D
dbl
Hi I have the following code in my Text330 field
=LiscYrs([LicHeldDate]) & " Yrs " & AgeMonths([LicHeldDate]) & " Mths"
if no date is entered I get an #Error how do I set it up so that if me
LicHeldDate Field is blank my Text330 field is blank.
It works correctly when a date is entered.
I have copied in the Module codes for LiscYrs and AgeMonths
Function AgeMonths(ByVal StartDate As String) As Integer
Dim tAge As Double
tAge = (DateDiff("m", StartDate, Now))
If (DatePart("d", StartDate) > DatePart("d", Now)) Then
tAge = tAge - 1
End If
If tAge < 0 Then
tAge = tAge + 1
End If
AgeMonths = CInt(tAge Mod 12)
End Function
Function LiscYrs(varTestDate As Variant) As Variant
Dim varYrs As Variant
If IsNull(varTestDate) Then
varYrs = Null
Else
varYrs = DateDiff("yyyy", varTestDate, Date)
If Date < DateSerial(Year(Date), Month(varTestDate), _
Day(varTestDate)) Then
varYrs = varYrs - 1
End If
End If
LiscYrs = varYrs
End Function
The above code does what I need in a different part of the db and works
correctly.
Any help would be much appreciated.
Bob
=LiscYrs([LicHeldDate]) & " Yrs " & AgeMonths([LicHeldDate]) & " Mths"
if no date is entered I get an #Error how do I set it up so that if me
LicHeldDate Field is blank my Text330 field is blank.
It works correctly when a date is entered.
I have copied in the Module codes for LiscYrs and AgeMonths
Function AgeMonths(ByVal StartDate As String) As Integer
Dim tAge As Double
tAge = (DateDiff("m", StartDate, Now))
If (DatePart("d", StartDate) > DatePart("d", Now)) Then
tAge = tAge - 1
End If
If tAge < 0 Then
tAge = tAge + 1
End If
AgeMonths = CInt(tAge Mod 12)
End Function
Function LiscYrs(varTestDate As Variant) As Variant
Dim varYrs As Variant
If IsNull(varTestDate) Then
varYrs = Null
Else
varYrs = DateDiff("yyyy", varTestDate, Date)
If Date < DateSerial(Year(Date), Month(varTestDate), _
Day(varTestDate)) Then
varYrs = varYrs - 1
End If
End If
LiscYrs = varYrs
End Function
The above code does what I need in a different part of the db and works
correctly.
Any help would be much appreciated.
Bob