Watch 'On Error GoTo' location?

Futures_Bright

Registered User.
Local time
Today, 09:48
Joined
Feb 4, 2013
Messages
69
Hi all,

Is there a way to add a Watch for where the code will jump to On Error?


Kind regards,

Michael
 
Michael, It will jump to the label which you have asked it to GoTo..

What do you mean by 'add a watch'?
 
Michael, Do you mean having something in the Watches window tell what label the On Error is currently set to?
 
Michael, Do you mean having something in the Watches window tell what label the On Error is currently set to?

Yes I do,

Basically I set up a localised On Error event, and was sure it was reset upon finishing that local section but the code didn't seem to behave as I expected it and I want to make sure it went through the correct error-proofing.
 
if you have a error handler in a block of code, and in the code you "sub" out to functions and procedures, the original error handler is still active - and an error in a sub will cause the original error handler to fire.

for this reason, any function or sub that might fail, ought really have it's own error handler, and return gracefully.

in which case the calling code needs to be able to react correctly in the event of an error.
 
Sorry I don't think I was clear when I said localised. Basically for a single If statement within the code I've said 'On Error goto NoEnabled' immediately following the label is a line stating On Error goto [normal error handling procedure].

What has caused me to wonder if this has happened is that my normal error handling procedure has a case for error 438, and since I put this in it fails with the MS Access standard debug message stating error 438.

Is this possibly just that I need to put 'err.Clear' in after the label? I wanted a watch so I could see which label was being called up on error rather than basically guessing.
 
the other issue maybe that error handling is not reentrant. a new error handler cannot be set while the first one is active. so if you use

goto to exit an error handler, you are still running the error handler, and further on error statements are ignored.

you have to RESUME, not GOTO to exit a error handler.

can you post your error handler codes.
 
Sorry I don't think I was clear when I said localised. Basically for a single If statement within the code I've said 'On Error goto NoEnabled' immediately following the label is a line stating On Error goto [normal error handling procedure].

<snip>

Is this possibly just that I need to put 'err.Clear' in after the label? I wanted a watch so I could see which label was being called up on error rather than basically guessing.

This reminds me of tracking down weirdness related to Raising a Custom Error and receiving an "Automation Error" and not my custom message. Look at my example of raising a custom error here:

http://www.access-programmers.co.uk/wiki/index.php/Robust_VBA_Error_Handler

(Yes, I know the Wiki looks sick. I reported it before coming back to post this reply.)
 
the other issue maybe that error handling is not reentrant. a new error handler cannot be set while the first one is active. so if you use

goto to exit an error handler, you are still running the error handler, and further on error statements are ignored.

you have to RESUME, not GOTO to exit a error handler.

can you post your error handler codes.

Thank you, I completely forgot that errors need to resume! This is the problem with learning while doing in-between jobs at work - you forget the little basic bits.

mdlueck I will have a look through your wiki now.

Thanks for your help guys
 

Users who are viewing this thread

Back
Top Bottom