Error handling outside class modules 
Author Message
 Error handling outside class modules

(VBA, Office 97)
I want my class modules to raise their own errors and handle these errors in
errorhandlers in the calling subroutines.

To get this to work, I need to make sure that the code runs in 'Break on
Unhandled Errors'-mode, NOT 'Break in Class Module' or 'Break on All Errors'
(as this makes VBA's messagebox pop up). Or do I? Have I misunderstood?

How is this done?




Sat, 13 Apr 2002 03:00:00 GMT  
 Error handling outside class modules
Bernt, you will need to do a couple of things.

First you need to raise the error from your 'server' which will be sent to
the 'client'.  Here's an example of the code that would be in your class
module:

Err.Raise vbObjectError+123, "CEmployee","Salary must be >=75000"

In development mode, you will need to set your option to "Break on All
Errors" so that the error is sent and handled by the client.

On the client side you would handle it just like any other error:

On Error GoTo myEH

myEH:
    If Err.Number = vbObjectError+123 Then
        MsgBox Err.Description
    Else
        MsgBox "Some other error"
    End If

Please note that the above code is untested as I do not have Excel available
to me at the moment.

Jennifer A. Campion
Microsoft MVP - Excel

Quote:

>(VBA, Office 97)
>I want my class modules to raise their own errors and handle these errors
in
>errorhandlers in the calling subroutines.

>To get this to work, I need to make sure that the code runs in 'Break on
>Unhandled Errors'-mode, NOT 'Break in Class Module' or 'Break on All
Errors'
>(as this makes VBA's messagebox pop up). Or do I? Have I misunderstood?

>How is this done?





Sat, 13 Apr 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Error Handling Across Class Module Boundaries

2. Error Handling Across Class Module Boundaries (Ooops Fix)

3. Error handling in class modules - need help

4. DLL/Class Module Error Handling Advice Needed

5. Calling a Function in an MS Access Class/Form/Module from an outside application

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

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

8. Call module functions from outside of module?

9. Handling CommandButton Click Events in Class Module

10. handle a excel/word instance in a class module

11. handle a excel/word instance in a class module

12. Error Handling Module

 

 
Powered by phpBB® Forum Software