Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error handling...can it be automated?

Status
Not open for further replies.

gusbrunston

Programmer
Feb 27, 2001
1,234
US
[tt]
Hi:

When I use the command button wizard, I get a nice packaged private sub with error handling lines. When I enter my own code, I'm sorry, but I haven't regularly included error handling code.

Is there any way to correct this programatically, or do I have to pay the price for my neglect and go back and do it for each subroutine?

...I was afraid of that.

Thanks, [glasses][tt] Gus Brunston - Access2000(DAO)[/tt] Intermediate skills.
 
You don't HAVE to handle errors at all if you don't want to !

However, if your db is for 'publication' and you want to make it 'user proof' then you will have to do something about error handling.

HOWEVER, there is something that might make life a little easier - Error Handling in Access is hierarchical.

If you have an event procedure eg.
Private Sub cmdButton_Click()

that has code in it that calls a general procedure eg.
Private Sub LevelOne()

which in turn calls another general procedure eg.
Private Sub LevelTwo()

then:-

If an error occures in the LevelTwo code Access will look for an Error Handler in LevelTwo procedure. If it does not find one then it will lokk again in the LevelOne Code. If it still fails to find a handler it will look in the cmbButton_Click procedure.

Therefore, as a first step, all you need to do is make sure you have error handling in the event procedures.
Then make sure that these error handlers will cope with all possible error occurances in the procedures that are called by it.
If that becomes too complex then go down a level and handle the error more locally.



'ope-that-'elps.



G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
[tt]
Thanks, GLS:

Everything you wrote about error handling is new to me. Therefore, I learned a great deal. I realize now that before I finish a db for compiling and distribution I should study a lot more about error handling (and security, and custom toolbars and...).

Thanks again. [glasses][tt] Gus Brunston - Access2000(DAO)[/tt] Intermediate skills.
 
a "USER PROOF" database, my dream. if you think that exists you have to come and work over here.

LOL Christiaan Baes
Belgium
"What a wonderfull world" - Louis armstrong
 
Gus,

Check out the Error Handling bit on my website. I really believe strongly in capturing every error in every procedure, so that you know where errors come from. I've written a bit of code to generate the error handling code I need for each procedure, as well as a generic error handler.

I'm sure you'll want to tweak it some, if you use it, but its a pretty decent place to start. It should become automatic to use error handling in every procedure, just as it's automatic to write the End If line as soon as you write the If Then line, so that you never have to go hunting to figure out which one you left out.

Jeremy =============
Jeremy Wallace
AlphaBet City Dataworks

Take a look at the Developers' section of the site for some helpful fundamentals.
 
If you have loaded Developer Tools, an Add-In that is available is for adding error handling.

There is a choice to create error handling for the current procedure or all modules in the project currently without error handling. Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
[tt]
Thanks, all:

I have seen the bit about error handling in the guide to my newly received Office XP Developer. (The 747 page Guide has no index!)

Pretty slick stuff about automating error handling. [glasses][tt] Gus Brunston - Access2000(DAO)[/tt] Intermediate skills.
 
Just to clarify, I support Jeremy Wallace's comments about trapping and handling errors locally.

My comments about hierarchy was intended as eductational and to give you a 'fix' option - not to promote the idea as an ideal solution.


'ope-that-'elps.

G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top