Smart questions
Smart answers
Smart people
Join Tek-Tips Forums

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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.

rproactive (TechnicalUser) (OP)
2 Dec 06 3:45
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
Helpful Member!  Remou (TechnicalUser)
2 Dec 06 5:18
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

Helpful Member!  TheAceMan1 (Programmer)
2 Dec 06 7:38

 . . . 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! .  .  .  .  .  .

rproactive (TechnicalUser) (OP)
2 Dec 06 14:16
thanks I will try your suggestions
rproactive (TechnicalUser) (OP)
2 Dec 06 18:30
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
Remou (TechnicalUser)
2 Dec 06 18:35
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?
rproactive (TechnicalUser) (OP)
2 Dec 06 18:41
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
Remou (TechnicalUser)
2 Dec 06 18:51
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.
rproactive (TechnicalUser) (OP)
2 Dec 06 18:59
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
Remou (TechnicalUser)
2 Dec 06 19:06
Good. smile

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!

Back To Forum

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