Stephen:
Copy all the code below to a new module.
It contains some functions and subprocedures you can
call before and after running your query.
I'm assuming you can run your query from code and make
the appropriate calls to the following module before
and after running your query.
Option Explicit
' The timeGetTime function returns the number of milliseconds
' that have elapsed since since the current Windows session
' started. The timeGetTime function is fast, accurate and
' doesn't "roll over". Therefore, the function is suitable
' for measuring elapsed times. The timeGetTime function
' is in the Windows system file "winmm.dll", hence the
' following declaration, which allows VBA to access the
' function:
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private mlngStartTime As Long
Public Function GetElapsedTime(fStart As Boolean) As Long
' This function can be called by another procedure to get
' the time when that procedure started and stopped,
' thus providing the elapsed time, ie the time it took
' for the other procedure to run.
Static lngStartMillisecond As Long
If fStart Then
lngStartMillisecond = timeGetTime()
Else
GetElapsedTime = timeGetTime() - lngStartMillisecond
End If
End Function
' ALTERNATIVE METHOD:
Public Sub StartTimer()
mlngStartTime = 0
' Start timer storing value in global lngStartTime:
mlngStartTime = timeGetTime()
End Sub
Public Function StopTimer() As Long
' Stop timer and return elapsed time in milliseconds:
StopTimer = timeGetTime() - mlngStartTime
End Function
' WAIT:
Public Sub WaitAWhile(lngMillisecondsToWait As Long)
Dim lngStart As Long
Dim lngEnd As Long
lngStart = timeGetTime()
lngEnd = lngStart
Do Until Abs(lngEnd - lngStart) > Abs(lngMillisecondsToWait)
DoEvents
lngEnd = timeGetTime()
Loop
End Sub
Regards
Geoff
message
news:
[email protected]...