Limiting the scope of On Error

  • Thread starter Thread starter Android
  • Start date Start date
A

Android

I would like to apply On Error error checking within a specific procedure
only.

If I do, something like....

Sub Test()

On Error Goto ErrorHandler
- code -
- code -

ErrorHandler:
msgbox "dddd"
End Sub

Will On Error still be active after this procedure finishes? If so, is
there a way to switch off On Error? I want to handle the error in this
routine, but I want the application to stop and show the error everywhere
else.

Regards,

Android.
 
On Error will still be active if you call another procedure, but when the
code terminates, it dies. Any further code run afterwards will return to the
default error handling.

You can return error handling to the default with

On Error Goto 0

If you want to ignore errors (sic!), or trap them individually, use

On Error Resume Next

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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

Back
Top