Display amount of time (minutes) for a macro to run... (MS Access 2013)

kyleno

Board Regular
Joined
Jun 9, 2014
Messages
61
How would one insert an action into a Macro in Design View to calculate the amount of time (in minutes) that it took for a macro to run (in MS Access 2013)? Please and thank you.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
In the example below the function "Timer" is used. Timer is the number of seconds past midnight. You have to store the value of Timer at the beginning of your macro and then compare that value to Timer again at the end of your macro.




Code:
Sub ShowTimer()
  Dim T As Single
  
  T = Timer
  
  'Run some code
  Do While Timer - T < 3
  
  Loop
  
  Debug.Print Format(Timer - T, "#.0##")
  'OR
  MsgBox "Your macro took " & Format(Timer - T, "#.0##") & " seconds to run"
  
  
End Sub
 
Upvote 0
Would I insert this into a module and then add it to the beginning and end of the macro? Sorry, I don't use code much with Access.

In the example below the function "Timer" is used. Timer is the number of seconds past midnight. You have to store the value of Timer at the beginning of your macro and then compare that value to Timer again at the end of your macro.



Code:
Sub ShowTimer()
  Dim T As Single
  
  T = Timer
  
  'Run some code
  Do While Timer - T < 3
  
  Loop
  
  Debug.Print Format(Timer - T, "#.0##")
  'OR
  MsgBox "Your macro took " & Format(Timer - T, "#.0##") & " seconds to run"
  
  
End Sub
 
Upvote 0
This was example code. You need to add a variable such as T using the DIM. Then add the line T = Timer. The last two statements I added at the end were examples of how to see the result of how much time it took. Ignore the part where I use the DO loop.

This is you adding the individual lines in the example into your code.

Jeff
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top