Crystal Reports for Eclipse Designer Guide

Conditional formatting functions (Crystal syntax)

To write a conditional formatting formula, right-click the report area or field the formula will affect and click Conditional Formulas. Select the condition and enter the conditional formula on the Formulas page. For example, you can format the {Customer.LAST_YEARS_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.
Example
//Conditional formatting example 1
If {Customer.Last Year's Sales} > 100000 Then
   crGreen
Else If {Customer.Last Year's Sales} < 15000 Then
   crRed
Else
   crBlack
Since this is a font color formatting function, the list of Color Constants appears as a commented list on the Formulas page. 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_YEARS_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
Else
   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.



SAP BusinessObjects
http://www.sap.com/sapbusinessobjects/
Support services
http://service.sap.com/bosap-support/
Product Documentation on the Web
http://help.sap.com/