2009-12-22 10 views
0

Utilisation de VB6 ET Crystal Report 9Comment rafraîchir le rapport de cristal?

Dans mon logiciel, lorsque je visualise mon rapport, il affiche une ancienne donnée, s'il y a des changements dans les données chaque fois que je dois actualiser mon rapport. Comment actualiser le rapport automatiquement lorsque j'exécute mon logiciel.

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) 

J'ai essayé CRViewer1.refresh, il affiche l'erreur

Comment actualiser le rapport dans mon code lui-même.

Besoin code VB6 Aide

Répondre

4

Essayez de jeter les données enregistrées avant de les téléspectateurs déclarent la source

Report.DiscardSavedData 
CRViewer1.ReportSource = Report 
+0

vous pouvez également modifier le rapport et non sélectionnez l'option « Enregistrer les données avec le rapport » dans le menu fichier. – dotjoe

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