Lynn_AccessUser
Registered User.
- Local time
- Today, 09:12
- Joined
- Feb 4, 2003
- Messages
- 125
I have the following function to calculate the age based on the DOB:
Function Age(varDOB As Variant) As Integer
Dim varAge As Variant
If IsNull(varDOB) Then Age = 0: Exit Function
varAge = DateDiff("yyyy", varDOB, Now)
If Date < DateSerial(Year(Now), Month(varDOB), _
Day(varDOB)) Then
varAge = varAge - 1
End If
Age = CInt(varAge)
End Function
The problem is that the age continues to calculate on people who are deceased. If I have a checkbox to check if the person is deceased, how do I prevent the age from continuing to calculate.
Currently, the age function is being called in the query as
Age: Age([DOB])
Function Age(varDOB As Variant) As Integer
Dim varAge As Variant
If IsNull(varDOB) Then Age = 0: Exit Function
varAge = DateDiff("yyyy", varDOB, Now)
If Date < DateSerial(Year(Now), Month(varDOB), _
Day(varDOB)) Then
varAge = varAge - 1
End If
Age = CInt(varAge)
End Function
The problem is that the age continues to calculate on people who are deceased. If I have a checkbox to check if the person is deceased, how do I prevent the age from continuing to calculate.
Currently, the age function is being called in the query as
Age: Age([DOB])