简体   繁体   English

如何刷新水晶报表?

[英]How to refresh the crystal report?

Using VB6 AND Crystal Report 9 使用VB6和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 我尝试了CRViewer1.refresh,它显示错误

How to refresh the report in my code itself. 如何在我的代码本身中刷新报告。

Need VB6 code Help 需要VB6代码帮助

Try discarding the saved data before setting the viewers report source 在设置查看者报告源之前,请尝试丢弃保存的数据

Report.DiscardSavedData
CRViewer1.ReportSource = Report
'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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM