Calculating Age

P

PawleysGrits

Using Access 2003, & WIN XP-Pro. In a table, I have an employee's birth
date, defined as dd-mmm-yyy. In a form, I would like to calculate the age
of the employee, and such is done with

=DateDiff("yyyy",[Birthdate],Now())+Int(Format(Now(),"mmdd")<Format([Birthda
te],"mmdd"))"

The problem is that each time I open the form, the age calculation
evaporates - it will work one time, and not another, with absolutely NO
changes being made to the form or table design. This isn't the only thing
that works sporadically; a control to create the employee name (from
separate first and last name fields) in a form page header comes and goes at
will.

I would appreciate any suggestions, and thanks in advance!
 
J

John Vinson

Using Access 2003, & WIN XP-Pro. In a table, I have an employee's birth
date, defined as dd-mmm-yyy. In a form, I would like to calculate the age
of the employee, and such is done with

=DateDiff("yyyy",[Birthdate],Now())+Int(Format(Now(),"mmdd")<Format([Birthda
te],"mmdd"))"

The problem is that each time I open the form, the age calculation
evaporates - it will work one time, and not another, with absolutely NO
changes being made to the form or table design. This isn't the only thing
that works sporadically; a control to create the employee name (from
separate first and last name fields) in a form page header comes and goes at
will.

I would appreciate any suggestions, and thanks in advance!

What's the Form's Recordsource? Does it include the [Birthdate] field,
and is that field in fact a non-null Date/Time field?

If that's all correct, I suspect the Form may be corrupt. Have you
tried Tools... Database Utilities... Compact and Repair? YOu may also
want to try creating a new (simple, stripped down, with just the
Birthdate and calculated Age controls) form to be sure that the data
is in fact there and correct.

John W. Vinson[MVP]
(no longer chatting for now)
 
P

PawleysGrits

Your suggestion to create another form containing only the calculated
controls worked, and that inspired me to trash the errant form and start
over. Happily, the problem is solved. Thank you for your assistance.

John Vinson said:
Using Access 2003, & WIN XP-Pro. In a table, I have an employee's birth
date, defined as dd-mmm-yyy. In a form, I would like to calculate the age
of the employee, and such is done with

=DateDiff("yyyy",[Birthdate],Now())+Int(Format(Now(),"mmdd")<Format([Birthd
a
te],"mmdd"))"

The problem is that each time I open the form, the age calculation
evaporates - it will work one time, and not another, with absolutely NO
changes being made to the form or table design. This isn't the only thing
that works sporadically; a control to create the employee name (from
separate first and last name fields) in a form page header comes and goes at
will.

I would appreciate any suggestions, and thanks in advance!

What's the Form's Recordsource? Does it include the [Birthdate] field,
and is that field in fact a non-null Date/Time field?

If that's all correct, I suspect the Form may be corrupt. Have you
tried Tools... Database Utilities... Compact and Repair? YOu may also
want to try creating a new (simple, stripped down, with just the
Birthdate and calculated Age controls) form to be sure that the data
is in fact there and correct.

John W. Vinson[MVP]
(no longer chatting for now)
 

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