Discussion Locked

Access 2000 Date Validation

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Ok, so this is my problem.

First, I am building a database in Access and using a form built in Access to add records. I am trying to do a form level validation with two date fields, a start and an end date. I don't want to force the validation at the table level as is causes a serious error, and I don't want the client to have access to debuging the problem. I just want to have a msgbox prompt the client that the end date cannot be set to before the start date, and that the start date cannot be greater than today (ie now()). Hopefully someone can help me out!

5 replies

by goliathkutaa

Also, the endDate is linked to an activeX Calendar control, so on mouse down it pops up a calendar so the use can select a year.

by dryflies

I am assuming you are using a calendar control to get your dates. I looked on my system and Calendar control 9.0 seems to be what is available. You will get the date from the "Value" property of the control. on your "OK button on the form containing the start and end date calendars add the DateDiff function to the on click event for the button such that the calendar form does not close and a warning is posted on the form about the start date being before the end date or the start date is before now().

retval = DateDiff("d",StartDate,EndDate)
if retval < 0 then warning and do not close form.
retval = DateDiff("d"StartDate, NOW)
if retval < 0 then warning and do not close form.
You can find the help for DateDiff in the visual basic help files that come up when you hit F1 in the Access VBA editor. piece O' Cake.

This discussion is closed to new replies.