Completing Age Range Field from Date of Birth

G

Guest

I am trying to complete an age range combo box automatically based on the
date of birth entered by the user but also allow the age range combo box to
be used if no date of birth is provided.

I have tried to use the DateDiff function but can't get it to work so then
can't get any further.

Any step by step advice would be appreciated.

Thanks.
 
F

fredg

I am trying to complete an age range combo box automatically based on the
date of birth entered by the user but also allow the age range combo box to
be used if no date of birth is provided.

I have tried to use the DateDiff function but can't get it to work so then
can't get any further.

Any step by step advice would be appreciated.

Thanks.
I have no idea what you mean by complete an age RANGE, but
to compute someone's age....

In a query:
Age: DateDiff("yyyy", [DOB], Date()) - IIF(Format([DOB], "mmdd") >
Format(Date(), "mmdd"), 1, 0)

Directly as the control source of an unbound control:
=DateDiff("yyyy",[DOB],Date())-IIf(Format([DOB],"mmdd")>Format(Date(),
"mmdd"),1,0)

You do know, I hope, that this Age computation should NOT be stored in
any table.
Just compute it and display it on a form or report, as needed.
 
G

Guest

fredg said:
I am trying to complete an age range combo box automatically based on the
date of birth entered by the user but also allow the age range combo box to
be used if no date of birth is provided.

I have tried to use the DateDiff function but can't get it to work so then
can't get any further.

Any step by step advice would be appreciated.

Thanks.
I have no idea what you mean by complete an age RANGE, but
to compute someone's age....

In a query:
Age: DateDiff("yyyy", [DOB], Date()) - IIF(Format([DOB], "mmdd") >
Format(Date(), "mmdd"), 1, 0)

Directly as the control source of an unbound control:
=DateDiff("yyyy",[DOB],Date())-IIf(Format([DOB],"mmdd")>Format(Date(),
"mmdd"),1,0)

You do know, I hope, that this Age computation should NOT be stored in
any table.
Just compute it and display it on a form or report, as needed.

Fred
Thanks for the help, after looking at it again I managed to use the
DateDiff function correctly. When I mean age range, i mean putting someone
into either 20-29 or 30-39 etc depending on their age. I need to do this as
soome people provide a date of birth but some just provide an age range.
Having an age range for everyone means I can produce statistics on
participants' ages.

Once again, thanks for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top