Jethro: On Error GoTo 0 turns off error chacking in a sub or function:
Phobic: Change Sub2 to a function (which I have called FunctionWithError) and do something like the following:Code:Option Explicit Private Sub Form_Load() Sub1 End Sub Public Function FunctionWithError() As Long On Error Resume Next ' Code that causes an error Dim x As Integer x = 6 / 0 FunctionWithError = Err.Number End Function Public Sub Sub1() On Error GoTo ErrorRoutine Err.Raise FunctionWithError Exit Sub ErrorRoutine: If Err.Number <> 0 Then MsgBox "FunctionWithError returned err number " & Err.Number End If End Sub




Reply With Quote