What would cause an error handler to work only once

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ragtopcaddy via AccessMonster.com

    What would cause an error handler to work only once

    I have an error handler: On Error GoTo Outtahere
    At the end of the routine, the OuttaHere section reads:

    OuttaHere:
    If Err.Number <0 Then
    If Err.Number = 3061 Then
    Debug.Print " Failed to get " & strFileName & " data"
    Err.Clear
    GoTo NextFile 'most likely, the spreadsheet lacks the
    lowUtilizationA NDMemory field
    Else
    MsgBox "Error # " & Err.Number & ", " & Err.Description & ", occurred.
    The function 'GetLowUtilServ ers' will abort.", _
    vbCritical + vbOKOnly, "Failed To Record Dashboard LowUtil
    Data"
    Err.Clear
    End If
    End If

    The error 3061 happens when a field called in a query doesn't exist in the
    spreadsheet. This is expected behavior. I'm looping through a directory full
    of spreadsheets. I'd like to resume the loop at the NextFile section:

    NextFile:
    strFileName = Dir
    Loop
    End If

    --
    Bill Reed

    "If you can't laugh at yourself, laugh at somebody else"

    Message posted via http://www.accessmonster.com

  • ragtopcaddy via AccessMonster.com

    #2
    Re: What would cause an error handler to work only once

    I neglected to mention the main problem which is in the subject line. The
    problem is, the error routine works fine for the 1st workbook that doesn't
    have the field, but fails to trap subsequent errors. It just stops on the
    line:

    Set rs = .OpenRecordset( strSQL)

    and displays the default 3061 error msg.

    --
    Bill Reed

    "If you can't laugh at yourself, laugh at somebody else"

    Message posted via AccessMonster.c om


    Comment

    • Salad

      #3
      Re: What would cause an error handler to work only once

      ragtopcaddy via AccessMonster.c om wrote:
      I have an error handler: On Error GoTo Outtahere
      At the end of the routine, the OuttaHere section reads:
      >
      OuttaHere:
      If Err.Number <0 Then
      If Err.Number = 3061 Then
      Debug.Print " Failed to get " & strFileName & " data"
      Err.Clear
      GoTo NextFile 'most likely, the spreadsheet lacks the
      lowUtilizationA NDMemory field
      Else
      MsgBox "Error # " & Err.Number & ", " & Err.Description & ", occurred.
      The function 'GetLowUtilServ ers' will abort.", _
      vbCritical + vbOKOnly, "Failed To Record Dashboard LowUtil
      Data"
      Err.Clear
      End If
      End If
      >
      The error 3061 happens when a field called in a query doesn't exist in the
      spreadsheet. This is expected behavior. I'm looping through a directory full
      of spreadsheets. I'd like to resume the loop at the NextFile section:
      >
      NextFile:
      strFileName = Dir
      Loop
      End If
      >
      Maybe try another attack tact.
      On Error Goto 0 'stop error trapping
      On Error Resume Next
      ...execute a statement that gets an error
      If Err.Number = 0 then
      ...process
      Else
      ...error trapping
      Endif

      LieToMe

      Comment

      • Bob Quintal

        #4
        Re: What would cause an error handler to work only once

        "ragtopcadd y via AccessMonster.c om" <u9289@uwewro te in
        news:82ae899029 286@uwe:
        I have an error handler: On Error GoTo Outtahere
        At the end of the routine, the OuttaHere section reads:
        >
        OuttaHere:
        If Err.Number <0 Then
        If Err.Number = 3061 Then
        Debug.Print " Failed to get " & strFileName & " data"
        Err.Clear
        GoTo NextFile 'most likely, the spreadsheet lacks the
        lowUtilizationA NDMemory field
        Else
        MsgBox "Error # " & Err.Number & ", " & Err.Description &
        ", occurred.
        The function 'GetLowUtilServ ers' will abort.", _
        vbCritical + vbOKOnly, "Failed To Record Dashboard
        LowUtil
        Data"
        Err.Clear
        End If
        End If
        >
        The error 3061 happens when a field called in a query doesn't
        exist in the spreadsheet. This is expected behavior. I'm looping
        through a directory full of spreadsheets. I'd like to resume the
        loop at the NextFile section:
        >
        NextFile:
        strFileName = Dir
        Loop
        End If
        >
        Try replacing the statement GoTo NextFile with Resume NextFile.


        --
        Bob Quintal

        PA is y I've altered my email address.
        ** Posted from http://www.teranews.com **

        Comment

        Working...