Do it as functions with some error testing,
Global Const AppErrorNum As Long = 19999
Global ErrorMsg As String
Sub Main()
Const ProcName as String = "Main"
On Error Goto Main_Error
'some code
If Not MyFirstCall Then Err.Raise AppErrorNum
'some more code
If Not MySecondCall Then Err.Raise AppErrorNum
'etc
Main_Exit:
Exit Sub
Main_Error:
If ErrorMsg = "" Then
ErrorMsg = "Error in " & ProcName & vbNewLine & _
"Error: " & Err.Number & ", " & Err.Description
End If
MsgBox ErrorMsg
Resume Main_Exit
End Sub
Public Sub MyFirstCall() As Boolean
Const ProcName as String = "MyFirstCall "
MyFirstCall = True
On Error Goto MyFirstCall_Error
' the real code
MyFirstCall_Exit:
'tidy-up code
Exit Function
MyFirstCall_Error:
MyFirstCall = False
ErrorMsg = "Error in " & ProcName & vbNewLine & _
"Error: " & Err.Number & ", " & Err.Description
Resume MyFirstCall_Exit
Exit Function
Public Sub MySecondCall() As Boolean
Const ProcName as String = "MySecondCall"
MySecondCall = True
On Error Goto MySecondCall_Error
' the real code, including
If Not MyThirdCall Then Err.Raise AppErrorNum
MySecondCall_Exit:
'tidy-up code
Exit Function
MySecondCall_Error:
MySecondCall = False
ErrorMsg = "Error in " & ProcName & vbNewLine & _
"Error: " & Err.Number & ", " & Err.Description
Resume MySecondCall_Exit
Exit Function
Public Sub MyThirdCall() As Boolean
Const ProcName as String = "MyThirdCall"
MyThirdCall = True
On Error Goto MyThirdCall_Error
' the real code
MyThirdCall_Exit:
'tidy-up code
Exit Function
MyThirdCall_Error:
MyThirdCall= False
ErrorMsg = "Error in " & ProcName & vbNewLine & _
"Error: " & Err.Number & ", " & Err.Description
Resume MyThirdCall_Exit
Exit Function
--
__________________________________
HTH
Bob
"(e-mail address removed)"