Reputation: 11972
Using VB6 AND Crystal Report 9
In my software when i view my report, it is displaying a old data's, if there is any changes in the data's every time i have to refresh my report. How to refresh the report automatically when i run my software.
Code
Dim crApp As CRAXDRT.Application
Dim Report As CRAXDRT.Report
Set crApp = New CRAXDRT.Application
Set Report = crApp.OpenReport(App.Path & "\ScheduleReport.rpt")
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
CRViewer1.EnableExportButton = True
CRViewer1.DisplayGroupTree = False
CRViewer1.EnableSearchControl = False
CRViewer1.Zoom (100)
I tried CRViewer1.refresh, It showing error
How to refresh the report in my code itself.
Need VB6 code Help
Upvotes: 0
Views: 9270
Reputation: 1
'After searching hours...this is the solution for Refresh......
Dim Appl As New CRAXDRT.Application
Dim rpt As New CRAXDRT.Report
Private Sub CRV1_RefreshButtonClicked(UseDefault As Boolean)
CRV1.Refresh
End Sub
Private Sub Form_Activate()
CRV1_RefreshButtonClicked True 'This EVENT IS IMPORTANT FOR REFRESH
End Sub
Private Sub Form_Load()
ReportPath = App.Path & "\YourReportFile.rpt"
Set Appl = New CRAXDRT.Application
Set rpt = Appl.OpenReport(ReportPath)
If rpt.HasSavedData Then rpt.DiscardSavedData
rpt.VerifyOnEveryPrint = True
CRV1.ReportSource = rpt
CRV1.Refresh
CRV1.ViewReport
End Sub
Upvotes: 0
Reputation: 14913
Try discarding the saved data before setting the viewers report source
Report.DiscardSavedData
CRViewer1.ReportSource = Report
Upvotes: 4