patrickdrd
Programmer
Hello everyone!
I need a way to "clone" (copy) the error object in order to prevent it from the code that's inside the error handler, i.e. so that it isn't reset,
if the code inside, has routines that have error handling themselves.
For example, consider the following code:
I would like the msgbox to contain err.number 999, not 1000!
I have in mind that it could be done using variables,
storing original err.number, err.description, etc.
and then showing them, but I'm looking for a more efficient way.
Is there one?
I do not want to fill my code with all these variables for error handling.
I cannot use set a = err,
because a would be only an instance of err,
when err is reset, a is reset as well.
I wish err had a clone method (like recordsets)!
Thanks in advance!
I need a way to "clone" (copy) the error object in order to prevent it from the code that's inside the error handler, i.e. so that it isn't reset,
if the code inside, has routines that have error handling themselves.
For example, consider the following code:
Code:
Option Explicit
Private Sub Form_Load()
On Error GoTo Form_Load_Error
Err.Raise 999
Exit Sub
Form_Load_Error:
' "clone" it somehow here, before test1, which resets it
test1
If InStr(Err.Source, " of ") = 0 Then Err.Source = "Form_Load of Form Form1"
MsgBox CStr(Err.Number) & "~" & Err.Description
End Sub
Private Sub test1()
On Error GoTo test1_Error
Err.Raise 1000
Exit Sub
test1_Error:
End Sub
I would like the msgbox to contain err.number 999, not 1000!
I have in mind that it could be done using variables,
storing original err.number, err.description, etc.
and then showing them, but I'm looking for a more efficient way.
Is there one?
I do not want to fill my code with all these variables for error handling.
I cannot use set a = err,
because a would be only an instance of err,
when err is reset, a is reset as well.
I wish err had a clone method (like recordsets)!
Thanks in advance!