View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tod Tod is offline
external usenet poster
 
Posts: 13
Default Proper way to pass errors up the line

Whenever I post these questions I wonder what it's going
to look like to a Google user five years from now. So:

"Hello from the past!"

Now here is my VBA newbie question o' the day:

How do I pass a raised error back to the procedure that
called?

Example (Don't laugh):

Sub FirstProc()
'Code Code Code
On Error Resume Next
Call Second
If Err.Number = vbObjectError + 513 Then
msgbox "This error came from SecondProc"
End if
'Code Code Code
End First

Sub SecondProc()
'Code Code Code
Err.Raise Number:=vbObjectError + 513, Description:="I
raised this error."
End Sub

This is obviously not correct, but hopefully you see what
I'm trying to do. I want SecondProc to pass my error back
to FirstProc and end without causing an error while in
SecondProc. Then when FirstProc gets the error it displays
a message or does something based on the err.number being
my raised error.

If I'm on the right track please show me where it's not
working. If I'm waaaay off please tell me how to do it.

tod