Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass stored Procedure Parameters to the report?

Data Access

How to pass stored Procedure Parameters to the report?

by  emcevoy  Posted    (Edited  )
The following example demonstrates how to set parameters using the Crystl32.ocx from Crystal Reports version 7 with Maintenance Release 1, which is the same for version 8.

All parameters including Stored Procedure and Crystal Parameters are set with the ParameterFields property. The exception is date-time Stored Procedures that are set with the StoredProcParam property.

For Example:

In the Report Designer a report has the following three parameters that appear in the "Insert Parameter" dialog box like this:

?ShipVia (Stored Procedure string parameter)
?Date (Stored Procedure date-time parameter)
?OrderAmt (Crystal Report number Parameter)

The following code will pass the parameters using the OCX from a Microsoft Visual Basic (VB) application:

CrystalReport1.StoredProcParam(1) = "1998-01-01 00:00:00.000"

CrystalReport1.ParameterFields(0) = "ShipVia;UPS;True"
CrystalReport1.ParameterFields(1) = "OrderAmt;2000;True"

- The index for the date-time Stored Procedure parameter matches the position in the list from the "Insert Parameter" dialog box beginning at zero for the first item.
- All parameters set with ParameterFields property can be in any order. The indexing is for VB to set aside memory for the parameter. In Crystal Reports the name of the parameter will be used to pass the proper value to the Crystal Report Parameter or Stored Procedure.
e.
The following code passes in null values to a stored procedure that prompts for two parameters.

CrystalReport1.ParameterFields(0) = "crwnull"
CrystalReport1.ParameterFields(1) = "crwnull"
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top