Example: Passing parameters from Crystal
Following is an example of how to create a query in OLE DB Object services that passes a Crystal parameter at runtime.
For this solution to work, you must have the latest weekly hot fixes for Crystal Reports 9, or a higher release of Crystal Reports.
On the OLE DB Object Services side:
- Select fields and other options for a database query. For detailed instructions on how to create a Database query, see Creating database queries.
- Create a filter or index criteria in the OLE DB Query Builder using the
"?" (question mark). Note: You cannot use date fields and some specialized conditional fields would not work.
This screen shot shows how you would specify an index criteria using an index called EMPSET1 for the COMPANY and EMPLOYEE fields. To get to this dialog, click Indexes on the main Database query form.
- When you are finished making specifications, you can exit OLE DB Object Services and return to Crystal Reports.
On the Crystal side:
- You are prompted as the Crystal parameter field, Param1, is created. Do not rename this parameter; this parameter is recreated each time you exit from Query Builder into Crystal Reports.
- Clear the Set parameter to null check box.
- Refresh the report and select Prompt for new parameter values.
- The parameter created by OLE DB Object Services is a string parameter, so
a Crystal string function (such as ToNumber) might be required to convert the string to a
number if used in a selection criteria or other formula.
More than one parameter can be entered into an Index criteria or Filter, which results in Param2, Param3, and so on, in Crystal. This makes a range possible in an index criteria, as in "?->?" creating Param1 and Param2 where Param1 is the starting string (00050) and Param2 is the ending string (1000).