Error Handling Log

ECEK

Registered User.
Local time
Today, 15:55
Joined
Dec 19, 2012
Messages
717
I currently have several on errrors go to eg:
Code:
IMPORTATN:
    DoCmd.OpenQuery "dltErrorLog", acViewNormal, acEdit
    DoCmd.RunSQL ("INSERT INTO tblErrorLog ( Errortext )VALUES ('There has been an error with importing ATN');")
    DoCmd.Quit

These are used for specific parts of my code to identify what has gone wrong. However if an error occurs between "On Errors" then I have to trawl through my code running it to find the problem.

Is there a way of having just one On Error goto and recording at what point the error occured ie which query didn't run successfully etc ?

Thanks for you time in advance
 
If you use an addin like MZ Tools you can add line numbers to your code and also to your error handling.
Unfortunately MZ Tools isn't free but there may be free alternatives that do the same thing???
 
Hi Ridders. This is on a network and as such add-ons are problomatic.
 
At the very least your error handling needs to provide (and log) the following information
- error number and description e.g Error 94 Invalid use of null
- procedure name / location e.g. cboUser in frmMain
- user name and workstation name
- date/time

All of the above can easily be obtained using standard vba code (no addins)
However having code line numbers are better still for diagnostic purposes
 

Attachments

  • oops.jpg
    oops.jpg
    35.4 KB · Views: 56
Link works for me

OK, I must be doing something stupid then.?
I am clicking on the link at the top of the article that says Our companion download includes a demonstration database and a several .bas module files

I then get that Oops message.?
 
I hadn't checked the link in the article which is, as you say, broken.
The article itself is fine though.
 
Minty
I have put the Function into my database.
How would I now "Call" it in my VBA code?
 
In your error handling routine simply put

Code:
errHandler:  Call LogError
MsgBox "Error has been logged", vbOKOnly, "Error"

The message box is optional, but helpful to end users.
 
Thanks Minty I'll give this a go and report back.
 

Users who are viewing this thread

Back
Top Bottom