
Raising Err in Class Module
Hi Jeff,
For reasons which I don't understand, the default for "Error Trapping" under
Tools/Options/Advanced in Access is set to "Break in Class Module", when to
do what you're trying to do, you need it to say "Break on Unhandled Errors".
I generally prefer to use the Class_Terminate and Class_Initialize procs for
setting this option, instead of changing the setting through the UI.
Something like
Private mintErrorTrap As Integer
Private Sub Class_Initialize()
mintErrorTrap = Application.GetOption("Error Trapping")
Call Application.SetOption("Error Trapping", 2)
End Sub
Private Sub Class_Terminate()
On Error Resume Next
Call Application.SetOption("Error Trapping", mintErrorTrap)
End Sub
HTH
--
Dev Ashish (Just my $.001)
---------------
The Access Web ( http://home.att.net/~dashish )
---------------
:I'm having trouble raising an error in a class module. I keep getting an
:automation error when, what I really wanted to do was pass the error back
to
:the original calling function. I *thought* you did something like the
:following (in pseudocode):
:
:Public Property Get MyFunc() as integer
:
: MyFunc = MyOtherFunc
:
: if err.number <> 0 then err.raise err.number
:end Property
:
:Private Function MyOtherFunc
:
:
: err.raise MyCustomErrNumber
:
:end function
:
:The error gets raised from MyOtherFunc but in MyFunc I get the automation
:error (I want to pass it back to the "Click" event from which it was
:called).
:
:Any help which points me in the right direction would be greatly
:appreciated.
:
:Jeff
:
:
: