By no means am I a VBA expert. I am getting better and probably to the extent where I am most dangerous! I have a form with required fields. In order to force these requirements on the user I use a message box to alert the user of the requirement followed by a SetFocus back to the required text field. However, I do have a command button that allows the user to basically cancel the data entry session for the form and exit to the Main Menu. How can I override or cancel the SetFocus on the various required fields when the user simply opts to cancel the data entry and exit to the main menu? Because of the SetFocus on these text fields I keep getting the message box alert that the field is required and placed back into the required field as a result fo the SetFocus.
I have copied the VBA for one of the required fields (They are all basically the same) and the VBA behind the "Main Menu" command button below. Any help is much appreciated.
Text Field VBA:
Private Sub Txt_Cust_Name_Exit(Cancel As Integer)
If IsNull(Me.Txt_Cust_Name) Then
MsgBox "This is a Required Field." & vbCrLf & "Please Enter the Customer Name Before Proceeding"
Cancel = True
Me.Txt_Cust_Name.SetFocus
End If
End Sub
Main Menu Command Button:
Private Sub Cmd_Open_Main_Menu_06_Click()
MsgBox "This New Customer Has NOT Been Added"
DoCmd.Close acForm, "Frm_New_Customer", acSaveNo
DoCmd.OpenForm "Frm_Main_Menu", acNormal
End Sub
I have copied the VBA for one of the required fields (They are all basically the same) and the VBA behind the "Main Menu" command button below. Any help is much appreciated.
Text Field VBA:
Private Sub Txt_Cust_Name_Exit(Cancel As Integer)
If IsNull(Me.Txt_Cust_Name) Then
MsgBox "This is a Required Field." & vbCrLf & "Please Enter the Customer Name Before Proceeding"
Cancel = True
Me.Txt_Cust_Name.SetFocus
End If
End Sub
Main Menu Command Button:
Private Sub Cmd_Open_Main_Menu_06_Click()
MsgBox "This New Customer Has NOT Been Added"
DoCmd.Close acForm, "Frm_New_Customer", acSaveNo
DoCmd.OpenForm "Frm_Main_Menu", acNormal
End Sub