<< Click to Display Table of Contents >> Navigation: Introduction to Crystal Reports > Developing Own Crystal Reports > 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…
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.
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.).
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.