Parameter Field in Crystal Report
There are multiple ways of passing parameters to the crystal report. This article focuses on the design time approach to attach parameters.
If you have a Crystal Reports with various product details and you need to display the product details according to Product Id, passing the parameter at runtime, then in these types of situations you can use the Parameter Field in Crystal Reports.
The above report simply displayed all the records from the Products table. This is because we have not yet configured the Select Expression and the Report Parameters. Let us add a parameter to the report. Go to the report, right click and select Field Explorer. This will load the field explorer tab where you can add a parameter to the report. Now, right click on the Parameter Fields and add a new parameter as shown in the screenshot below.
After creating you have to drag the parameter field from the field explorer and drop it into the section details of the crystal report as shown in the screenshot below.
The next step is to add a Record Selection Formula. The record selection formula option is found under the Special Fields option. Right click on the record selection formula and add it to the report. Next, right click on the record selection formula you just added to the report and click on Select Expert.
The next screen shows the filter criteria. We are matching the productID parameter field with the product_id in the Product table.
Select the OK button to close the Select Expert window.
Now, run the application again and you will notice that the page prompts you to enter the parameter field, which in this case is the Product ID.
When the OK button is clicked you will see the results of Product ID.