TIP: Click on subject to list as thread! ANSI
echo: win_access
to: JAN WILLEM STAD
from: MIKE HENDRIX
date: 1996-07-26 12:44:00
subject: Calculating age

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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.