Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

debug.Print Max 200 lines exceeded

debug.Print Max 200 lines exceeded

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

RE: debug.Print Max 200 lines exceeded

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.


'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

RE: debug.Print Max 200 lines exceeded

 . . . or you could write to a blank module:


   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

See Ya! .  .  .  .  .  .

RE: debug.Print Max 200 lines exceeded

thanks I will try your suggestions

RE: debug.Print Max 200 lines exceeded

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


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

RE: debug.Print Max 200 lines exceeded

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?

RE: debug.Print Max 200 lines exceeded

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

RE: debug.Print Max 200 lines exceeded

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.

RE: debug.Print Max 200 lines exceeded

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

RE: debug.Print Max 200 lines exceeded

Good. smile

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close