If you have a form with the record source set to your table of times, you
could add a textbox to display your total hours, and in the afterupdate of
the form:
Private Sub Form_AfterUpdate()
SumofHrs
End Sub
which calls the sub:
Sub SumofHrs()
Dim myArray(2) 'array to hold hours and minutes
Dim pos As Integer 'need position of ":" for hrs -could be 1 digit or 2
Dim hrs As Integer
Dim mins As Integer
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
On Error GoTo ErrorHandler
Set dbs = CurrentDb
strSQL = "SELECT tableofFlyingtime.YourTimeRecorded FROM
tableofFlyingtime"
Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)
'I called the table "tableofFlyingTime", timefield in the table
"YourTimeRecorded"
'If the recordset is empty, exit.
If rst.EOF Then Exit Sub
With rst
Do Until .EOF
pos = InStr(1, !YourTimeRecorded, ":", 1)
myArray(1) = CInt(Left(![YourTimeRecorded], pos - 1))
myArray(2) = CInt(Mid(![YourTimeRecorded], pos + 1, 2))
hrs = hrs + myArray(1)
mins = mins + myArray(2)
.MoveNext
Loop
End With
hrs = hrs + Int(mins / 60)
mins = mins Mod 60
Me.txtsum = hrs & "hrs and " & mins & "minutes." 'textbox to display
total
rst.Close
dbs.Close
Set rst = Nothing
Set dbs = Nothing
Exit Sub
ErrorHandler:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub
HTH
Damon