473,890 Members | 1,355 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 2390
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
10893
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
4771
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
1860
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
3173
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
3785
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
2843
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
19513
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
2279
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
9822
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
10819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10923
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
10462
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
5851
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
6045
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4676
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
2
4271
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.