Almost there on time buttons again

D

DaveB

I tried to use this and after I copy and pasted it into
my document the lettering turned red. When I try to use
it I get an error message "Compile error: Syntax error.
I'm trying to get a button to calculate the sum of two

Command 92 is at 7:22pm
and Command93 is at 9:35pm but it shows in
TotalTimetoBill 2:00 instead of 2:08.
...
Private Sub Command94_Click()
Me.TotalTimetoBill = DateDiff("h", Me!StartDateTime, Me!
CompletionDateTime)
End Sub

It's showing integer hours because that's what you're
asking for: the
"h" argument to DateDiff calculates integer hours.

If you want integer minutes, use "n" (for miNutes - "m"
is Months).
You can cast this into hh:nn format using an expression
like


DateDiff("h", Me!StartDateTime, Me!CompletionDateTime) &
Format(DateDiff("n", Me!StartDateTime, Me!
CompletionDateTime) MOD 60,
":00")
 
J

John Vinson

I tried to use this and after I copy and pasted it into
my document the lettering turned red. When I try to use
it I get an error message "Compile error: Syntax error.
I'm trying to get a button to calculate the sum of two

Fix the line wrap. The function call should all be on one line (and,
of course, it should use your own fieldnames, not my guesses). Also
there should be no space between the ! characters and the form/control
names.
 

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

Similar Threads


Top