Calculate age (1 Viewer)

REDaughdril

Registered User.
Local time
Today, 18:24
Joined
Jan 23, 2000
Messages
58
I need to calculate a person's age at the time the field is entered. We enter the person's date of birth when we enter data. Please help. Thanks
 

Travis

Registered User.
Local time
Today, 16:24
Joined
Dec 17, 1999
Messages
1,332
Private Sub BirthDay_AfterUpdate()
intYearsOld =datediff("yyyy","#" & me.[BirthDay] & "#",date)
if datepart("m",#" & me.[BirthDay] & "#") < datepart("m",date)= False then
intYearsOld = intYearsOld - 1 'Just In case they have not had their birthday yet this year.
end if
me.[Age] = intYearsOld
end sub

This is accurate up to the month. If you want to go further add to the If statement and ElseIf datepart("m",#" & me.[BirthDay] & "#") = datepart("m",date)
if datepart("d",#" & me.[BirthDay] & "#") < datepart("d",date) then
intYearsOld = intYearsOld - 1
end if
 

Users who are viewing this thread

Top Bottom