S
Secret Squirrel
I'm using a case select to calculate vacation hours for my employees. Since
this is done in VBA behind a form I can't duplicate this function in a query.
Or can I? What I'm trying to do is create a query that lists the accrued
vacation time just like the case select does and then subtract the time used
from that accrued time and then append the results to a table. But before I
can create the append query I need to create a query that will do the same as
the case select. Any ideas on how this can be done?
Function VacHoursEarned(CalcYear As Variant) As Variant
If IsNull(CalcYear) Then
VacHoursEarned = Null
Exit Function
End If
Select Case CalcYear
Case Is < 2
VacHoursEarned = 0
Case 2 To 4
VacHoursEarned = 80
Case 5 To 9
VacHoursEarned = 96
Case 10 To 14
VacHoursEarned = 120
Case 15 To 19
VacHoursEarned = 128
Case 20 To 24
VacHoursEarned = 136
Case 25 To 29
VacHoursEarned = 144
Case 30 To 34
VacHoursEarned = 152
Case Is >= 35
VacHoursEarned = 160
Case Else
VacHoursEarned = Null
End Select
End Function
this is done in VBA behind a form I can't duplicate this function in a query.
Or can I? What I'm trying to do is create a query that lists the accrued
vacation time just like the case select does and then subtract the time used
from that accrued time and then append the results to a table. But before I
can create the append query I need to create a query that will do the same as
the case select. Any ideas on how this can be done?
Function VacHoursEarned(CalcYear As Variant) As Variant
If IsNull(CalcYear) Then
VacHoursEarned = Null
Exit Function
End If
Select Case CalcYear
Case Is < 2
VacHoursEarned = 0
Case 2 To 4
VacHoursEarned = 80
Case 5 To 9
VacHoursEarned = 96
Case 10 To 14
VacHoursEarned = 120
Case 15 To 19
VacHoursEarned = 128
Case 20 To 24
VacHoursEarned = 136
Case 25 To 29
VacHoursEarned = 144
Case 30 To 34
VacHoursEarned = 152
Case Is >= 35
VacHoursEarned = 160
Case Else
VacHoursEarned = Null
End Select
End Function