Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validating dates

Status
Not open for further replies.

Knackers

Technical User
Apr 26, 2001
59
AU
I have two dtaes in a table - Start_date and End_date. How do I put a validation on End_date to ensure that it is greater than Start_date?
 
It depends on what you wan't to happen when the end_date is before the start date, e.g.

In a query, replace the End_date column with:

end_date: =iif([end_date]<[start_date],[start_date],[end_date])

This would replace the end_date with the start_date if the end_date was before the start_date.

HTH

Andrew.
 
Cheers Andrew.
All I really want to do is diplay a warning/notification that the end date must be after the start date.

Is there a way that I can just build a validation rule?
 
You could make a little function that checks your two dates, I would do it like this:

Function end_date_check(start_date,end_date)
if end_date<start_date then
msgbox &quot;Your end date must be after the start date.&quot;
else
end_date_check=end_date
endif
end function

This will alert the user when it finds a date error, you may wan't it to return a specific date to signify an error (to make it easier to use in a query), if so, just remove set the end_date_check value after the msgbox.

To use it all you have to do is replace [end_date] with:

=end_date_check([start_date],[end_date])



HTH

Andrew.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top