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
lowUtilizationANDMemory field
Else
MsgBox "Error # " & Err.Number & ", " & Err.Description & ", occurred.
The function 'GetLowUtilServers' 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
u9289 [ Mo, 14 April 2008 22:30 ] [ ID #1942062 ]

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.com
http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-ac cess/200804/1
u9289 [ Mo, 14 April 2008 22:33 ] [ ID #1942063 ]

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

ragtopcaddy via AccessMonster.com 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
> lowUtilizationANDMemory field
> Else
> MsgBox "Error # " & Err.Number & ", " & Err.Description & ", occurred.
> The function 'GetLowUtilServers' 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
http://www.youtube.com/watch?v=QgBD60-UhDg
Salad [ Mo, 14 April 2008 23:12 ] [ ID #1942065 ]

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

"ragtopcaddy via AccessMonster.com" <u9289 [at] uwe> wrote in
news:82ae899029286 [at] 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
> lowUtilizationANDMemory field
> Else
> MsgBox "Error # " & Err.Number & ", " & Err.Description &
> ", occurred.
> The function 'GetLowUtilServers' 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 **
Bob Quintal [ Di, 15 April 2008 00:24 ] [ ID #1942073 ]
Datenbanken » comp.databases.ms-access » What would cause an error handler to work only once

Vorheriges Thema: Funky Save Record Stuff
Nächstes Thema: adding new fields