• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 5. Implementing Parameters for D... > Crystal Reports in the Real World—Cu...

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.

Open the sample report Chap 5 World SalesParm.rpt created earlier in this chapter.

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.13):

If {?Countries} = "*" Then
    {Customer.Country} = {?Countries};

Figure 5.13. The updated Record Selection Formula 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, click the Add button to add the symbol to the list of values, and click OK. You should see something like in Figure 5.14.

Figure 5.14. The report returns all values when * is passed in as a parameter. In this photo the chart has been removed from the report but the group tree clearly shows many countries being returned.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint