What do you think will be returned from this formula?>>
Code:
IIf([Text1>89],0,0)
Wouldn't
Code:
IIf([Text1>89],1,0)
be better??
I wouldn't use the Count() function, Sum() might be better.
Code:
Sum(IIf([Text1>89],1,0))
To calculate the age, I use a function
Code:
Function GetAge(varDOB As Variant, Optional varAsOf As Variant) As Variant
'Purpose: Return the Age in years.
'Arguments: varDOB = Date Of Birth
' varAsOf = the date to calculate the age at, or today if missing.
'Return: Whole number of years.
Dim dtDOB As Date
Dim dtAsOf As Date
Dim dtBDay As Date 'Birthday in the year of calculation.
GetAge = Null 'Initialize to Null
'Validate parameters
If IsDate(varDOB) Then
dtDOB = varDOB
If Not IsDate(varAsOf) Then 'Date to calculate age from.
dtAsOf = Date
Else
dtAsOf = varAsOf
End If
If dtAsOf >= dtDOB Then 'Calculate only if it's after person was born.
dtBDay = DateSerial(Year(dtAsOf), Month(dtDOB), Day(dtDOB))
GetAge = DateDiff("yyyy", dtDOB, dtAsOf) + (dtBDay > dtAsOf)
End If
End If
End Function
The usage would be:
The Text Box (Textbox1) control source would be "=GetAge([Birthdate])".
or "=GetAge([Birthdate], #1/1/2017#)"