Jan Willem Stad wrote in a message to All:
JWS> Does anyone have any suggestions on how to create a field in
JWS> Access 7 which calculates age?
JWS> It has to be something like: After you type a birthdate in a field
JWS> in another field the current date has to be substracted from this
JWS> birthdate. But how to accomplish this?
There's probably several ways to do it. This is how I did mine. On the
AfterUpdate function for the Birthdate I entered this code to calculate the
age in the [age] field.
Private Sub Birthdate_AfterUpdate()
Dim ThisYear As Integer
Dim BirthYear As Integer
ThisYear = Year(Date)
BirthYear = Year([Birthdate])
Me![age] = ThisYear - BirthYear
End Sub
You will have to ensure that the input mask for the birthdate includes the
full year (i.e. 1956). If you don't any year less than 30 will return a
negative number (i.e. 20 Jun 29 would return a negative number).
Regards,
Mike...
Fidonet: 1:147/114
Internet: hendrixm@msn.com
--- FMail/386 1.02
---------------
* Origin: -==- OKCity Ok (1:147/114)
|