Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fun with math and time values 1

Status
Not open for further replies.

murpl

Technical User
Mar 1, 2001
32
CA
Maybe I'm overcomplicating things for myself but I need to do some simple math and it's not turning out to be too simple!
I have a form that a technician can enter the start time and the end time spent on a particular job so we know how much time to invoice the customer. TimeOut - TimeIn should equal TotalTime, right? Right. I'm using Double type instead of Date/Time but am having a heck of a time getting my head around how to code the expression to allow for the 24 hour and base 60 as well as how to handle time that spans from AM - PM.
I'm new to Access and VB so please bear with me. You don't have to type slow or anything but forgive me if my newbieness shows. :eek:)

Thanks, Mike
 
Hi Mike,
Change to date/time fields for your time entries. Then check out thread 118-61005. When you've finished laughing (it was all just in fun you know), scope out some of the functions offered there. Happy to help! Gord
ghubbell@total.net
 
Er, how do I find that thread?

Mike
 
Sorry, I should have been more specific: It's about to fall off of page 2 to page 3 in general discussions: user jamesf4218 "How do sum together the results of calculated fields please?" Gord
ghubbell@total.net
 
ROFL!
Okay, found it. What's even funnier is I already considered datediff (browsed it in VB help) and dismissed it as being not what I wanted. <VBG>

::heh heh:: Okay, thanks, Gord. 'preciate it!

Mike
 
thread118-61005
MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
There we go. Thanks, MichaelRed.
Okay guys, I used a variation on BlackKnights suggestion with the public function. I needed the elapsed time returned in hours + minutes as a fraction of hour (ie: 1.5 hrs, 2.75 hrs, etc) so my coding is different and I included some error trapping. I set the control source for the control to
Code:
=CalcTime()
Works great, values returned are correct but one problem:
When the Start-time control and Stop-time control values are entered I see no data (nothing, nada) in the total-time control text box. If I exit the form and re-open it, switch to design view and then back again, or even move two or more records back and then come back THEN it shows me the calculated value. Whatup wit dat?
I've tried using repaint, refresh to no avail. I even tried running a macro using setvalue. How can I get it to display the calculated value as soon as the function is run?
Also, is it possible to write that value to a table as well?

Thanks, Mike
 
Mike,
Afterupdate of either start or stop times, call your function again. Should work..! Gord
ghubbell@total.net
 
You'd think so wouldn't ya. I'll try an afterupdate event from my end time control and see what happens.
Thanks Gord

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top