G
Guest
Trying to perfect this a little more...
I've got this code that measures the length (in minutes) of a procedure.
Sub TimeLoop(strFncToCall As String)
On Error GoTo TimeLoop_Err
Dim sngStart As Single
Dim sngEnd As Single
Dim lngLoop As Long
Dim Msg As String
Dim Ans As Integer
sngStart = Timer
Application.Run strFncToCall
sngEnd = Timer
'Creates a message box
Msg = "Process completed successfully!"
Msg = Msg & vbNewLine & vbNewLine
Msg = Msg & "Process Time: " & Format$((sngEnd - sngStart) / 60, "0.0")
& " minutes"
Ans = MsgBox(Msg, vbInformation, "Refresh Status")
TimeLoop_Exit:
DoCmd.SetWarnings True
Exit Function
TimeLoop_Err:
MsgBox Err.Number & ": " & Err.Description, vbCritical, "Error - Time
Loop"
Resume TimeLoop_Exit
End Sub
If I encounter an error in the "called" procedure - that error is reported,
and then the code continues to the MsgBox in TimeLoop. Ideally, if there is
an error in the called procedure, it should report the error and stop. How
do I accomplish this?
I've got this code that measures the length (in minutes) of a procedure.
Sub TimeLoop(strFncToCall As String)
On Error GoTo TimeLoop_Err
Dim sngStart As Single
Dim sngEnd As Single
Dim lngLoop As Long
Dim Msg As String
Dim Ans As Integer
sngStart = Timer
Application.Run strFncToCall
sngEnd = Timer
'Creates a message box
Msg = "Process completed successfully!"
Msg = Msg & vbNewLine & vbNewLine
Msg = Msg & "Process Time: " & Format$((sngEnd - sngStart) / 60, "0.0")
& " minutes"
Ans = MsgBox(Msg, vbInformation, "Refresh Status")
TimeLoop_Exit:
DoCmd.SetWarnings True
Exit Function
TimeLoop_Err:
MsgBox Err.Number & ": " & Err.Description, vbCritical, "Error - Time
Loop"
Resume TimeLoop_Exit
End Sub
If I encounter an error in the "called" procedure - that error is reported,
and then the code continues to the MsgBox in TimeLoop. Ideally, if there is
an error in the called procedure, it should report the error and stop. How
do I accomplish this?