473,748 Members | 7,217 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error handler problem...

My error handler works GREAT. However, VBA seems to have some
bugs/features that are causing it fits. The little snippet that I put
at the end of each routine looks like this:

Error_Handler:
If Error_Handler(" <routine name>", Err) = acDataErrDispla y Then
On Error GoTo 0

Stop: Resume ' Press [F8] twice to view the problem.

End If

When an error occurs and I decide to debug it, I just indicate this on
the form that pops up, and the Error_Handler routine returns
acDataErrDispla y, which then shuts off error trapping, stops so I can
gain control, I press F8 a couple of times, and I am right on the
statement that causes the problem - or am I!

Pressing F8 again then jumps into the error handling routine for the
routine that called this one. Over and over again I respond to the
same form, once for each routine in the calling list, until eventually
I get to the top. Of course, if the routine does something different
on subsequent calls, then I am in REAL trouble trying to debug complex
problems.

The fundamental problem seems to be that Resume has TWO different
functions that really need individual control:

1. It gets you back to where the problem is.
2. It re-enables higher-level error trapping.

What would seem to be needed is some way to turn higher level error
trapping off, but that doesn't seem to be possible. Failing that, some
sort of magic is needed to work around this.

So far, the only semi-workable idea seems to be to bracket all calls,
function references, etc., with lines to disable and enable the error
handler, like:

On Error GoTo 0
Call something
On Error Goto Error_Handler

Of course, many function references are in complex statements that may
fail for reasons quite aside from problems in the included function,
so doing this would leave some errors un-handled and really make a
mess of programs.

Of course, I could just trap only in event handling routines that are
always at the top of the call stack, but then I must re-execute a LOT
of code to get back to the error, that may work quite differently the
second time around.

Any ideas, thoughts, suggestions, etc?

Steve Richfield
Nov 13 '05 #1
2 2381
Hi Steve. It will be interesting to see what everyone else does.

Personally, I use MZTools (from www.mztoools.com) to drop the error handler
into each new routine with the click of a toolbar button. You can configure
your own error handler, so mine is configured to add:
'On Error Goto Err_Hander
i.e. it is commented out. During development the lines all fail at the point
where they happen. Before release, we do a global search for:
'On Error
and replace with:
On Error
so they are all activated.

Other useful techniques:
- breaking out anything that is likely to error into its own little wrapper
function;
- calling a global error handler that can just ignore things like error
2501.
- logging the errors, because users can never tell you what happened.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Steve Richfield" <go****@smart-life.net> wrote in message
news:78******** *************** ***@posting.goo gle.com...
My error handler works GREAT. However, VBA seems to have some
bugs/features that are causing it fits. The little snippet that I put
at the end of each routine looks like this:

Error_Handler:
If Error_Handler(" <routine name>", Err) = acDataErrDispla y Then
On Error GoTo 0

Stop: Resume ' Press [F8] twice to view the problem.

End If

When an error occurs and I decide to debug it, I just indicate this on
the form that pops up, and the Error_Handler routine returns
acDataErrDispla y, which then shuts off error trapping, stops so I can
gain control, I press F8 a couple of times, and I am right on the
statement that causes the problem - or am I!

Pressing F8 again then jumps into the error handling routine for the
routine that called this one. Over and over again I respond to the
same form, once for each routine in the calling list, until eventually
I get to the top. Of course, if the routine does something different
on subsequent calls, then I am in REAL trouble trying to debug complex
problems.

The fundamental problem seems to be that Resume has TWO different
functions that really need individual control:

1. It gets you back to where the problem is.
2. It re-enables higher-level error trapping.

What would seem to be needed is some way to turn higher level error
trapping off, but that doesn't seem to be possible. Failing that, some
sort of magic is needed to work around this.

So far, the only semi-workable idea seems to be to bracket all calls,
function references, etc., with lines to disable and enable the error
handler, like:

On Error GoTo 0
Call something
On Error Goto Error_Handler

Of course, many function references are in complex statements that may
fail for reasons quite aside from problems in the included function,
so doing this would leave some errors un-handled and really make a
mess of programs.

Of course, I could just trap only in event handling routines that are
always at the top of the call stack, but then I must re-execute a LOT
of code to get back to the error, that may work quite differently the
second time around.

Any ideas, thoughts, suggestions, etc?

Steve Richfield

Nov 13 '05 #2
Regarding the following posting on DevelopersDex, I am replying from
USENET so the whole world can read this, rather than just DevelopersDex
subscribers.

Re: Error handler problem...
From: Allen Browne
Date Posted: 11/10/2004 7:53:00 PM

Hi Steve. It will be interesting to see what everyone else does.

Personally, I use MZTools (from www.mztoools.com) to drop the error handler
into each new routine with the click of a toolbar button. You can configure
your own error handler, so mine is configured to add:
'On Error Goto Err_Hander
i.e. it is commented out. During development the lines all fail at the point
where they happen. Before release, we do a global search for:
'On Error
and replace with:
On Error
so they are all activated.
Sure, but then your customers have exactly the same problem,
as your error handler goes round and round processing the
same error over and over again.
Other useful techniques:
- breaking out anything that is likely to error into its own little wrapper
function;
- calling a global error handler that can just ignore things like error
2501.
- logging the errors, because users can never tell you what happened.
My present error handling routine does these things and MUCH
more, like composing clever search strings to search Google
Groups with a single button press, substituting better error
Messages for the cryptic ones that come with Access, etc.


--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

Nov 13 '05 #3

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

Similar topics

9
10887
by: Robert Wing | last post by:
I support an MS Access application in which errors are trapped using the On Error statement. Just recently, the users of this system have experienced run-time error number 3021 on a random basis. My biggest problem right now is that the error description associated with this error is Application-defined or object-defined error. It has always been my understanding that these error numbers would not be used by Microsoft and were available...
6
4751
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
1
1857
by: Brad | last post by:
I added an Error event to a web usercontrol (ascx), but when an error is raised in the control it does not get called...only the Application_Error even in the global.asax gets called. The same thing in an aspx works correctly. Does the Error event not really work with a user control or is there something I am misunderstanding? Using Framework 1.1 - VS2003 Thanks
33
3157
by: Anthony England | last post by:
I am considering general error handling routines and have written a sample function to look up an ID in a table. The function returns True if it can find the ID and create a recordset based on that ID, otherwise it returns false. **I am not looking for comments on the usefulness of this function - it is only to demonstrate error handling** There are three versions of this code. David Fenton says under the earlier thread "DAO...
10
3764
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 GoTo Err_Ctrl 'This code is generating the error If Nz(Me.SubformCont.Form!txtUsage,"") = "' Then Msg "There's a problem"
6
2839
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 web.config file <httpHandlers> <add verb="*" path="*.imgw" type="Customhandler.Handler,Handler" /> </httpHandlers> following is the code in Handler.ashx file
2
19484
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
9
2271
by: Daniel Smedegaard Buus | last post by:
Hey all :) I was wondering about the $error_types (I particularly notice the 's' suffix when reading the manual) parameter for 'set_error_handler()': Can be used to mask the triggering of the error_handler function just like the error_reporting ini setting controls which errors are shown. Without this mask set the error_handler will be called for every error regardless to the setting of the error_reporting setting.
0
2897
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
8830
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9544
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.