Validation on a Form Textbox Control

I would like a validation rule that make sure a date is entered in a field before the Data Entry person moves on to the next field.
GeneBatAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Jim HornConnect With a Mentor Microsoft SQL Server Developer, Architect, and AuthorCommented:
The Form.BeforeUpdate triggers when you move from one record on the form to the next.
The TextBox.BeforeUpdate triggers when you move from that text box to another.

>before the Data Entry person moves on to the next field.
This would imply TextBox.BeforeUpdate
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Place this code in your text box's BeforeUpdate event (rename the obvious)

Public Sub YourDateField_BeforeUpdate(Cancel as Integer)

If Not IsDate(Nz(Me.YourDateField, "banana")) then
   msgbox "{message to user of your choice, depending on work situation", vbOkOnly + vbInformation
   Cancel = True
   DoCmd.CancelEvent  '<-- Only if the above does not work.
End If

End Sub
0
 
GeneBatAuthor Commented:
I set up a test form with 2 textboxes on labeled StartDate and other Fullname&
When I move off the StartDate textbox and enter the Fullname  it lets me goto the next record without telling me to enter at StartDate& This is the problem Im having& I dont know which event to use. Im a rookie I been coding in MS Access for 2 months& :)
Thanks for any help you can give...
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>I dont know which event to use.
Before Update, because it is cancellable.
After Update does not let you cancel.
0
 
GeneBatAuthor Commented:
Well should I do the code on the Forms Before Update maybe?
0
 
GeneBatAuthor Commented:
Ok, I'll try it there, it works on the Form level!
 But I would have to check every date field right...
I think your way is better... :)
0
 
GeneBatAuthor Commented:
I works at the Textbox level just like you suggested...
Thanks, JimHorn
0
 
GeneBatAuthor Commented:
Thanks for the info... One day I'll be up there... :)
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Thanks for the grade.  Good luck with your project.  -Jim
0
All Courses

From novice to tech pro — start learning today.