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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with creating Error Trapping method.....

Status
Not open for further replies.

cavery

Technical User
Oct 29, 2002
129
0
0
US
Hello,
Does anyone know of a easy and simple method with creating a program that will capture errors and store them in a file? (either word, notepad, etc.)

Currently my group is using Access 97...

Thanks for your help,
Clark

~Clark
 
Hi

Define table to hold data

Set error trap code with On Error Go To

In the rror trap include code to insert a record into the table or errors recorded

which bit do you not understand?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Well I'm sort of lost on the last line, but here is what I have so far as code:

Private Sub cmdappend_Click()
On Error GoTo Err_cmdappend_Click

(I have a few things here obviously, but didnt want to copy the entire cod)

Exit_cmdappend_Click:
Exit Sub

Err_cmdappend_Click:
MsgBox Err.Description, vbCritical, ("ARCHIVE UNSUCCESSFUL, CONTACT YOUR SYSTEMS ADMINSTRATOR")
Resume Exit_cmdappend_Click


End Sub
So what I'm looking for is a method to add the error message, user name, pc etc. in a text file for record retention...

Thanks,
Clark

~Clark
 
Hi

It would be easier to stick it in a table

I will assume you have teh userLogin Id and PC Id extracted into globals gUser and gPC

Private Sub cmdappend_Click()
On Error GoTo Err_cmdappend_Click

(I have a few things here obviously, but didnt want to copy the entire cod)

Exit_cmdappend_Click:
Exit Sub

Err_cmdappend_Click:
MsgBox Err.Description, vbCritical, ("ARCHIVE UNSUCCESSFUL, CONTACT YOUR SYSTEMS ADMINSTRATOR")
Resume Exit_cmdappend_Click

strSQL = "INSERT INTO tblErrors (lngErr, ErrDesc,strUser,strPC) VALUES (" & Err.Number & ",'" & err.Description & "','" & gUser & "','" & gPC & "');"
docmd set warnings false
docmd.runSQl strSQl
docmd.setwarnings true


End Sub


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I prefer sticking it in a temp file. Part of this preference is tied to the fact that I learned to do this from a VB programmer who was very distrustful of mdbs, but part of it is that a text file is a much simpler creature than an mdb, and if there's corruption in the mdb, you may not be able to get to your table so easily.

My method is detailed in the Developers' section of my website. Clearly it will require some tweaking to work in your databases, but it's pretty clean.

There's also code up there to build the lines of code you'll want to include in the subs and functions that use the error trapping method.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top