8.2.2 Filtering Data on ProjectID

<< Click to Display Table of Contents >>

Navigation:  8. Introduction to Crystal Reports > 8.2 Developing Own Crystal Reports >

8.2.2 Filtering Data on ProjectID

Introduction to Crystal Reports > Developing Own Crystal Reports

Each project database can contain several projects. The report will now include data from all projects on the database. To list data from the current project only, it is necessary to insert a filter.

First, we will insert a parameter field to prompt for the current project name. Click Parameter Fields in the Field Explorer with the right mouse button. If the Field Explorer is not present, get it from the View menu.  From the right-click menu, select New…

image56_334

image56_335

In the Create New Parameter window, enter ProjectID (1.) as the name of the parameter.

To add a dynamic list of values to the ProjectID parameter, select Dynamic (2.). You then click the Insert button (3.), and select ProjectID from the dropdown list. In the Parameters column, click on the text Click to create parameter (4.). The text will change to ProjectID.

Click the OK button to close the Create New Parameter window.

Now we are ready to create the data filter. This is done by creating a Record Selection formula. Choose Selection Formulas and then Record… on the Report menu.

In the Report Fields list of the Formula editor, expand the database and the item table. Select the database field ProjectID with the mouse, and drag it into the formula text window.

image56_336

In the formula text window, type the sign of equality (1.) after the text {ITEM.ProjectID}.

Select the parameter named ProjectID (marked with a question mark icon in the list) in the ‘Report Fields’ branch. Drag and drop it to the formula text window (2.).

image56_337

The selection formula should look like this:

{ITEM.ProjectID}={?ProjectID}

Click the Save and close button. The report data will now be filtered to include the selected ProjectID only.