Exit sub

K

Karen H

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
 
G

Gottfried Lesigang

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top