Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleRefresh a DataReport
KeywordsDataReport, refresh
CategoriesDatabase
 
It seems when you create a DataReport attached to a DataCommand object in a DataEnvironment, the report does not refresh itself when the data is modified. This example shows how to ensure that the report is up-to-date.

Create a DataReport without attaching it to a DataEnvronment or DataCommand. Insert TextBoxes in the detail section and set their DataField values to be the names of the fields in the table.

Then when you need to create a report, use ADO to build a Recordset with the data you want to display and set the DataReport's DataSource property to point to that Recordset. Because you rebuild the Recordset each time you display the report, there can be no monkey business with the Recordset not getting refreshed.

 
Private Sub Form_Load()
    Set conn = New ADODB.Connection
    conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & App.Path & "\books.mdb;" & _
        "Persist Security Info=False"
End Sub

Private Sub cmdReport_Click()
    Set rs = conn.Execute("SELECT Title, Year, URL, Pages, " & _
        "ISBN FROM BookInfo ORDER BY Title")

    Set rptTitles.DataSource = rs
    rptTitles.Show vbModal
End Sub

Private Sub Form_Unload(Cancel As Integer)
    conn.Close
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated