time issue again

B

bob

I did try the suggestion but it is not working the way i want it to here is
what i am looking for in a better example
a truck is pulling product from a vendor he is at the vendor and he time
stamps at 12:23:25 then he is finishes at 13:23:25 that is an hour of time
and there is a 45 mintues of grace time. so they get 15 minutes of pay at a
rate of .3166. we call this delay time
I just want to enter the times and have this calculate the hours, minutes
and seconds between the two times and subtract the grace time and if there is
any time left that it is paid at a specfic pay rate. I hope this explains it
better then last time. Also if it is possible to have several of this and
have it add it up. I think that is can figure that out just have to name i
like delay 1 delay 2 and so on. Then i so need to put this in a form which
might be best as a sub form and just hide all the controls. Thank you for the
help
 
C

Chris O''''Neill

I'm not sure why Alan's suggestion didn't work for you because it looks to me
like exactly what you need. The DateDiff function calculates the time
difference (when you use the "n" interval argument) so all you do is subtract
the "grace period" from that and multiply it by the rate. So, unless I'm not
following you, this should work:

' Assuming the following fields are on a form:
'
' Field Name Data Type What it Contains
'------------------------------------------------------------
' txtStartTime Date/Time the start time
' txtEndTime Date/Time the end time
' txtGraceMinutes Integer the number of "grace" minutes
' txtRate Currency the rate non-grace minutes are paid at
' txtTotalPaid Currency the total paid for non-grace minutes
'
' ********* Start Code *********

Dim currTotalPaid as Currency

currTotalPaid = (DateDiff("n",Me.txtStartTime, Me.txtEndTime) -
Me.txtGraceMinutes) * Me.txtRate

' Only update Me.txtTotalPaid if currTotalPaid is positive
' Otherwise, set Me.txtTotalPaid and Me.txtGraceMinutes to zero

If currTotalPaid > 0 then
Me.txtTotalPaid = currTotalPaid
Else
Me.txtTotalPaid = 0
Me.txtGraceMinutes = 0
End If

' ********* End Code *********

If I'm still not getting it, please provide more info. Hope this helps...

Regards, Chris
 
B

bob

Here is another question? does this have to be in a query or can it just be
typed in the control source in the properties box in the design view of a
form
 
C

Chris O''''Neill

Where you put it depends on how you want to use it. That code I posted could
almost be included as-is in the OnClick event of a command button. (You
would probably want to add some error trapping, such has handling empty
fields.) You could also put it in one of the events for the form (or one of
the controls, depending on when you want it to trigger. For instance, if you
put it in the OnEnter or GotFocus event for the txtTotalPaid field if you
don't it to trigger only when you enter that field or give it focus.

Hope that helps...

Regards, Chris
 
B

bob

You guys are awsome!!!!!!!!!!!!! I went back and used the other sugguestion
and it did work. but of course they is always the little things that we want
it all. the only problem is that it is not showing the seconds on the total
time that is left so that i can pay the driver that penny that is theirs if
it is over 30 second. so he is what i am saying

Driver in 12:00:00pm
Driver Out 13:00:31pm
grace peroid 45mins
Total time 15 mins and 31 second
so that would round up to 16 mins
if that was under 30 second then it would stay at 15 mins

Once again thank you for your time
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top