Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

debug.Print Max 200 lines exceeded 2

Status
Not open for further replies.

rproactive

Technical User
Oct 6, 2005
65
US
I have a vba code segment that uses Debug.Print but it overflows after 200 lines and overrights values.

Is there some way to extend this to more lines or output in some other manner??


Thanks for any help
 
You can output to a file with the Open Statement or the FileSystemObject. Open the file and use Print instead of Debug.Print, make sure you close the file in your error statements or you will get 'file in use' errors. If, for some reason, you find the file fails to close, you can close it in a separate procedure, if you dim the number at module level, or use a known number.

Code:
'Open statement
'Typed, not tested
'Get the next free number
FNo = FreeFile 
strOutput = "C:\Doc\Log.txt" 
'You can use Open ... As 1 ... 2 etc
Open strOutput For Output As FNo
'Output line
Print #FNo, "Help is at hand."

'Do stuff

'Output line
Print #FNo, "I did stuff."

Close FNo

'To open the file
FollowHyperlink strOutput

 
. . . or you could write to a blank module:
Code:
[blue]   Dim mdl As Module, Txt As String
   
   Set mdl = Modules("modTest")
   Txt = "Now is the time!"
   
   mdl.AddFromString "'Ace"
   mdl.AddFromString "'Man"
   mdl.AddFromString "'" & Txt[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks again tried code to show all closed forms but nothing happens. I obviously don't have quit right

Code:
Private Sub Command9_Click()
'add section to output to file
FNo = FreeFile
strOutput = "C:\STUFF\Log.txt"
Open strOutput For Output As FNo



'Sub AllQueries()
'All open queries
    Dim obj As AccessObject, dbs As Object
    Set dbs = Application.CurrentData
    ' Search for open AccessObject objects in AllQueries collection.
    For Each obj In dbs.AllQueries
        If obj.IsLoaded = True Then
            ' Print name of obj.
            Debug.Print "Open Queries : " & obj.Name
            Print #FNo, "Open Queries  : " & obj.Name
        End If
    Next obj
    Close FNo
End Sub

thanks again
 
The code above will only output queries that are currently open. This is likely to be very few or none. Did you ensure that you had a query open?
 
using this as a sample. Deliberately wanted upput small so caould verify in immediate window- which does show 1 open query. But no file output
 
Can you set a break and step through the code? I cannot see any error and it works for me exactly as you show it.
 
YES it works as you say I was looking in wrong folder. Its the simple things that keep a person humble.

thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top