Save an Error log File
The following code shows how one can record errors to a Errors log file. Create an Errors.log file first and place that file in your apps path. Place the error handling in whatever procedures you want. Place the errLogger procedure in a module as a public procedure or in a form as a private procedure.
Module
Public Sub errLogger(ByVal lNum As Long, ByVal sDesc As String, ByVal sFrom As String)
Dim FileNum As Integer
FileNum = FreeFile
Open App.Path & "\Errors.log" For Append As FileNum
Write #FileNum, lNum, sDesc, sFrom, Now()
Close FileNum
End Sub
Usage
Private Sub butGenErr_Click()
On Error GoTo Err_handler
Exit Sub
Err_handler:
If Err.Number <> 0 Then
errLogger Err.Number, Err.Description, "butGenErr_Click"
Err.Clear
Resume Next
End If
End Sub
Special Instructions
This code originally appeared on AndreaVB.com, and has been republished here with the permission of Andrea Tincani.
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.