Jessica:
You can do this with a single function:
Public Function GetAgeWithMonths(varDoB, varClosedate) As String
Dim intYears As Integer, intMonths As Integer
Dim varDateAt As Date
' if no close date then compute age
' at current date, otherwise at close date
varDateAt = Nz(varClosedate, VBA.Date)
If Not IsNull(varDoB) Then
' get difference in years
intYears = DateDiff("yyyy", varDoB, varDateAt)
' get difference in months
intMonths = DateDiff("m", varDoB, _
DateSerial(Year(varDoB), Month(varDateAt), Day(varDateAt)))
' adjust result if date of birth falls later in year
' than date at which age to be calculated
If varDateAt < DateSerial(Year(varDateAt), Month(varDoB), Day(varDoB))
Then
intYears = intYears - 1
intMonths = intMonths + 12
End If
End If
GetAgeWithMonths = intYears & " year" & _
IIf(intYears <> 1, "s", "") & _
" " & intMonths & " month" & _
IIf(intMonths <> 1, "s", "")
End Function
The expression would then be as follows, passing both the date of birth and
the close date into the function:
AgeWithMonth: GetAgeWithMonths([BirthDate], [Date Close])
If Close Date is Null the function will compute the age at the current date,
otherwise at the close date.
Ken Sheridan
Stafford, England
I have the following fields Age, birthdate and date close. To calculate age
in years and months i have the below function
AgeWithMonth: Age([BirthDate]) & " years, " & AgeMonths([BirthDate]) & "
months". I need the agewithmonth function to stop calculating the age when i
enter a closing date. So that would give me the age of the client when the
case was close.
[quoted text clipped - 22 lines]
see how old a client was when their case was close. I have the below fields
birth date and age in months and years.
--
Message posted via AccessMonster.com
.