Link to home
Start Free TrialLog in
Avatar of apsonline
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.
Avatar of Runrigger
Runrigger
Flag of United Kingdom of Great Britain and Northern Ireland image

are you triggering any events on exit from the forms DOB field?

or, when displaying the record in the form, is the data the result of a filter/search or from data entry?
Avatar of apsonline
apsonline

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.
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
This may sound like a simple question, but have you defined your DOB field in the table as Date/Time?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It could be that the textbox needs to be renamed to, say, txtAge.

/gustav
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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial