
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?