You can use something like this (write in Append mode so you don't loose previous entries):VB Code:
Option Explicit Private Sub Form_Load() On Error GoTo ErrorHandeler Debug.Print 1 / 0 Exit Sub ErrorHandeler: writeLog Err.number, Err.description, "Form1 Form_Load" End Sub 'in module Public Sub writeLog(number As Long, description As String, procedure As String) Dim ff As Integer: ff = FreeFile Open App.Path & "\error.log" For Append As #ff Print #ff, Format(Date, "dd.mm.yy") & ", " & Format(Time, "hh:mm:ss") & " - error #" & number & " - " & description & " - " & "in " & procedure & " procedure" Close #ff End Sub




Reply With Quote