Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

4.29 Tutorial 4-5. Creating DCPs

Tutorial 4-5. Creating DCPs

The previous tutorials in this chapter have focused on different ways to modify the Group.rpt sample report and customize it with parameters. This tutorial is no different. It builds on the other tutorials by showing you how to use DCPs to create the same parameters and demonstrates how it makes them more user friendly.

The previous tutorials created a parameter for the fields Country and Customer ID. They used the database tables to build a static list of values that the user chose from. The downside to doing it this way is that the list of customers to pick from was quite large. Even though the user could only choose to print the customers from either the USA or Canada, they still had to scroll through every customer in the database even if that customer was located in a different country.

We’re going to modify the report requirements to illustrate the usage of DCPs. The report will now let the user print the report for one or more customers and the user will narrow down the list of customers to pick from by first picking the Country. Once they pick the Country, then only the customers located in that country will be displayed.

  1. Open the Crystal Reports sample report Group.rpt. Save it as Tutorial DCPs.rpt.
  2. Right-click on the Parameter Fields list and select New.
  3. Enter the parameter name Customers to print.
  4. Select the Dynamic option.
  5. For the Prompt Group Text type in Select the customers to print.
  6. Click on the Insert button and select the Country field. Leave the Description and Parameters column alone because they aren’t needed.
  7. We want to let the user enter customers from more than one country. In the Options, set the option Allow Multiple Values to True.
  8. For the second field select Customer ID and for the description field select Customer Name. Click on the Parameters column so that a parameter is created for this field.
  9. We want to let the user print multiple customers as well. In the Options box, set the option Allow Multiple Values to True.
  10. At this point, two prompts have been created and the final prompt saves the Customer ID field to the parameter. Click the OK button to save the parameter.
  11. Now we want to set the record selection formula so that it filters on the Customer Id parameter. Select the menu items Report | Select Expert.
  12. When the Choose Field dialog box opens, select the Customer.Customer ID field and click the OK button.
  13. For the selection criteria choose Is Equal To.
  14. For the field to match to, choose the parameter {?Customers – Customer ID}.
  15. Click the OK button to save your changes. The Enter Values parameter will automatically open. It should look similar to the following figure.


The first prompt lets you select multiple countries. As you choose each country, the Customer list changes to reflect which customers are in that country. Choose as many customers as you wish to print and click the OK button. Your report is updated to reflect the customers you picked.