Chapter 4 - Selecting Records with Parameters
This chapter first shows you how to filter data using the Select Expert and then shows you how to create advance filters using parameters. Parameters are covered in great detail because they are also used within report formulas and for custom formatting. The effective use of parameters within record selection formulas and custom formatting lets you create dynamic reports that are tailored to each specific user.
This is an excerpt from the book Crystal Reports Encyclopedia.
Click to read more chapter excerpts.
Selecting Records Tutorials
Tutorial 4-1. Selecting Records
Let's put what we learned about selecting records to use. In this tutorial we will set a filter on two fields: Country and Last Year's Sales. For Country we want to select a specific set of countries to print (Canada, England, and USA). For the Last Years Sales field we only want to see records with a sales amount over $50,000.
- Open the Crystal Reports sample report Group.rpt. This report demonstrates grouping data on the Country and Customer Name fields. It shows the previous year's sales by customer and their percentage of the total sales.
- Save the report as "Select Expert Tutorial.rpt".
- Click the menu items Report | Select Expert.
- The Choose Field dialog box opens for you to select the field to filter on. Select the Customer.Country field.
- The Select Expert dialog box opens with the Customer.Country tab shown. For the comparison type, select Is One Of from the dropdown box.
- In the second dropdown box, select each of the following values: Canada, England and USA. This selects all records that are from one of those three countries.
- Create a second filter field by clicking on the
tab and select the field Customer.Last Year's Sales. Click the Ok button to go back to the Select Expert dialog box. - For this field we want all sales that are greater than $25,000. For the condition select Is Greater Than or Equal To. In the second dropdown box type in $25,000.
- To make sure you've entered both conditions properly, click on the Show Formula button in the bottom right hand corner. Compare your formula to the following:
{Customer.Country} in ["USA", "England", "Canada"] and
{Customer.Last Year's Sales} >= $25000.00
- Make any necessary corrections to your formula if there is a mistake.
- Preview the report and it should look like the following. Notice that each sales amount is greater than $25,000.
To read all my books online, click here for the Crystal Reports ebooks.