You'll need to adapt this to your situation, but this is one way to pass parameters:
Private Sub Command1_Click()
Dim crpParamDefs As CRAXDRT.ParameterFieldDefi
Dim crpParamDef As CRAXDRT.ParameterFieldDefi
Dim crpSubreport As CRAXDRT.Report
Set crpParamDefs = Report.ParameterFields
For Each crpParamDef In crpParamDefs
With crpParamDef
Select Case .ParameterFieldName
Case "@PARAM1"
.SetCurrentValue "PARAM1 VALUE"
Case "@PARAM2"
.SetCurrentValue "PARAM2 VALUE"
End Select
End With
Next
Report.EnableParameterProm
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
End Sub
Main Topics
Browse All Topics





by: DRRYAN3Posted on 2003-10-27 at 14:54:51ID: 9630382
Start by going to File-Options, Database and check the box for Stored Procedures.
Your stored procedure should return a single recordset, most easily achieved by having the final statement in the stored procedure be a select statement of some kind.
I've found the best performance using the Crystal Reports "Microsoft SQL Server" data source, available under "More Data Sources" in the data explorer displayed when you create a new report.
Select your stored procedure from the list of stored procedures (if yours is not displayed, you have a permissions issue on the SQL server).
As far as VB goes, the only change you'll need to make is how your parameters are named. If your stored procedure takes a parameter named @PARAM1, then Crystal Reports will name it {?@PARAM1} and that is how you need to reference it when you pass the parameters to CR from VB.
I'll dig up a code example in a minute.