Wednesday, April 16, 2014

Multiple if conditions in a Crystal Reports Record Selection


 When using multiple If statements in a Crystal Reports Record Selection, use parentheses to group your if-then-else statements. These need to be terminated with an Else. If no else exists in your logic, use Else True. Multiple If statements are then separated using an And or Or as seen in the example below:


{TERM} = {?Term} And
{INSTITUTION} = {?Institution} And
(
If ({?Organization} <> "%") Then
    {ACAD_ORG} = {?Organization}
Else True
)
And
(
If ({?Dual Enrollment} = "N") Then
    {HS_DUAL_ENROLL} = "N"
Else If ({?Dual Enrollment} = "Y") Then
    {HS_DUAL_ENROLL} = "Y"
Else True
)