apsonline
asked on
Trying to insert age into a form
I have a form that includes contact information and has a field for DOB. I would like to automatically calculate the person's age from the DOB field and have it display in the form. I am able to do this in a query but for some reason am having trouble getting the query results to show in the Age field in my form. Any help would be appreciated.
ASKER
Not triggering anything on exit
The Age field would be the result of data entry; in other words the DOB field already contains a birthdate, I just need the Age field to display the current age.
The Age field would be the result of data entry; in other words the DOB field already contains a birthdate, I just need the Age field to display the current age.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm not exactly an Access expert, I might need slightly more specific instructions. So far I created a new module called AgeSimple and pasted the above code. I created a new textbox in the form named Age and inserted
=AgeSimple([Birthdate])
"Birthdate" is the name of my DOB field. When I open the form I get #Name? in the Text Box.
What am I missing?
Thanks
=AgeSimple([Birthdate])
"Birthdate" is the name of my DOB field. When I open the form I get #Name? in the Text Box.
What am I missing?
Thanks
This may sound like a simple question, but have you defined your DOB field in the table as Date/Time?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It could be that the textbox needs to be renamed to, say, txtAge.
/gustav
/gustav
ASKER
Got it working, I didn't do the module right at first. Is it a lot of trouble to supress the #ERROR result if the DOB field is empty?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or, when displaying the record in the form, is the data the result of a filter/search or from data entry?