Validating Date

  • Thread starter Thread starter Guest
  • Start date Start 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.
 
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
 
Back
Top