Error Handling Code

  • Thread starter SteelFire via AccessMonster.com
  • Start date
S

SteelFire via AccessMonster.com

I need to start putting in some error handling and debuging code. I was
reading some different forms and most came back to Allen Browne's. I was
thinking of using his, but am I to put all that code in every form and what
not or do I make a module? And if I use a Module, how do I get the code to
run off of it. And it talks about a table to hold all of the errors. Do I
have to make the table, and the module just adds a new record or what? Would
I be able to just put the information into a .txt file? And If I did, would
it make a new file for each new error, or just add to it?
 
A

Allen Browne

Presumably we are talking about this one:
Error Handling in VBA
at:
http://allenbrowne.com/ser-23a.html

The Function LogError() goes into a standard module, once. You don't need
all that in every procedure. The first example in the article shows 9 lines
of code. What you do in each procedure you have is to include error handling
like that, but replace the line:
MsgBox Err.Number & Err.Description
with:
Call LogError(Err.Number, Err.Description, "SomeName()")
replacing SomeName() with the name of the actual procedure.

Instead of typing those lines into every procedure, what I actually do is
use a little utility from mztools.com. It gives you a toolbar in your VBA
window. One of the buttons on that toolbar drops this code into any
procedure for you, without having to type it. You can download the utility
for VBA from:
http://www.mztools.com/v3/mztools3.aspx
 
S

SteelFire via AccessMonster.com

Thank you so much. It is nice to know that the higher ups are taking the time
to help out the lowly newcomers. The mztools toolbar has saved me a lot of
time. Again, thanks.

Allen said:
Presumably we are talking about this one:
Error Handling in VBA
at:
http://allenbrowne.com/ser-23a.html

The Function LogError() goes into a standard module, once. You don't need
all that in every procedure. The first example in the article shows 9 lines
of code. What you do in each procedure you have is to include error handling
like that, but replace the line:
MsgBox Err.Number & Err.Description
with:
Call LogError(Err.Number, Err.Description, "SomeName()")
replacing SomeName() with the name of the actual procedure.

Instead of typing those lines into every procedure, what I actually do is
use a little utility from mztools.com. It gives you a toolbar in your VBA
window. One of the buttons on that toolbar drops this code into any
procedure for you, without having to type it. You can download the utility
for VBA from:
http://www.mztools.com/v3/mztools3.aspx
I need to start putting in some error handling and debuging code. I was
reading some different forms and most came back to Allen Browne's. I was
[quoted text clipped - 6 lines]
did, would
it make a new file for each new error, or just add to it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top