Results 1 to 2 of 2

Thread: On Error (2003)

  1. #1
    3 Star Lounger
    Join Date
    Sep 2001
    Stuck at work..., Missouri, USA
    Thanked 0 Times in 0 Posts

    On Error (2003)

    I have some code that is guaranteed to generate one error and possibly two.

    For the first, I use <pre>On Error GoTo <my label></pre>

    For the second I've tried <pre>On Error GoTo <my other label></pre>

    After the first error, it goes to the first label, but when the next error gets thrown, I get an error message instead of it moving to the second label.

    Is it possible to have multiple On Error GoTo statements?
    <font face="Comic Sans MS">Morgan Erickson</font face=comic>
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: On Error (2003)

    You can use different On Error GoTo statements, but you must take care to end each error handling section (the part starting with the label you jump to) with either Exit Sub or with one of the Resume statements (Resume, Resume Next or Resume <label>).
    Another option is to let one error handler handle all errors:

    Sub MyProc()
    On Error GoTo ErrHandler
    Exit Sub

    Select Case Err
    Case ...
    Case ...
    Case Else
    End Select
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts