Date validation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a textbox on a form used to capture the start date used as a
parameter for a query. I want to validate that the date is valid. For
example, Feb 29, 2005 is invalid, and currently it breaks the sql code. Is
there a way to check the date in the textbox before executing the query?
thanks in advance for any assistance.
 
Try this

On the before update event of the Text field write the code
=======================================
On error goto MySub_Error
Dim MyDate
' If the cvdate will get an error it will prompt the user with a message
MyDate = CvDate(Me.[TextFieldName])
Exit Sub

MySub_Error:
msgbox "Error in date"
cancel = True 'wont let the user exit the field
==================================
 
Back
Top