Hi,
To calculate total time, you need to split the time in hours and minnutes,
sum them separately, then use the function below, who returns you the total
time, as a string, in format HHHH:MM (which you can use on reports)
Suppose you have a field called TimeSpent in table TimeTest
dim nHours as integer, nMinutes as integer
dim rs as DAO.Recordset, db as DAO.Database
set db = currentdb()
set rs = db.openrecordset("select TimeSpent from TimeTest where <<< your
condition >>>")
if rs.recordcount >0
do while not rs.eof
nHours = nHours + Hour(rs![TimeSpent])
nMinutes = nMinutes + Minute(rs![TimeSpent])
rs.movenext
loop
endeif
debug.print "Total time is:", GetTime(nHours, nMinutes)
Public Function GetTime(ByVal nHours As Integer, ByVal nMinutes As Integer)
As String
Dim sResult As String
On Error GoTo GetTime_Error
Dim nMoreHrs As Integer, sHours As String
nMoreHrs = nMinutes / 60
nMinutes = nMinutes Mod 60
nHours = nHours + nMoreHrs
If nHours < 10 Then
sHours = "0" & nHours
Else
sHours = "" & nHours
End If
sResult = sHours & ":" & Right$("0" & nMinutes, 2)
GetTime = sResult
GetTime_Exit:
On Error GoTo 0
Exit Function
GetTime_Error:
MsgBoxLog "Error " & Err.number & " - " & Err.Description & vbCrLf & "In
procedure GetTime"
Resume GetTime_Exit
End Function
HTH,
Bogdan