Display macro running time in Form

Display macro running time in Form

Post by MarkusJoh » Fri, 05 Oct 2007 17:27:28


Hello Friends,

I have a quite massive access DB where I have to run daily queries on.
To execute a qeuery I have created a form with buttons.
Each button runs a private Sub Functions with several
"DoCmd.OpenQuery" statements.

In this form I want to have a text field or label, that shows the
elapsedf time from begin to end of the sub function.

How can I implement this??

Thanks for a hint;-)
Markus
 
 
 

Display macro running time in Form

Post by Steve Scha » Sat, 06 Oct 2007 14:20:23

Markus,

If you have "private Sub Functions" and "DoCmd.OpenQuery statements",
then you are talking about VBA procedures, which in Access are quite
different from macros.

You could use code like this:

Dim StartTime As Date
Dim EndTime As Date
Dim ElapsedTime As Integer

StartTime = Now
...
<your OpenQuery thingies etc>
...
EndTime = Now
ElapsedTime = DateDiff("s",StartTime,EndTime)
Me.YourLabel.Caption = ElapsedTime & " seconds"

This only shows the time in whole seconds. Not sure if that's what you
were looking for.

--
Steve Schapel, Microsoft Access MVP