如何刷新水晶报告?

时间:2009-12-22 05:47:33

标签: vb6 crystal-reports refresh

使用VB6和Crystal Report 9

在我查看报告的软件中,如果每次必须刷新报告时数据有任何变化,它都会显示旧数据。如何在运行我的软件时自动刷新报告。

代码

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)

我试过CRViewer1.refresh,显示错误

如何在我的代码中刷新报告。

需要VB6代码帮助

2 个答案:

答案 0 :(得分:4)

尝试在设置查看者报告来源之前丢弃已保存的数据

Report.DiscardSavedData
CRViewer1.ReportSource = Report

答案 1 :(得分:0)

'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