TimeOut minus TimeIn

ScrmingWhisprs

I <3 Coffee Milk.
Local time
Yesterday, 20:24
Joined
Jun 29, 2006
Messages
156
I have a datasheet subform that is acting like a timesheet. I have a TimeIn field and TimeOut field (both fields formatted as Medium Time); and a field for Hours to total the time. I used the expression =HoursAndMinutes([TimeOut]-[TimeIn]) that I found in another post, and it didn't work. All I got was #Name. Any thoughts as to why that's happening? I would preferably like the hours to total in tenths of hours, ie. 10.5.

Thanks
ScrmingWhisprs
 
You realize that HoursAndMinutes is not a native Access function, so you would have to add that to your db?
 
Use DateDiff()
Code:
DateDiff("n", [TimeIn], [TimeOut])/60
You need to determine the difference in minutes as DateDiff returns a LONG value. Just divite that by 60 to get the difference in hours.

If you wanted to, you go even determine the difference in seconds and convert that to hours but that is probably not worth the effort since you aren't looking for that level of precision.
 
Last edited:
Okay, I see.

That works great now. The unbound textbox ("Hours") has the control source of =DateDiff("n",[TimeIn],[TimeOut])/60. I set the Format of that field to Fixed, with 1 Decimal Place. That's all good, it shows me tenths of hours. Now I need to sum the hours fields in the footer of the subform so I can pull that value into another unbound textbox on the Mainform, which has a control source of =frmTransactionsSub.Form!TotalHours. What I'm getting is #Error.

I've determined that it's not a problem with the textbox on the mainform, but the textbox in the footer of the subform. I have its control source as =Sum([Hours]).

What am I doing wrong?

ScrmingWhisprs
 

Users who are viewing this thread

Back
Top Bottom