View Full Version : DOB to AGE?


Pasadena
01-30-2001, 07:59 PM
I have a form with DOB control and AGE control. When the DOB date is filled in, the age is automatically filled with the age; however, the age number is not put into the table. It stays on the form though. Does anyone know what I need to add or change to make sure the age is also shown on the table? Im using A2K and the following code is placed into the control source text box of the age.

=IIf(((DatePart("m",Date())=DatePart("m",[DOB])) And (DatePart("d",Date())=DatePart("d",[DOB]))) Or (DatePart("m",Date())>DatePart("m",[DOB])) Or (DatePart("m",Date())=DatePart("m",[DOB]) And DatePart("d",Date())>DatePart("d",[DOB])),DateDiff("yyyy",[DOB],Date()),DateDiff("yyyy",[DOB],Date())-1)

Thank you for any ideas!

Atomic Shrimp
01-30-2001, 11:57 PM
I thought for a moment I had been able to simplfy the age calculation down to:
Format([date2]-[date1],"yy")
but this only works if the person's age is 99 or less

Anyway, are you sure that you want to store the person's current age in a table? - this is usually not recommended, as you have to update it all the time. Surely it would be simpler to calculate it whenever it is required.
(Unless you want to store the person's age when they were added to the list as a fixed value, in which case you would add the AgeWhenJoined field to your table, then add a text box to your form which is bound to that field, then (I'm not sure which event would be the best one to use to make it happen, but probably the AfterUpdate event of the DOB text box) use code like:

Me.txtAgeWhenJoined = (your formula)

HTH

Mike

Pasadena
01-31-2001, 12:28 AM
I need the age to show the persons age at the time he/she committed the offense. We use it for statistics.

Pasadena
01-31-2001, 01:45 AM
No that didnt work.