There's usually no need to pass it. It's global, so the function can access
it directly ...
'error handler
report_error
Function report_error
MsgBox "Error " & Err.Number & ": " & Err.Description
End Function
When you do need to store the values, a custom class can be used ...
'In a class module saved as clsSavedError ...
Option Compare Database
Option Explicit
Private mlngErrorNumber As Long
Private mstrErrorDescription As String
Public Property Let ErrorNumber(lngErrorNumber As Long)
mlngErrorNumber = lngErrorNumber
End Property
Public Property Get ErrorNumber() As Long
ErrorNumber = mlngErrorNumber
End Property
Public Property Let ErrorDescription(strErrorDescription As String)
mstrErrorDescription = strErrorDescription
End Property
Public Property Get ErrorDescription() As String
ErrorDescription = mstrErrorDescription
End Property
Private Sub Class_Initialize()
mlngErrorNumber = Err.Number
mstrErrorDescription = Err.Description
End Sub
'In a standard module ...
Option Compare Database
Option Explicit
Public Sub TestSavedError()
Dim SavedError As clsSavedError
On Error GoTo ErrorHandler
Err.Raise 11
ExitProcedure:
Exit Sub
ErrorHandler:
Set SavedError = New clsSavedError
ShowError SavedError
Resume ExitProcedure
End Sub
Public Sub ShowError(SavedError As clsSavedError)
MsgBox "Error " & SavedError.ErrorNumber & ": " &
SavedError.ErrorDescription
End Sub