Date validation

anto.danny

Registered User.
Local time
Today, 11:38
Joined
Nov 8, 2015
Messages
35
Hello,

I want a vba code that checks the date and if the date is below 1-1-1990 then it should open a form. I know a bit of vba but I cant figure out how to enter the date in vba

Code:
If me.dateofbirth < 1-1-1990 then
DoCmd.OpenForm "helloworld"
end if

Also which event should I put the code in, so that the form opens as soon as the user goes to the next textbox?
 
after update event of your control.
 
after update event of your control.
Its on the lost focus event of the dateofbirth textbox, but the code doesn't work when I enter a date below the year 1990. Is there a format I need to follow to use a specific date???
 
try casting your date constant with #:

If me.dateofbirth < #1-1-1990# then
DoCmd.OpenForm "helloworld"
end if
 
happy coding!
 

Users who are viewing this thread

Back
Top Bottom