Counting multiples of hours

This solution by cyanidem works perfectly, thank you all for your help :D

I agree with Minty, function will work better in this case.
Put this in standard module:
Code:
Public Function GivePoints(sJobType As String, nHours As Integer) As Long
Dim vPoints As Long
    Select Case sJobType
        Case "job_a"
            Select Case nHours
                Case 1 To 3
                    vPoints = 1
                Case 4 To 6
                    vPoints = 2
                Case 7 To 9
                    vPoints = 3
                Case Else
                    vPoints = 999
            End Select
        Case "job_b"
            Select Case nHours
                Case 1 To 5
                    vPoints = 1
                Case 6 To 10
                    vPoints = 2
                Case 11 To 15
                    vPoints = 3
                Case Else
                    vPoints = 999
            End Select
        Case Else
            Select Case nHours
                Case 1 To 2
                    vPoints = 1
                Case 3 To 4
                    vPoints = 2
                Case 5 To 5
                    vPoints = 3
                Case Else
                    vPoints = 999
            End Select
    End Select
    GivePoints = vPoints
End Function

And then you can just call it from your sub like:
Code:
me.Points=GivePoints(me.Job_Type, me.NumberOfHours)
or whatever suits your design.
 

Users who are viewing this thread

Back
Top Bottom