- Introduction
- Understanding the Value of Parameters
- Creating and Implementing Parameters Fields
- Using Parameters with Record Selections
- Using Parameters with Top/Bottom N Group Selections
- Creating and Implementing Dynamic and Cascading Parameters
- Troubleshooting
- Crystal Reports in the Real WorldCustom Filtering
Crystal Reports in the Real World—Custom Filtering
Sometimes a report needs to return all records for a parameterized field where a record selection filter has been created on this parameter. Although it would certainly be possible to create a parameter and select all valid values for the parameter, there certainly must be a better way—and there is. In this example, a filter is added to a report so that if a user enters a specific value or a list of values, only those values are returned. Alternatively, if the user enters an asterisk (*, or other predefined symbol such as All Values), all values are returned. The following steps highlight this capability:
- Open the sample report Chap 5.rpt created in the first half of this chapter. Set the Allows Custom Values property to True and Change the Top N sort condition to All in the Group Sorting Expert.
- From the Report menu choose Selection Formulas, Record. Remove the following line of text.
{Customer.Country} = {?Countries}
Replace the text with the following (as shown in Figure 5.15):
(If {?Countries} = "*" Then True Else {Customer.Country} = {?Countries};)
Figure 5.15 The updated Record Selection Formula Editor enables the end user to select All Values with one easy selection.
Click Save and Close.
When prompted for a new parameter value, remove any existing values, enter the * symbol as a manual custom entry, click the Add (>) button to add the symbol to the list of values, and click OK. You should see something like in Figure 5.16.
Figure 5.16 The report returns all values when * is passed in as a parameter. In this photo, the chart has been edited slightly from the original report but you can clearly see that all countries were returned.