What would cause an error handler to work only once
What would cause an error handler to work only once
am 14.04.2008 22:30:36 von u9289
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
Re: What would cause an error handler to work only once
am 14.04.2008 22:33:16 von u9289
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
Re: What would cause an error handler to work only once
am 14.04.2008 23:12:34 von Salad
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
Re: What would cause an error handler to work only once
am 15.04.2008 00:24:53 von Bob Quintal
"ragtopcaddy via AccessMonster.com" wrote in
news:82ae899029286@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 **