Reputation: 11
I did my best to try and explain my problem elsewhere, but so far none has really known anything. This project has just kind of been handed to me. A link to my explanations that I have so far. I can try and provide any further information that's needed: http://www.reddit.com/r/learnprogramming/comments/1pqzvi/crystal_reports_xi_not_passing_variables_from_vb6/
Upvotes: 1
Views: 861
Reputation: 1292
The following code does precisely what you are asking for, assuming you have placed the CRViewer control on your form naming it CRViewer1.
Even though you might already understand the code, perhaps a novice VB6 programmer is reading this, so I have added additional comments that explain what is happening.
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
Upvotes: 1