I have an employee list with their date of birth ,I need to calculate whether they are below or above 40 years old to determine if they are eligible for insurance,here is the vba code for that
If IsDate(Application.WorksheetFunction.VLookup(Me.Label1, [Emplist_dob], 15, 0)) Then
Label6.Caption = IIf(DateDiff("yyyy", Application.WorksheetFunction.VLookup(Me.Label1, [Emplist_dob], 15, 0), Date) >= 40, "Above 40 no insurance", "Below 40 eligible for insurance")
End If
If IsDate(Application.WorksheetFunction.VLookup(Me.Label1, [Emplist_dob], 15, 0)) Then
Label6.Caption = IIf(DateDiff("yyyy", Application.WorksheetFunction.VLookup(Me.Label1, [Emplist_dob], 15, 0), Date) >= 40, "Above 40 no insurance", "Below 40 eligible for insurance")
End If
No comments:
Post a Comment