Solved

Printing DataGrid Results

Posted on 2004-04-19
7
321 Views
Last Modified: 2007-12-19
I have created an SQL query using ADO that retrieves some data from a database, then I use a datagrid to output the results for the user.  I am trying to give the user the option of printing those results.  How can I do this?
0
Comment
Question by:MaRs79
[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
  • 2
7 Comments
 
LVL 18

Expert Comment

by:Sethi
ID: 10861019
0
 

Author Comment

by:MaRs79
ID: 10861577
I am using the MSDatagrid control.  The flexgrid control does not work for me.
0
 
LVL 2

Expert Comment

by:DANNYMAC
ID: 10861600
The easyest was is to print the recordset.  
be sure to update your recordset with any changes in the data grid the client might make then simple print your recordset.
Here is a a simple routine that will print out any recordset.
Private Sub Command1_Click()

    Dim FSo As New FileSystemObject
    Dim F, J
   
    Set F = FSo.CreateTextFile(App.Path + "\test.csv", True)
    With Adodc1.Recordset
        .MoveFirst
        While Not .EOF
            For J = 0 To .Fields.Count - 1
                F.Write .Fields(J) & IIf(J = .Fields.Count, "", ",")
                Next
            F.WriteLine
            .MoveNext
            Wend
        End With
    F.Close

End Sub
This assumes that the data is in an ADODC Data control.  But simply change the With Reference to your recordset or Contol name.  Also this will put out a comma separated ftext file, again simply change the field separator to what you wish to use.

There is no easy or simple way that I know of to list row by row data in a datagrid.  It is easy to goto a row or cell if you know where it is, like the cursor is on it, but if the number of columns and rows are unknown then I do not know of a way to loop thru the datagrid.

Hope this helps.
D
0
 
LVL 18

Accepted Solution

by:
Sethi earned 125 total points
ID: 10864779
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

756 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