• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 574
  • Last Modified:

Creating Error catching in VBA (Access 2007)

Hello,

I need to come up with a proper (best) way to catch error in my access 2007 application. I have created an error table and plan on insert error code and descriptions in the table instead of showing it as a message box. How should I go about this? Should I create one function that inserts the error into the error table, then from my other functions is where I call the error function?

My error table is

ErrorLogID autonumber
ErrNumber TEXT
ErrDescription TEXT
ErrDate DAte/Time
CallingProc (function) TEXT
ShowUser Yes/No
Parameters TEXT

Thanks
0
lulubell-b
Asked:
lulubell-b
1 Solution
 
thydzikCommented:
yes, create one function that inserts the error function into the error table.

let it take in parameters
ErrObject - error number and description
CallingProc - the name of the function

in the function (errfunc) the
ErrDate will be Now()

set it up in each of your functions to call errfunc on error, with the name of the function as the callingproc

see example
 
Function tester()
    On Error GoTo errjump
    

    
errjump:
    
    errfunc Err, "tester"
    Resume Next

End Function

Open in new window

0
 
Jeffrey CoachmanCommented:
<I have created an error table and plan on insert error code and descriptions in the table instead of showing it as a message box.>

Be careful of this as error numbers and descriptions can change in different versions of Access for the same error...


0
 
Luke ChungPresidentCommented:
Here are a few of my papers that you may find helpful:

This paper was also published on MSDN:
Error Handling and Debugging Tips and Techniques for Microsoft Access, VBA, and Visual Basic 6 (VB6) http://www.fmsinc.com/tpapers/vbacode/Debug.asp

Pinpointing the Exact Line Where A Crash Occurs in VB6 or VBA
http://www.fmsinc.com/free/NewTips/VBA/ErrorHandling/LineNumber.html

It's a matter of creating a global error handler to document the error. The challenge you may face is that depending on the error, it's not always possible to write it to a table. We always write errors to a text file located in the user's folder to avoid any database problems that may be occurring.

You'll also want to make sure your environment has the right error handling settings when your application starts. That's covered in the first paper. Hope this helps.  Good luck.
0
 
puppydogbuddyCommented:
Try this free error handler wizard:
               http://www.aadconsulting.com/legacyaddins.html
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now