Display counter in min:seconds

  • Thread starter Thread starter Joe M.
  • Start date Start date
J

Joe M.

I want to show the elapsed time in min:seconds on a form to measure the
performance of a query/report after the cmdbutton is clicked. I've tried some
things but no success. Can anyone help?

Thanks,
Joe M.
 
Joe M. said:
I want to show the elapsed time in min:seconds on a form to measure the
performance of a query/report after the cmdbutton is clicked. I've tried
some
things but no success. Can anyone help?

Thanks,
Joe M.

Generally, I use code like:


dim myTimer as single



myTimer = timer

code goes here...


myTimer = timer - myTimer

msgbox "elapsed time = " & myTimer

You can also stuff the value into a text box on a form if that need be such
as:

me.txtShowTime = myTimer
 
I want to show the elapsed time in min:seconds on a form to measure the
performance of a query/report after the cmdbutton is clicked. I've tried some
things but no success. Can anyone help?

Thanks,
Joe M.

Elapsed time from the command button to... what? What's the second time point?

You can set a variant variable to Now() in the button's click event, and in
whatever other event you're trying to trap; and use DateDiff to determine the
elapsed time in seconds:

Dim iHowLong As Integer
iHowLong = DateDiff("s", vStartTime, vEndTime)

Then you can display the integer seconds as minutes:seconds with an expression
like

iHowLong \ 60 & ":" & Format(iHowLong MOD 60, "00")
 
Back
Top