Roger Bell said:
Thanks for the information Dirk. Do I need to generate all the code
shown here or only part of it? Sorry to be such a nuisance and Thanks
Copy everything between the "*** Code Start ***" and "*** Code End ***"
lines, and paste it into a standard module. If you create a new module
for the purpose, don't name the module the same as the function.
With that function in place, you can use it on your form, or in the
query your form is based on. The person's age, as calculated by the
function, shouldn't actually be stored in the table, because it changes
from day to day and can always be calculated from the date of birth.
Instead, use a calculated field in the form's recordsource query, or a
calculated control on the form, to compute and display the age for each
record.
In a query, you would use a calculated field defined (in query design
view) like this:
Age: Diff2Dates("ym", [Date of Birth], Date(), False)
Then the calculated Age field would be available in your form's field
list and you could bind a text box to it.
Or you could use a calculated text box on the form, setting its
ControlSource property to:
=Diff2Dates("ym", [Date of Birth], Date(), False)
Does that clarify how to use the function? I've taken your word for it
that you want to show years and months, and not years. months, and days,
which is also possible with that function.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)