I am trying to create a function that calculates the amount of accrued vacation and sick time a person has on the current date. For example there are 26 pay periods in a year. If the current date were 11/07/03 that would be pay period 23. Since an employee accrues 6.7667 hours of vac each pay period and 4.6167 hours sick time each pay period I need to be able to determine what they currently have available.
Below is a SHORT version of my attempt at the vacation calculation. There must be a better way. Right? Any suggestions are appreciated.
Below is a SHORT version of my attempt at the vacation calculation. There must be a better way. Right? Any suggestions are appreciated.
Code:
Public Function setavHrs()
Dim lTime
If Nz(Me.annDate.Value) = "" Or Nz(Me.cat.Value) = "" Then
Exit Function
End If
If Me.cat.Value = 2 Then
lTime = DateDiff("d", Me.annDate.Value, Now()) / 14
Select Case lTime
Case Is = 1
Me.avHrs.Value = 6.7667
Case Is = 2
Me.avHrs.Value = 13.5333
Case Is = 3
Me.avHrs.Value = 20.3000
Case Is = 4
Me.avHrs.Value = 27.0667
Case Is = 5
Me.avHrs.Value = 33.8333
Case Is = 6
Me.avHrs.Value = 40.6000
Case Is = 7
Me.avHrs.Value = 47.3667
‘ this would continue for up to 26 pay periods
End Select
End If
End Function