Age validation rule 17-65 (1 Viewer)

Afrooman108

New member
Local time
Today, 11:05
Joined
Apr 23, 2012
Messages
9
I need to use a validation rule that checks how old a person is by their date of birth.


Here is what i have so far, 6205 is the number days a 17 is alive, the difference in the date of birth must be more or equal to this, however it must be less that 23725 the number of days a 65 year old is alive.

6205<=DateDiff("d",[Date of Birth],[Employment Date]) And 23725>=DateDiff("d",[Date of Birth],[Employment Date])

Any help appreciated

Regards
 

Beetle

Duly Registered Boozer
Local time
Today, 05:05
Joined
Apr 30, 2011
Messages
1,808
Calculating age is a matter of determining the number of years since the Date Of Birth while taking into consideration whether or not their birthday has occurred yet in the current year. If it hasn't, then you subtract one. There are a lot of variations on this function. There are some examples here, here and here.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:05
Joined
Feb 19, 2002
Messages
42,970
Validation rules are very limited in what they can do. DateDiff() is a VBA function and so it cannot be used in a validation rule. Remember Jet/ACE have a life of their own separate from Access. That means that table validation rules must be able to run without having Access even loaded on the computer. You will need to do the validation at the form level in the form's BeforeUpdate event and cancel the update if the date is invalid.
You can try just subtracting the two dates. It might work.
 

Users who are viewing this thread

Top Bottom