Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

5.03 Adding and Editing Formulas

Adding and Editing Formulas

Formulas are used by many parts of a report. You can create formulas from scratch and display their results directly on the page. You can attach reports to different properties of a report object so that the property can be conditionally turned on or off. Crystal Reports also filters report data using the record selection formula. But the method that you will probably use most frequently is the within Field Explorer window in design mode (see Figure 5-1).



Figure 5-1. Field Explorer window.

Within the Field Explorer is the Formula Fields category. By clicking on the plus sign next to it you can see all the formula fields in the report. To add a new formula, right-click on the category name and select the New menu option. Enter a formula name and click the OK button to open the Formula Workshop dialog box (discussed in the next section).

To edit an existing formula, right-click on the formula name and select Edit. If you with to delete the formula, right-click on it and select Delete. However, don’t delete a formula that has a checkmark on it because it is being used on the report. Delete it from the report prior to deleting it from the Field Explorer Window.

Crystal Reports XI R2 has some great new features for working with formulas in a report. To edit a formula, simply double-click on it. This automatically opens it in the Formula Workshop. I think it’s great that they added this feature because I’ve seen it in other programs and always wished we had it in Crystal Reports. This also works for editing SQL Expressions, Running Totals, and Parameters.

If you need to create a new formula that is similar to an existing formula, right-click on the existing formula and select Duplicate Formula. This makes a copy of the formula for you.

Sometimes it can be difficult to figure out which formula a field is being used in. In a complex report, there can be too many formulas to figure out which ones use a certain field. With Crystal Reports XI R2, you can right-click on any field and select Find In Formula and it opens the Formula Workshop dialog box. At the bottom is a search result list of all the formulas that use that field. Double-click each formula to edit it.