Returns the number of seconds elapsed since midnight.
Timer
Time Function.
This example uses the Timer function to pause the application. The example also uses DoEvents to yield to other processes during the pause.
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then PauseTime = 5 ' Set duration. Start = Timer ' Set start time. Do While Timer < Start + PauseTime DoEvents ' Yield to other processes. Loop Finish = Timer ' Set end time. TotalTime = Finish - Start ' Calculate total time. MsgBox "Paused for " & TotalTime & " seconds" EndIf
You can use the Timer function to time operations and events in your Microsoft Access application by placing the Timer function immediately before and after the operation in your code that you wish to time. The following example uses the name of a query as its argument, then calculates how long it takes the query to run.
Sub QueryTimer (strQueryName As String) Dim sngStart As Single, sngEnd As Single Dim sngElapsed As Single sngStart = Timer ' Get start time. DoCmd.OpenQuery strQueryName, acNormal ' Run query. sngEnd = Timer ' Get end time. sngElapsed = Format(sngEnd - sngStart, "Fixed") ' Elapsed time. MsgBox ("The query " & strQueryName & " took " & sngElapsed _ & " seconds to run.")Sub