Calculations in code w\ Time Fields (1 Viewer)

Chanda

New member
Local time
Today, 03:32
Joined
Jan 7, 2000
Messages
7
Hello Everyone,
Here is my problem, I need to keep a running total on my form as the user is entering records.
I have two fields [TimeIn] and [TimeOut] in my table w\data type "Date/Time". In the query that is the record source for my form I have a calculated field HoursWorked ([TimeOut]-[TimeIn]) which gives me a decimil number. This is the code that I have in the BeforeUpdate event to have the running total for each person as the user adds them to the schedule.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim db As Database
Dim rst As Recordset
Dim Total As Single
Set db = CurrentDb()
Set rst = db.OpenRecordset("qrySchedule", dbOpenDynaset)
rst.Requery
Do While Not rst.EOF
If rst![EmplyID] = Me.cmbPickEmply Then
Total = Total + rst![HoursWorked]
End If
rst.MoveNext
Loop
Me.TotalHours = Total + Me.HoursWorked
rst.Close
End Sub

I need the TotalHours field to show hours and minutes worked, like 37:28 which would be 37 hours and 28 minutes. Does any one know how to get these decimil results into the format I need? Any help would be greatly appreciated!
Thanks,
Chanda

[This message has been edited by Chanda (edited 07-18-2000).]
 

Users who are viewing this thread

Top Bottom