Conditional attribute properties

A conditional attribute property tests to see which of two or more conditions is met. The program then applies the formatting appropriate to the condition. For example, assume that you want values under quota printed in red and all other values printed in black. The program tests to see whether the value is under quota or not. If it is under quota, then it applies the red attribute; if it is not, then it applies the black attribute.

Use an If-Then-Else formula for this kind of conditional formatting. For Crystal syntax, see If expressions. Or, for Basic syntax, see If statements.

Crystal syntax example
If Condition A Then
    crRed
Else
    crBlack
Basic syntax example
If Condition A Then
    formula = crRed
Else
    formula = crBlack
End If

When conditional attribute properties are set up, Seagate Crystal Reports loads a selection of attributes into the Functions list in the Formula Editor. Double-click any of these attributes to add them to a formula. For example, if you are setting horizontal alignment conditionally, the Functions list contains attributes such as DefaultHorAligned, LeftAligned, and Justified. If you are setting borders conditionally, the Functions list contains attributes such as NoLine, SingleLine, and DashedLine.

You can take this kind of property one step further. You can specify a list of conditions and a property for each; you are not limited to two conditions. For example, if you have a number field on your report that contains sales figures from countries around the world, you can specify the number attribute(s) that you want to apply to each country. In this case, your conditions would specify that if it is from Country A, the program should apply the Country A attribute; if it is from Country B, the Country B attribute; if it is from Country C, the Country C attribute, and so on.

With more than two alternatives, use this kind of formula:

Crystal syntax example
If Condition A Then
    crRed
Else If Condition B Then
    crBlack
Else If Condition C Then
    crGreen
Else
    crBlue
Basic syntax example
If Condition A Then
    formula = crRed
ElseIf Condition B Then
    formula = crBlack
ElseIf Condition C Then
    formula = crGreen
Else
    formula = crBlue
End If

Use a multi-condition If-Then-Else formula for this kind of conditional formatting.



Seagate Software, Inc.
http://www.seagatesoftware.com
Please send comments to:
techpubs@seagatesoftware.com