Syntax for age in a form

  • Thread starter Thread starter Musiwa
  • Start date Start date
M

Musiwa

Help please I am triying to calculate an age in a form.
Is this possible I have the date of birth already
populated for each record and I was trying to use
datediff like in a query but this does not work in a
form. I need to know the age eachtime I use that record
 
Help please I am triying to calculate an age in a form.
Is this possible I have the date of birth already
populated for each record and I was trying to use
datediff like in a query but this does not work in a
form. I need to know the age eachtime I use that record

Set the Control Source of a textbox on the form to

=DateDiff("yyyy", [DOB], Date()) - IIF(Format([DOB], "mmdd") >
Format(Date(), "mmdd"), 1, 0)

Or you can put the same expression in a vacant Field cell in the query
and reference the calculated field as the control source.
 
Musiwa,

DateDiff should work ok in the control source property of an unbound
textbox on your form. One way of doing it is...
=DateDiff("yyyy",[DateOfBirth],Date())+(Format([DateOfBirth],"mmdd")>Format(Date(),"mmdd"))

- Steve Schapel, Microsoft Access MVP
 
Back
Top