Hi
I have an input form that collects attendee details and need to make sure that each field is filled in. I have used the code below on the before update event of the form but when I try to close the form, the message box works and when I click ok I have the you cannot save this record at this time message, what is my code missing?
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me![At_Date_of_birth]) Then
MsgBox "You must enter a 'Date od Birth' before this Record can be saved"
Cancel = True: Me!Date_of_birth.SetFocus
ElseIf IsNull(Me![At_Gender]) Then
MsgBox "You must enter 'Gender' before this Record can be saved"
Cancel = True: Me!Gender.SetFocus
ElseIf IsNull(Me![At_Tel Number]) Then
MsgBox "You must enter a Preferred telehone number before this Record can be saved"
Cancel = True: Me!Telephone__Number.SetFocus
ElseIf IsNull(Me![At_Address 1]) Then
MsgBox "You must enter address line 1 before this Record can be saved"
Cancel = True: Me!Address_1.SetFocus
End If
End Sub
Thank you for your help
I have an input form that collects attendee details and need to make sure that each field is filled in. I have used the code below on the before update event of the form but when I try to close the form, the message box works and when I click ok I have the you cannot save this record at this time message, what is my code missing?
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me![At_Date_of_birth]) Then
MsgBox "You must enter a 'Date od Birth' before this Record can be saved"
Cancel = True: Me!Date_of_birth.SetFocus
ElseIf IsNull(Me![At_Gender]) Then
MsgBox "You must enter 'Gender' before this Record can be saved"
Cancel = True: Me!Gender.SetFocus
ElseIf IsNull(Me![At_Tel Number]) Then
MsgBox "You must enter a Preferred telehone number before this Record can be saved"
Cancel = True: Me!Telephone__Number.SetFocus
ElseIf IsNull(Me![At_Address 1]) Then
MsgBox "You must enter address line 1 before this Record can be saved"
Cancel = True: Me!Address_1.SetFocus
End If
End Sub
Thank you for your help