Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

7.18 Advanced Tutorial Introduction

Advanced Tutorials

When using conditional formatting to customize report output, the typical report property uses one of the simple data types to store its value. Many properties use the values True or False to turn them on or off. For example, properties such as Suppress, Italic, and Keep Object Together uses True to enable the property and False to disable the property. But there are certain properties that use pre-defined constants to set their values. You have to be aware of when to use these pre-defined constants so that your formulas return the correct data. Otherwise the Formula Workshop returns an error when you try to save it.

As an example of using the proper data type, Figure 7-6 shows the Section Editor dialog box. All the properties displayed here use checkboxes. These properties are either on or off, and formulas that are associated with these properties have to return True or False. As expected, returning True is the same as a checked box, and returning False is the same as an unchecked box.



Figure 7-6. The section expert window.

As a more varied example, Figure 7-7 shows the Border tab of the Format Editor dialog box. This dialog box not only uses checkboxes, but it uses some new values you haven’t seen yet: line styles and colors.



Figure 7-7. The Format Editor’s border tab.

The values for the line style and color are Crystal Reports predefined constants. The line style property can have values such as crDashedLine, crNoLine, etc. The color property can have values such as crAqua, crYellow, crRed, etc.

There are two ways to determine the predefined constants used with a property. The first and easiest way is when you open the Formula Workshop, it lists all the predefined constants as comments in the code. The following code excerpt is what you see when modifying the Line Style property of the border. It shows you every possible predefined constant that the formula can return.

// This conditional formatting formula must return
//one of the following Line Style Constants:
// crSingleLine
// crDoubleLine
// crDashedLine
// crDottedLine
// crNoLine

A second way of determining the predefined constants for a certain property is to look in the Function Tree. When you open the Formula Editor, the predefined constants for the current property are listed. This list is dynamic and won’t show constants for other properties. For example, if you are modifying a line style property, the Function Tree will show the different line styles, but won’t list any colors. This is illustrated in Figure 7-8.



Figure 7-8. The Function Tree for line styles.

If you are modifying a color property, it will show the available colors, but no line styles. This is illustrated in Figure 7-9.



Figure 7-9. The Function Tree for colors.

If the Function Tree doesn’t list the Color Constants or if the Formula Workshop doesn’t have any constants listed, then use True and False to turn the property on or off.