This documentation is archived and is not being maintained.

Conditional Formatting Functions (Crystal Syntax)

Visual Studio 2005

When writing a conditional formatting formula, certain additional functions appear at the top of the Functions tree to help you with this. For example, you can format the {Customer.Last Year's Sales} field to print sales of more than $100,000 in green, sales of less than $15,000 in red, and all other sales in black.


//Conditional formatting example 1
If {Customer.Last Year's Sales} > 100000 Then
Else If {Customer.Last Year's Sales} < 15000 Then

Since this is a font color formatting function, the list of Color Constants appears in the Functions Tree. This example uses three: crGreen, crRed and crBlack. You could have used the actual numeric values of the color constants instead. For example, crRed is 255 and crGreen is 32768. However, the formula is more understandable using the color constants. All constant functions in Crystal syntax can have the "cr" prefix.

Crystal syntax still supports constant functions from previous versions without the "cr" prefix. For example, you can use "Red" instead of "crRed". However, using the "cr" prefix organizes constant functions and is recommended.

Note   Some formatting attributes do not use constant functions. For example, if you wanted to not print {Customer.Last Year's Sales} values if the sales were less than $50,000, you could write the following conditional formatting formula for the suppress attribute:
//Conditional formatting example 2
If {Customer.Last Year's Sales} < 50000 Then
   True //suppress the value
   False //do not suppress the value

Or more simply:

//Conditional formatting example 3 -
//equivalent to example 2
{Customer.Last Year's Sales} < 50000

If the last year's sales are less than $50,000, then the expression

{Customer.Last Year's Sales} < 50000

is True, and so the formula returns True. On the other hand, if the last year's sales are greater than or equal to $50,000, then

{Customer.Last Year's Sales} < 50000

is False and so the formula returns False.

See Also

Performing Report Calculations | Conditional Formatting