I have a main form (frmMain) and within it a subform (fsubDetails). Each are based on a separate query. Once a record has been created and the focus is on fsubDetails, I want to validate two fields within fsubDetails, and until these conditions have been met, I don't want the user to be able to move focus back to frmMain. The two fields within fsubDetails are:
Both must have data entered into them. If they are Null (once a new record has been created in fsubDetails), then the focus can not go beyond fsubDetails.
With that in mind, I have the following code on fsubDetails BeforeUpdate Event Procedure:
If IsNull(txtNumber) Then
MsgBox "Number field can not be left blank."
ElseIf IsNull(txtAddress) Then
MsgBox "Address can not be left blank."
The problem I have, is that once I prompt a message caused by leaving txtNumber or txtAddress blank (Null), I am then allowed to change focus to frmMain. This isn't what I want to be happening - I need the focus to stay within fsubDetails until the user enters data into txtNumber and txtAddress. Its probably so simple, its staring me in the face, but if anyone can see where I am going wrong I would greatly appreciate your help.