I would set the Validation property of the text box to:
Validation Rule: Between #1/8/2017# And Date()
Then set the Validation text to:
Validation Text: Must be Between 1/8/2017 and current date
This all assumes your date formats are similar to the US.
Regards,
Duane
Sent: Wednesday, August 2, 2017 12:31 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Date comparisons in a form control
Hi Guys
This one should be straightforward I hope ....
In a form control I am trying to prevent the user from putting in an incorrect date.
I only want the date to be between 1/8/17 and the current date
I have the following code triggered by the On Exit event of the control
if [date placed] < 1/8/17 then
msgbox "date placed cannot be before 1/8/17"
[date placed] = null
elseif [date placed] > date then
msgbox "date placed cannot be in the future"
[date placed] = date
end if
the elseif seems to work perfectly but the test for before 1/8/17 doesn't work properly.
What am I doing wrong?
Also, so that I don't have to change the code each year, how can I code it so that between 1/8/nn and 31/7/nn+1 it uses 1/8/nn for the date test?
cheers
Phil
Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (2) |
Tidak ada komentar:
Posting Komentar