I use this to log errors
Public Sub errorLog(strWhere As String)
Dim strMsg As String
Dim strErr As String
Dim intFp As Integer
strErr = ""
If (Err.Number <> 0) Then
strErr = " - " & Err.Description
End If
On Error Resume Next
intFp = FreeFile
Open logFile & ntUserName() & "-RW.txt" For Append As #intFp
strMsg = Day(Now) & " " & Month(Now) & " " & Year(Now)
strMsg = strMsg & " - " & Hour(Now) & ":" & Format(Minute(Now),
"00")
strMsg = strMsg & " " & strWhere & strErr
Print #intFp, strMsg
Close #intFp
Err.Clear
End Sub
Public Sub resetLog()
On Error Resume Next
Kill logFile & ntUserName() & "-RW.txt"
Err.Clear
errorLog "Log reset"
End Sub
Public Sub msg(strMsg As String)
Dim intFp As Integer
On Error Resume Next
intFp = FreeFile
Open logFile & ntUserName() & "-RW.txt" For Append As #intFp
Print #intFp, strMsg
Close #intFp
Err.Clear
End Sub
FJ wrote:
Hi all,
I hope someone can help me with the following:
I want my database to make a logfile in which it puts the date and time
a code is used. The code is triggered by a timer. Every x mins it
checks something and I want to write the time and date it checks into
that logfile.
So far I have only been able to make it a new file each time, but I
want it to be added in a text file (so that in the end you open the
file and see all the times and dates).
Does anyone have a bright idea on how to do this?
Thanks in advance!
F-J