M
markcupito
Hello all,
I am new to MS Access 2003, for the most part. (Disclaimer)
Anyway, I have an "Hours" text box on a form that is programmed as [ServiceHours] .. I need to make the "Hours" do this.. Round(4*[ServiceHours], 0 / 4) to get the hours and to compensate for minutes, only allow quarterly hours. .25, .5, .75 ...
Here's the code that attempts to compensate for that, but it is buggy, and I don't know how to program the above.
Private Sub ServiceHours_AfterUpdate()
On Error GoTo Err_Handler
Dim number, number2
number = Int(Me.[ServiceHours])
number2 = Me.[ServiceHours] - number
Select Case number2
Case 0 To 0.125
Me.[ServiceHours] = Me.[ServiceHours] - number2
Case 0 To 0.365
Me.[ServiceHours] = Me.[ServiceHours] - (number2 - 0.25)
Case 0.366 To 0.625
Me.[ServiceHours] = Me.[ServiceHours] - (number2 - 0.5)
Case 0.626 To 0.885
Me.[ServiceHours] = Me.[ServiceHours] - (number2 - 0.75)
Case 0.896 To 1
Me.[ServiceHours] = Me.[ServiceHours] - (number2 - 1)
' Round(4 * [ServiceHours], 0) / 4
End Select
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox Error$
Resume Exit_Handler
End Sub
I'm not familiar on how to code it so I get the results I want.
Any help + tips would be greatly appreciated.
I am new to MS Access 2003, for the most part. (Disclaimer)
Anyway, I have an "Hours" text box on a form that is programmed as [ServiceHours] .. I need to make the "Hours" do this.. Round(4*[ServiceHours], 0 / 4) to get the hours and to compensate for minutes, only allow quarterly hours. .25, .5, .75 ...
Here's the code that attempts to compensate for that, but it is buggy, and I don't know how to program the above.
Private Sub ServiceHours_AfterUpdate()
On Error GoTo Err_Handler
Dim number, number2
number = Int(Me.[ServiceHours])
number2 = Me.[ServiceHours] - number
Select Case number2
Case 0 To 0.125
Me.[ServiceHours] = Me.[ServiceHours] - number2
Case 0 To 0.365
Me.[ServiceHours] = Me.[ServiceHours] - (number2 - 0.25)
Case 0.366 To 0.625
Me.[ServiceHours] = Me.[ServiceHours] - (number2 - 0.5)
Case 0.626 To 0.885
Me.[ServiceHours] = Me.[ServiceHours] - (number2 - 0.75)
Case 0.896 To 1
Me.[ServiceHours] = Me.[ServiceHours] - (number2 - 1)
' Round(4 * [ServiceHours], 0) / 4
End Select
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox Error$
Resume Exit_Handler
End Sub
I'm not familiar on how to code it so I get the results I want.
Any help + tips would be greatly appreciated.