required field in form

  • Thread starter Thread starter NAS
  • Start date Start date
N

NAS

How do I make a field on a form required? I don't want the user to be able to
continue unless they fill out a certain field, kind of like when you fill out
a form online and you miss something, it lets you know, if that makes sense.
I would also like to create a message box telling the user what they miss.
One of the fields is time in 24 hour format and the other is a date in
YYYYMMDD format. Access 2003 on Windows XP.
 
Use the forms BeforeUpdate event to validate data entry;

Private Sub Form_BeforeUpdate (Cancel As Integer)

If IsNull(Me!YourTimeField) Then
Cancel = True
MsgBox "Please fill out the Time field!"
Me!YourTimeTextBox.SetFocus
ElseIf IsNull(Me!YourDateField) Then
Cancel = True
MsgBox "Please fill out the Date field!"
Me!YourDateTextBox.SetFocus
End If

End Sub
 
Back
Top