?
Solved

Using debug.print to print horizontal (like crosstab)

Posted on 2011-02-13
6
Medium Priority
?
541 Views
Last Modified: 2012-05-11
Experts,

I'm using the code below to loop through a record on a form. However, instead of debug.print displaying the information vertical, I'd like for it to display horizontal (like crosstab)l.
 
For example...

Normal debug.print
1
2
3

Horizontal debug.print
1 2 3

Thank you,
James

Dim rst As dao.Recordset
        Dim strReport As String
        
        Set rst = Me.RecordsetClone
        
        With rst
            .MoveFirst
            Do While Not .EOF                   
                    
                    strString = rst!ReportInfo
                    
                    Debug.Print strString
                    
                .MoveNext
                
            Loop
        End With

Open in new window

0
Comment
Question by:jdallain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 34883876
Like this ...

            Do While Not .EOF                  
                   
                    strString = strString & " " &  rst!ReportInfo
                   
                    '   Debug.Print strString
                   
                .MoveNext
               
            Loop
     
           Debug.Print strString

mx
0
 
LVL 75
ID: 34883880

How about just this:

        Dim strReport As String
               
        With Me.RecordsetClone
            .MoveFirst
            Do While Not .EOF                  
                   
                    strString = strString & " " &  rst!ReportInfo
                   
                    '   Debug.Print strString
                   
                .MoveNext
               
            Loop
     
           Debug.Print strString

        End With
0
 
LVL 11

Expert Comment

by:RgGray3
ID: 34883894
Method 1, place a comma after the data being printed
Try the following in the immediate window

Dim x As Integer

    For x = 1 To 10
        Debug.Print x,
    Next
   
End Sub

this may not be suitable depening on what the data is and its size and consistency as the comma acts like a Tab

or you can Move the Debug.print outside the loop and build a string where you currently have the debug.print

Not knowing the data behind ReportInfo this may or may not suit your needs

You Lets say that report info is 15 characters in size...  you could define a var as string 18 and when you debug.print it it would guarentee 3 characters between values


0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Closing Comment

by:jdallain
ID: 34883900
Thank you very much! I probably should have been able to figure that out :)
0
 
LVL 19

Expert Comment

by:Richard Daneke
ID: 34883910
You cannot unprint a debug.print, so I think you would need to extend the string on each repeat:
1
1 2
1 2 3
Then, the code attached may work.
Dim rst As dao.Recordset 
        Dim strReport As String 
         
        Set rst = Me.RecordsetClone 
	
         
        With rst 
            .MoveFirst 
            Do While Not .EOF                    
                    ' we build the string by tacking on the next values
                    strString = strString & " " & rst!ReportInfo 
                     
                    Debug.Print strString 
                     
                .MoveNext 
                 
            Loop 
        End With

Open in new window

0
 
LVL 75
ID: 34883915
You are welcome. That's why we are here ... just in case you can't ... at the moment :-)

mx
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question