G
Guest
Hello, I have a form that has a subform. On the main form, I need the user
to make a selection from two different pulldown menus before they are allowed
to move to the subform. If the user doesn’t make a selection from those
menus, I want to prevent the data from being saved and set the focus to the
control that the user didn’t make a selection for. The code works fine and
does this, but after my error message runs, the user gets another error
message that says “You canceled the previous operation.†How can I prevent
that second message from running?
I have code that looks like this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull([VName]) Then
DoCmd.CancelEvent
MsgBox "Please enter VName.", , "VName"
Me![VName].SetFocus
ElseIf IsNull([VTypeID]) Then
DoCmd.CancelEvent
MsgBox "Please select the VType.", , "VType"
Me![VTypeID].SetFocus
End If
Exit Sub
End Sub
I'm still new to this. Any help is appreciated!
Thanks
to make a selection from two different pulldown menus before they are allowed
to move to the subform. If the user doesn’t make a selection from those
menus, I want to prevent the data from being saved and set the focus to the
control that the user didn’t make a selection for. The code works fine and
does this, but after my error message runs, the user gets another error
message that says “You canceled the previous operation.†How can I prevent
that second message from running?
I have code that looks like this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull([VName]) Then
DoCmd.CancelEvent
MsgBox "Please enter VName.", , "VName"
Me![VName].SetFocus
ElseIf IsNull([VTypeID]) Then
DoCmd.CancelEvent
MsgBox "Please select the VType.", , "VType"
Me![VTypeID].SetFocus
End If
Exit Sub
End Sub
I'm still new to this. Any help is appreciated!
Thanks