Use the CRAXDRT objects to set the parameters (and anything else you need, like login information).
This sample code Opens, Sets two Parameters and then Shows the report on a Form that contains the Crystal Viewer control. In this case the two parameters are "Discrete" Date values that the user chosen from Date Picker controls.
VB Code:
Dim objCrystal As CRAXDRT.Application 'its better to create this object global to the VB application. Dim objReport As CRAXDRT.Report Dim objParam As CRAXDRT.ParameterFieldDefinition Set objCrystal = New CRAXDRT.Application Set objReport = objCrystal.OpenReport(FileName, 1) Set objParam = objReport.ParameterFields.GetItemByName("@FromDate") objParam.ClearCurrentValueAndRange objParam.AddCurrentValue dtpFromDate.Value Set objParam = objReport.ParameterFields.GetItemByName("@ToDate") objParam.ClearCurrentValueAndRange objParam.AddCurrentValue dtpToDate.Value With frmReportViewer If Len(ReportTitle) > 0 Then .Caption = ReportTitle End If .ReportViewer.ReportSource = objReport .ReportViewer.ViewReport .Show .ZOrder vbBringToFront End With
Note I only have Crystal 8.5 but the code should be similar for 9.




Reply With Quote