Using a Botton to calculate time

D

DaveB

I've asked this question 3 times now, and although I get
a different way to do it each time nothing has worked yet.
I'm using the
I am trying to make a button that will take a field
with
These are my buttons so far down below. The last one is
the one I'm having trouble with. I want it to show in
hours and minutes. The formula there now only
shows "Compile error: Argument not optional. Another one
that I tried only show 1.0 for the day I assume, since it
had only been a few minutes between the time that I tried
it. I need to to show hours and minutes.

Private Sub Command113_Click()
Me!DateTime1stContact = now()
End Sub
Private Sub Command114_Click()
StartDateTime = Date + Time()
End Sub
Private Sub Command115_Click()
Me!CompletionDateTime = now()
End Sub

Private Sub Command117_Click()
Me.TotalTimeOfBill = DateDiff("h", Me!StartDateTime - Me!
CompletionsDateTime)
End Sub
 
R

Randy Harris

DaveB said:
I've asked this question 3 times now, and although I get
a different way to do it each time nothing has worked yet.
I'm using the
I am trying to make a button that will take a field
with

These are my buttons so far down below. The last one is
the one I'm having trouble with. I want it to show in
hours and minutes. The formula there now only
shows "Compile error: Argument not optional. Another one
that I tried only show 1.0 for the day I assume, since it
had only been a few minutes between the time that I tried
it. I need to to show hours and minutes.

Private Sub Command113_Click()
Me!DateTime1stContact = now()
End Sub
Private Sub Command114_Click()
StartDateTime = Date + Time()
End Sub
Private Sub Command115_Click()
Me!CompletionDateTime = now()
End Sub

Private Sub Command117_Click()
Me.TotalTimeOfBill = DateDiff("h", Me!StartDateTime - Me!
CompletionsDateTime)
End Sub

Perhaps the problem is that in one place you've got Me!CompletionDateTime
and in the other you have Me!CompletionsDateTime.
 
J

John Vinson

Private Sub Command117_Click()
Me.TotalTimeOfBill = DateDiff("h", Me!StartDateTime - Me!
CompletionsDateTime)
End Sub

That should be

DateDiff("h", Me!StartDateTime, Me!CompletionsDateTime)

You're SUBTRACTING the two dates, and passing DateDiff two arguments -
"H" and that rather cryptic number. DateDiff needs THREE arguments not
two.
 

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