Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleBuild a DataReport using a program-created Recordset
KeywordsDataReport, Recordset
CategoriesDatabase
 
Create the Recordset using New. Use its Fields.Append method to define the Recordset's fields. Open the Recordset and use its AddNew method to create the records. Finally, set the report object's DataSource property to this Recordset and display the report.

Note: This program requires MDAC 2.5. Download it.

 
Private Sub cmdReport_Click()
Dim rs As ADODB.Recordset
Dim fld As ADODB.Field

    Set rs = New ADODB.Recordset
    rs.Fields.Append "Name", adVarChar, 30
    rs.Fields.Append "Amount", adCurrency

    rs.Open
    rs.AddNew Array("Name", "Amount"), Array("Rod", 123.45)
    rs.AddNew Array("Name", "Amount"), Array("Michelle", _
        12345)
    rs.AddNew Array("Name", "Amount"), Array("Amy", 54.321)
    rs.AddNew Array("Name", "Amount"), Array("Merlin", _
        9.8765)

    Set rptTest.DataSource = rs
    rptTest.Show vbModal

    rs.Close
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated