Output Debug.Print to file

  • Thread starter Thread starter Calvin Willman
  • Start date Start date
C

Calvin Willman

I'm trying to save off my debug info to a file, but don't know how. It's to
print the RecordSource property of every form in the database, which I can
do to the immediates window fine, but the thing scrolls too much and I lose
the first few lines.
 
I'm trying to save off my debug info to a file, but don't know how. It's
to
print the RecordSource property of every form in the database, which I can
do to the immediates window fine, but the thing scrolls too much and I
lose
the first few lines.

You can use something like the following function:

Function WriteTextFile(Content As String, Filename As String, PlaceInFolder
As String) As String
Dim iFreefile As Integer
iFreefile = FreeFile
Open Replace(PlaceInFolder & "\" & Filename, "\\", "\") For Output As
iFreefile
Print #iFreefile, Content
Close #iFreefile
err_:
Close #iFreefile
End Function

and whereever you need something written to a file you use:
WriteTextFile "This goes in the file","myfile.txt","c:\"

If you need to keep appending something to the same file instead of creating
a new you should use:
Open Filename For Append As iFile
instaed of :
Open Filename For OutPut As iFile



Jesper Fjølner
 
This is great. Thanks.


You can use something like the following function:

Function WriteTextFile(Content As String, Filename As String, PlaceInFolder
As String) As String
Dim iFreefile As Integer
iFreefile = FreeFile
Open Replace(PlaceInFolder & "\" & Filename, "\\", "\") For Output As
iFreefile
Print #iFreefile, Content
Close #iFreefile
err_:
Close #iFreefile
End Function

and whereever you need something written to a file you use:
WriteTextFile "This goes in the file","myfile.txt","c:\"

If you need to keep appending something to the same file instead of creating
a new you should use:
Open Filename For Append As iFile
instaed of :
Open Filename For OutPut As iFile



Jesper Fjølner
 
Create a new table tblRecordSource and use DAO to add new records
instead of

Debug.Print

Set targetRS = CurrentDb.OpenRecordSet("tblRecordSource")

[Debug.Print]
With .rs
.AddNew
.Fields("txtRecordSource") = [whatever code]
.Update
end with
 
Back
Top