Validating Date

G

Guest

I have a StartDate and an EndDate textbox on a form that's unbound. How can I
validate when the user click on a command button, i.e., April 31, 2006 is
invalidate because April does not have 31 days? For now everytime an invalid
date is entered Access shows a non-user-friendly message. Thanks in advance.
 
B

Barry Gilbert

In the textbox's BeforeUpdate event put this code:

If Not IsDate(Me.StartDate) Then
Msgbox "Invalid date"
Cancel=True
Endif

This will validate the date before ever getting to the command button.

HTH,
Barry
 

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