473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

Jun 27 '08 #1
3 2536
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/For...ccess/200804/1

Jun 27 '08 #2
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
Jun 27 '08 #3
"ragtopcaddy via AccessMonster.com" <u9289@uwewrote 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 **
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
8
by: Eric Osman | last post by:
My javascript program has reason to want to stop. For example, function A has 5 lines, the second of which calls function B, which has 5 lines, the first of which calls function C. But...
59
by: kk_oop | last post by:
Hi. I wanted to use exceptions to handle error conditions in my code. I think doing that is useful, as it helps to separate "go" paths from error paths. However, a coding guideline has been...
6
by: Philipp Schmid [MSFT] | last post by:
I am trying to add a Generic Handler (ASHX) to my web site solution. In order to do that I have to specifiy an assembly name in the web.config file. But since 2.0 web sites are no longer...
10
by: robert d via AccessMonster.com | last post by:
I have a global error handler that up until today has been working flawlessly. Let me first provide the relevant code **************************************************************** On Error...
2
by: Jukka Aho | last post by:
When converting Unicode strings to legacy character encodings, it is possible to register a custom error handler that will catch and process all code points that do not have a direct equivalent in...
5
by: David Thielen | last post by:
Hi; I am writing the output of a page directly using IHttpHandler, IRequireSessionState and if it is a text file I set HttpContext.Response.ContentType = "text/plain". But when it displays I get...
6
by: =?Utf-8?B?cHJhZGVlcF9UUA==?= | last post by:
I am trying to create a simple HTTP handler in ASP.net 2.0. I am using VS 2005. I am trying to handle a custom extension file givein in the URL. I have also created the following entry in the...
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.