Dbyte
Technical User
- Mar 6, 2002
- 87
I want to build an expression that calculates the age for someone using their date of birth. This will include people born before 1930. The catch is that I want it calculated (& entered into the table automatically) when the person entering the data exits out of the Date of Birth field on my form. I believe this can be done using the On Exit property, but can't figure out how to write the actual expression. I have the following 2 old queries that I would like to combine in this expression:
1. IIf((Int((Now()-[Date of Birth])/365.2425)/100)<0,Int((Now()-([Date of Birth]-36524.25))/365.2425),Int((Now()-[Date of Birth])/365.2425)) AS Age INTO [CITable]
2. UPDATE [Report Table] SET [Report Table].Age = 100-"Abs[Age]" WHERE ((([Report Table].Age)<0))
How can I change this into 1 all-inclusive expression, so that the calculation is done right after the date of birth is entered & people born before 1930 are calculated correctly? Or if it can't be done then, when/how should I go about accomplishing this? Thanks in advance for your help.
-D
1. IIf((Int((Now()-[Date of Birth])/365.2425)/100)<0,Int((Now()-([Date of Birth]-36524.25))/365.2425),Int((Now()-[Date of Birth])/365.2425)) AS Age INTO [CITable]
2. UPDATE [Report Table] SET [Report Table].Age = 100-"Abs[Age]" WHERE ((([Report Table].Age)<0))
How can I change this into 1 all-inclusive expression, so that the calculation is done right after the date of birth is entered & people born before 1930 are calculated correctly? Or if it can't be done then, when/how should I go about accomplishing this? Thanks in advance for your help.
-D