Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing data on a .DSR report

Status
Not open for further replies.

Beaner5434

Programmer
Jul 18, 2001
12
US
I have developed a VB5 app which uses a .dsr report and the CRViewer. The user has the option of selecting two dates to compare on the VB5 form, then printing the results via the .DSR report. The following code is used when opening the form that contains the CRViewer control:

-------------------------------------------------
Option Explicit
Dim Report As New rptDooley
Dim DAOSnap As DAO.Recordset
Dim DAODb As DAO.Database
Dim wrkJet As Workspace

Private Sub Form_Load()
Dim sForm As String

Screen.MousePointer = vbHourglass
' Create a Microsoft Jet workspace
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
' Set the location of the database here
Set DAODb = wrkJet.OpenDatabase(dbMerger)
' Create the recordset off the designated Date fields,
sForm = "SELECT DooleyTemp.* From DooleyTemp "
sForm = sForm & "ORDER BY DooleyTemp.SummaryGroup;"
Set DAOSnap = DAODb.OpenRecordset(sForm)
Report.Database.SetDataSource DAOSnap
Report.ReadRecords
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set wrkJet = Nothing
Set DAODb = Nothing
Set DAOSnap = Nothing
Report.DiscardSavedData
Set Report = Nothing

End Sub
-------------------------------------------------
When I click the report button on the dialog form, it opens the report and shows the last data set displayed. If I then simply close the report form and reopen it, it shows the data the user has selected. I've tried putting the Report.DiscardSavedData at the start of the Form_Load event, after the report has been displayed, and when the form is closed, but it makes no difference; I have to open, close, and then reopen the report in order to display the information I want. I know it has to be something simple, but I am clueless at this point, and I am hoping one of you can help me out with this little glitch.

I also tried clicking the Refresh button on the report form. The report went blank (for data), which I figure is a clue? Again, though, if I close the report and then just reopen it, voila! Everything is there, just the way it should be.

Any hints or suggestions on how I can make this child behave would be greatly appreciated! Thanks!
 
Actually No Help just that I have somewhat the same problem in that I have to close the VB6 app and reopen it to get the report to get the correct information after changes have been made to the Database. I too have tried refreshing the data in the initialize and load events but to no avail. If you get the answer let me know. Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top