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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

GeneBatAuthor Commented:
Well should I do the code on the Forms Before Update maybe?
0
Jim HornMicrosoft 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.