PDA

View Full Version : Creating an Error Log Document



Imdabaum
06-18-2007, 03:26 PM
Does anyone have a good way to write to a word/notepad document from Access if an error occurs at a certain sub/function?

I would just want to write out a time stamp, where the error ocurred, and then carriage return. Then next time an error happens I would want it to go to the bottom of the page and start from where it left off.

geekgirlau
06-18-2007, 06:44 PM
Sub ErrorLog(lngErrNo As Long, strErrDesc As String, strProcedure As String, _
strModule As String)

Dim strLog As String


On Error Resume Next
strLog = "C:\My Documents\Error_Log.txt"
Open strLog For Append As #1

Print #1, lngErrNo & Chr(9) & _
strErrDesc & Chr(9) & _
strProcedure & Chr(9) & _
strModule & Chr(9) & _
Now()

Close #1
End Sub


When you call this procedure, you need to pass the error number, error description, procedure name and module name.