J
joseph.johnson4
I am trying to calculate the number of hours worked utilizing the "TimeIn"
and "TimeOut" fileds on a subform that will calculate the total number of
hours per week. The expression that I am utilizing is:
=HoursAndMinutes([TimeOut]-[TimeIn])
I have also created an HoursandMinutes which is:
ublic Function HoursAndMinutes(interval As Variant) As String
'***********************************************************************
' Function HoursAndMinutes(interval As Variant) As String
' Returns time interval formatted as a hours:minutes string
'***********************************************************************
Dim totalminutes As Long, totalseconds As Long
Dim hours As Long, minutes As Long, seconds As Long
If IsNull(interval) = True Then Exit Function
hours = Int(CSng(interval * 24))
totalminutes = Int(CSng(interval * 1440)) ' 1440 = 24 hrs * 60 mins
minutes = totalminutes Mod 60
totalseconds = Int(CSng(interval * 86400)) ' 86400 = 1440 * 60 secs
seconds = totalseconds Mod 60
If seconds > 30 Then minutes = minutes + 1 ' round up the minutes and
If minutes > 59 Then hours = hours + 1: minutes = 0 ' adjust hours
HoursAndMinutes = hours & ":" & Format(minutes, "00")
End Function
The error I keep coming up with is #Name?
I need the form to do three things:
1) Calculate the total hours worked each day
2) Then calculate a summed total of the hours worked per week
3) Lastly, keep a running total of the hours each employee works as long as
they are employed.
I could really use some assistance and help from those that have more
experience with Access 2007 than I do.
Thanks, Joe
and "TimeOut" fileds on a subform that will calculate the total number of
hours per week. The expression that I am utilizing is:
=HoursAndMinutes([TimeOut]-[TimeIn])
I have also created an HoursandMinutes which is:
ublic Function HoursAndMinutes(interval As Variant) As String
'***********************************************************************
' Function HoursAndMinutes(interval As Variant) As String
' Returns time interval formatted as a hours:minutes string
'***********************************************************************
Dim totalminutes As Long, totalseconds As Long
Dim hours As Long, minutes As Long, seconds As Long
If IsNull(interval) = True Then Exit Function
hours = Int(CSng(interval * 24))
totalminutes = Int(CSng(interval * 1440)) ' 1440 = 24 hrs * 60 mins
minutes = totalminutes Mod 60
totalseconds = Int(CSng(interval * 86400)) ' 86400 = 1440 * 60 secs
seconds = totalseconds Mod 60
If seconds > 30 Then minutes = minutes + 1 ' round up the minutes and
If minutes > 59 Then hours = hours + 1: minutes = 0 ' adjust hours
HoursAndMinutes = hours & ":" & Format(minutes, "00")
End Function
The error I keep coming up with is #Name?
I need the form to do three things:
1) Calculate the total hours worked each day
2) Then calculate a summed total of the hours worked per week
3) Lastly, keep a running total of the hours each employee works as long as
they are employed.
I could really use some assistance and help from those that have more
experience with Access 2007 than I do.
Thanks, Joe