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

Logging Access errors in external log file 1

Status
Not open for further replies.

SlakeB

MIS
Jun 15, 2005
40
US
I have a form in my access db with a number of buttons tied to sub procedures. Right now, any errors are displayed in a message box:

Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub

Instead of this, I would like the errors to go to either an external log file, or better yet into a table (tblErroLog) in the db. Can anyone help?
 
use an append query something like this for a table. You will need to add any additional fields and values you would want to capture

MsgBox Err.Description
sql = "Insert into tblErroLog (fieldname) values('" & Err.Description & "')"
currentdb.execute sql
Resume Exit_Command1_Click
End Sub
 
Here is my code:
Err_Command1_Click:
MsgBox Err.Description
Dim sql As String

sql = "INSERT INTO tblErrorLog (ErrorDescription)" &_ "VALUES('" & Err.Description & "')"

DoCmd.RunSQL sql
Resume Exit_Command1_Click
End Sub




I keep getting this error:
Syntax error (missing operator) in query expression "The expression you entered has a function name that Microsoft Access can't find. ')'.

Can you find the syntax error?
 
You may try this:
sql = "INSERT INTO tblErrorLog (ErrorDescription)" _
& " VALUES('" & Replace(Err.Description, [tt]"'", "''"[/tt]) & "')"


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top