1

我尽我所能尝试在其他地方解释我的问题,但到目前为止,还没有人真正知道任何事情。这个项目刚刚交给了我。到目前为止我的解释的链接。我可以尝试提供所需的任何进一步信息:http ://www.reddit.com/r/learnprogramming/comments/1pqzvi/crystal_reports_xi_not_passing_variables_from_vb6/

4

1 回答 1

1

以下代码正是您所要求的,假设您已将 CRViewer 控件放置在您的表单上,并将其命名为 CRViewer1。

尽管您可能已经理解了代码,但可能是一个新手 VB6 程序员正在阅读本文,所以我添加了额外的注释来解释正在发生的事情。

Dim crxApp As New CRAXDDRT.Application 'Instantiate the CR ActiveX component
Dim crxRpt As CRAXDDRT.Report 'This is the report object created by CR

'Open the report definition file.  TheReportName example: MyReport.rpt
Set crxRpt = crxapp.OpenReport(App.Path & "\Reports\" & TheReportName)
'This is how we pass a value as a parameter to the report
'If you have more than one parameter, copy, paste, and edit for ParameterFields(2)
CrxRpt.ParameterFields(1).AddCurrentValue ("Your value here")
'The following assigns the generated report document to the CRViewer1 control and
'waits for the user to close the control
CrViewer1.ReportSource = CrxRpt
CrViewer1.DisplayGroupTree = True
CrViewer1.ViewReport
CrViewer1.Zoom (75)
While CrViewer1.IsBusy
    DoEvents
Wend
CrViewer1.Refresh
于 2014-01-01T20:39:49.340 回答