Tutorial: Filtering Data Using Selection Formulas: Introduction

Selection formulas are used to filter records that you want to display on a Crystal report. To write selection formulas, you can use the Basic syntax or the Crystal syntax.

In this tutorial, you create a selection formula to filter customer records where the Last Year's Sales field is greater than a specific value, and the Customer Name field is compared to another string. A DropDownList (Web) or ComboBox (Windows) control selects a comparison operator for the Customer Name field. You can choose to display customer names that are equal to, less than, greater than, less than or equal to, greater than or equal to, or not equal to the string value that you have specified.

The formula is passed as a string variable to the SelectionFormula property of the CrystalReportViewer class. Once the property is set, the Crystal report that binds to the CrystalReportViewer control is filtered before it is displayed.

This tutorial can also be completed with classes of the CrystalReportViewer object model, although the ReportDocument object model is preferred. For more information on which object model to use, see Which Object Model Should I Use?.

Continue to Creating a Report.