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_Name = Me.IDNO.Column(1) & ", " & Me.IDNO.Column(2)
Me.DOH = Me.IDNO.Column(20)
Me.Recruit_Class = 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_Service.value = YOS