I have a main form with a date field I want to be filled in before the user proceeds.
I have searched the forum and found the following code which I have implemented however, no matter where I placed it it just keeps on allowing the cursor to move to the next field on the subform and allows the form to be closed also. It doesn't save the record because until the date field is completed, no record is created but I want it to stop the user, return to the date field and make them enter a date.
Private Sub AuditDate_BeforeUpdate(Cancel As Integer)
If IsNull(Me.AuditDate) Or Me.AuditDate = "" Then
MsgBox "You must enter a date!"
AuditDate.SetFocus
Exit Sub
End If
End Sub
Any ideas? thanks
I have searched the forum and found the following code which I have implemented however, no matter where I placed it it just keeps on allowing the cursor to move to the next field on the subform and allows the form to be closed also. It doesn't save the record because until the date field is completed, no record is created but I want it to stop the user, return to the date field and make them enter a date.
Private Sub AuditDate_BeforeUpdate(Cancel As Integer)
If IsNull(Me.AuditDate) Or Me.AuditDate = "" Then
MsgBox "You must enter a date!"
AuditDate.SetFocus
Exit Sub
End If
End Sub
Any ideas? thanks