Date Validations

zar786

Registered User.
Local time
Today, 20:00
Joined
Mar 30, 2005
Messages
11
I have 2 text boxes were the user enters a start and end date for a list of fixtures, i need to validate them using vba to ensure a value has been entered, they are valid dates, not in the past and the end date must not be before the start date, once entered i have a command button which runs a report with a list of fixtures for that period.

I thought this would be pretty easy but proving to be difficult, on the textbox before update event this is what i have so far, but not working:

Code:
Dim dtStartDate As Date
Cancel = True
If IsNull ([matchDay]) Then 'is field blank?
myDisplayWarningMessage "Please enter a value for Start Date"
ElseIf Not IsDate([matchDay]) Then
myDisplayWarningMessage "Date format is not valid"
End If

the matchDay is the field were the dates are derived from, but i assume i need to specify which table etc this is in, not sure how to do this?

if i just leave Cancel = True it won't run the report if nothing is entered but then ofcourse cancels everything so even if a valid date is entered it won't run.

Would really appreciate some guidance with this...
 
Code:
If Not IsDate([matchDay]) Then
 MsgBox "Please enter a valid Start Date", vbExclamation, "Invalid or Missing Start Date"
 Cancel = True
End If
 

Users who are viewing this thread

Back
Top Bottom