Question Details

No question body available.

Tags

vba ms-access

Answers (2)

Accepted Answer Available
Accepted Answer
January 12, 2026 Score: 2 Rep: 8,053 Quality: High Completeness: 60%

I suggest we consider an example with this code

Private Sub SubA()
    SubD 'SubB 
    Debug.Print "Err.number=", Err.Number; "Err.Source=", Err.Source
    MsgBox Err.Number
End Sub

Private Sub SubB() On Error Resume Next Err.Raise 1234 Debug.Print "Err.number=", Err.Number; "Err.Source=", Err.Source Exit Sub End Sub

Private Sub SubD() On Error GoTo errhandler Err.Raise 1234 Exit Sub errhandler: Debug.Print "Err.number=", Err.Number; "Err.Source=", Err.Source Exit Sub End Sub

Case when we call SubB we get output

Err.number=    1234 Err.Source=             Database
Err.number=    1234 Err.Source=             Database

With SubD we get

Err.number=    1234 Err.Source=             Database
Err.number=    0 Err.Source= 

In SubD error is "handled". Then, after Exit Sub, error is cleared.

By applying "on error resume next" we leave the error "suppressed" but not "handled".

So Exit Sub, Exit Function, Exit Property clear error after handling, otherwise, error is transferred to a higher level in the call stack, which is logical.

Upd1
Documentation says about clearing err when exit (Sub,Function,Property) sub, where error handled. If Sub not handle error, Exit Sub do not clear error.

In "error handler" part of sub we can read value like "err.number". So, within Sub "err" not cleared implicitly.
And "Exit Sub" implicitly call "err.clear", if we don't clear explicitly before.

If error is "handled", this event do not propagate thru "call stack".

What is "error handling" in this case?
We see that On Error GoTo errhandler and then jump to errhandler is "error handling".
Also, commands like on error resume next, on error goto some_handler ... after error will reset error - clear current error -> handle this error.

January 12, 2026 Score: 2 Rep: 8,963 Quality: Low Completeness: 40%

It looks like the documentation is inconsistent. For the Err object it states the following:

The Err object's properties are reset to zero or zero-length strings ("") after an Exit Sub, Exit Function, Exit Property, or Resume Next statement within an error-handling routine. Using any form of the Resume statement outside of an error-handling routine will not reset the Err object's properties. The Clear method can be used to explicitly reset Err.

This suggests to me the code is behaving correctly.