I have a function which caculates the number of years from a certain
date. The function works great if the date is not null however when
the date is null I recieve a type mismatch error. The code is below.
Any assistance is appreciated. Thanks!!
Dim YOS As String
Me.date1 = Year(Me.Injury_ Date)
Me.Employee_Nam e = Me.IDNO.Column( 1) & ", " & Me.IDNO.Column( 2)
Me.DOH = Me.IDNO.Column( 20)
Me.Recruit_Clas s = Me.IDNO.Column( 19)
YOS = DateDiff("yyyy" , [DOH], Date) - IIf(Format(Date , "mmdd") <
Format([DOH], "mmdd"), 1, 0) 'breaks here on null of DOH
Me.Years_of_Ser vice.value = YOS
date. The function works great if the date is not null however when
the date is null I recieve a type mismatch error. The code is below.
Any assistance is appreciated. Thanks!!
Dim YOS As String
Me.date1 = Year(Me.Injury_ Date)
Me.Employee_Nam e = Me.IDNO.Column( 1) & ", " & Me.IDNO.Column( 2)
Me.DOH = Me.IDNO.Column( 20)
Me.Recruit_Clas s = Me.IDNO.Column( 19)
YOS = DateDiff("yyyy" , [DOH], Date) - IIf(Format(Date , "mmdd") <
Format([DOH], "mmdd"), 1, 0) 'breaks here on null of DOH
Me.Years_of_Ser vice.value = YOS
Comment