Hi,
In the form I have designed, I want the Age to be calculated and printed side-by-side when the DOB is entered.
How shall I go about it?
Hi,
In the form I have designed, I want the Age to be calculated and printed side-by-side when the DOB is entered.
How shall I go about it?
I have seen several ways of calculating the age from the date of birth. Here is one link
It is not giving the desired results.
Pl suggest some other way out..
The solution offered by does work. If it is not working for you then you must be doing something wrong. The expression:-
=DateDiff("yyyy",[Birthdate],Now())+Int(Format(Now(),"mmdd")<Format([Birthdate],"mmdd"))
should be used as the Control Source for the textbox that is used to show the age.
Birthdate should be changed to the name of the textbox that holds the DOB.
If this helped, please click the star at the bottom left of this posting and add to my reputation. Many thanks.
Bob Fitzpatrick
But still I don't get the age calculated. Instead, when I view the form in the form view, I get to see "#Name?" written in place of any age...
Last edited by coolpal9; 01-09-2012 at 11:50 PM.
Then you've got a variable misnamed, a spelling error or you have bound the field to something you shouldn't have or nothing.
Could be a multitude of errors.
Coolpal9,
Is it possible for you to zip & post your database (with any sensitive data removed)? That way we can explore the issue further.
Yeah, there was a minor error.
But after that, now the Age textbox always returns 113 as the result.
1. What is the datatype of the field where the birthdate is stored? Is it really a date/time field and not TEXT?
2. How is the date stored? What is the date format that you use in the database?
You might need to format to U.S. date format if you are not in the U.S. (thank Microsoft for that one):
=DateDiff("yyyy",[Birthdate],Format(Date(),"\#mm\/dd\/yyyy\#")+Int(Format(Date(),"\#mm\/dd\/yyyy\#"<Format([Birthdate],"mmdd"))
And I would use DATE() instead of NOW because that eliminates the time element which you aren't concerned with anyway.
It is date/time.
Format is mm/dd/yyyy
Check the attachment...
It shows #Error. I don't know what syntactic error is there. I've checked it many times.
Pl help...
The name of your DOB control is not DOB but rather DOB_Text. You have to use DOB_Text in the expression. Corrected DB is attached.
Thank you!