Raising Err in Class Module 
Author Message
 Raising Err in Class Module

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



Fri, 17 Aug 2001 03:00:00 GMT  
 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
:
:
:



Fri, 17 Aug 2001 03:00:00 GMT  
 Raising Err in Class Module
I forgot about that setting. Thanks for reminding me.

Jeff

Quote:

>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
>:
>:
>:



Sat, 18 Aug 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. err.raise not trappable in class module

2. Problems with Err.Raise in a class module.

3. Err.Raise in OLE Server EXE not raising error in calling program

4. Err.Raise - error not being re-raised all the way to top of the call stack

5. Raising errors from (class module) objects

6. Raising Events (not within a module or class)

7. Class modules 97 - Refering to array within a custom class module

8. Accessing procedures of a class module from another class module

9. Class raising an event from another class?

10. Raising events from a class within a collection class

11. Err.Raise Causes Automation Error

12. Err.Raise Number starting point

 

 
Powered by phpBB® Forum Software