I have placed code on the After_Update event of a form to check if a field named Quantity has been left null.
If IsNull(Me.Quantity) Then
MsgBox "You must enter a Quantity, it is a required field."
DoCmd.GoToControl "Quantity"
Cancel = True
End If
If the user presses the close button in the upper right hand corner of the form, It gives the message that quantity was left null, however, the form still closes. Is there a way I can prevent this from happening. I thought the Cancel=True would cause the form to remain open, however, it does not. Any suggestions??
Note: The code is also on a command button I created to close the form. I know that I can take the close button off of the upper right hand corner of the form in the form properties, however the button is still there unless the form is not maximized. Users would like all forms in the database to be maximized so they can see all data on the form.
If IsNull(Me.Quantity) Then
MsgBox "You must enter a Quantity, it is a required field."
DoCmd.GoToControl "Quantity"
Cancel = True
End If
If the user presses the close button in the upper right hand corner of the form, It gives the message that quantity was left null, however, the form still closes. Is there a way I can prevent this from happening. I thought the Cancel=True would cause the form to remain open, however, it does not. Any suggestions??
Note: The code is also on a command button I created to close the form. I know that I can take the close button off of the upper right hand corner of the form in the form properties, however the button is still there unless the form is not maximized. Users would like all forms in the database to be maximized so they can see all data on the form.