I have some code for a routine I call Logger that write a timestamped message to a file.
You Identify the file.
Code:
' Date : 1/21/2009
' Purpose : To write records to a LOG file using FileSystemObject.
'
'Parameters
' sLogName As String -- full path and file name of the log file
' sLogRec As String -- record to be written to the log
'
' NOTE: Each log record has a timestamp appended
'
' Special Note/restriction:
'***** Must set a reference to MICROSOFT SCRIPTING RUNTIME ***
'---------------------------------------------------------------------------------------
'
Sub Logger(sLogName As String, sLogRec As String)
Dim tslog As TextStream
Dim fileLog As file
Dim I As Integer
Dim fso As FileSystemObject
On Error GoTo Logger_Error
Set fso = New FileSystemObject
Set fileLog = fso.GetFile(sLogName) '"I:\wordtest\output\Results.log")
Set tslog = fileLog.OpenAsTextStream(ForAppending)
tslog.WriteLine Now() & vbTab & sLogRec
tslog.Close
On Error GoTo 0
Exit Sub
Logger_Error:
MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure Logger of Module ADO_Etc"
End Sub
Typical usage
Code:
....
Dim myLog As String
myLog = "I:\jColby\myLog.txt"
Dim x As String
Set db = CurrentDb()
I = 0 'for testing
hName = "zzzqqq"
x = "List Tables with Indexes and/or " & vbCrLf & "Primary Key and Display Components" & vbCrLf & vbCrLf
Debug.Print x
Logger myLog, x
....
I just saw Norie's post. I'm assuming you're saying messages , but are referring to
Debug.Print to the immediate window.