Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2006

Tip: Looking for answers? Try searching our database.

error routine

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Janis - 19 Sep 2006 23:46 GMT
Thanks for this error handler macro.  I have one question about it.  It is
for a user form.  
Where it says "exit sub" , what is the exit sub for?  The end sub is the end
of the subrouting which it reaches if there is no error, but if there is an
error doesn't it go to the error handler?  so why does it exit the sub?
Thanks,

Private Sub CommandButton1_click()

on Error goto ErrHandler

Code
xxxxxxx

Exit Sub

ErrHandler:
Select Case Err.Number
Case 9
    resume
Case Else
   MsgBox Err.Number & " " & Err.Description
End Select
End Sub
Bob Phillips - 19 Sep 2006 23:59 GMT
So that it doesn't drop into the error handler by defaulter even though
there is no error.

Signature

HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

> Thanks for this error handler macro.  I have one question about it.  It is
> for a user form.
[quoted text clipped - 20 lines]
> End Select
> End Sub
Tom Ogilvy - 20 Sep 2006 00:18 GMT
The exit sub is so it doesn't go through the error handler when there is no
error.

Errhandler:

is just a label that is jumped to if an error occurs - it doesn't mark the
end of the "good" code.  If you don't have the exit sub, the code will
always pass through the error handler.

Signature

Regards,
Tom Ogilvy

> Thanks for this error handler macro.  I have one question about it.  It is
> for a user form.
[quoted text clipped - 22 lines]
> End Select
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.