Exit sub

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hiya

I have an error handler on a sub which ends in 'exit sub'

However, this sub is referenced from a higher level routine and it seems that 'exit sub' simply ends the current procedure and the higher procedure continues

Do you know the simplest way in which I can stop all the procedures from inside the lower level routine

Thanks

Karen
 
Hi Karen!

This is the normal behaviour: Exit Sub just returns to the calling line
above.

I don't know wheter I got you right but I think raising an userdefined error
and placing an error-handler in EVERY Sub above could solve your problem.
Every Sub tests

If Err.Number=MyErrNumber Then Err.Raise MyErrNumber, [...]

Your error is passed from one to the next almost without time. You even
could raise different errors (or "Source" or "Description") to feed
information back on the reason of returning.

Have a look on vbObjectError!

In fact - it is not very pretty but very effective - some programmers use
this method to close down e.g. deep recursions.

HTH
Gottfried
 
Back
Top