required field in form

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.
 
B

Beetle

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top