Reputation: 184
I am trying to add a very simple suppression formula to my Crystal Report (XI) field but it is not working as expected.
I would like a text box to be visible if certain conditions are met, otherwise suppress. With the suppress box ticked my current formula is below:
{table1.field1} = "V1" or
{table1.field2} <> "V2" or
PageNumber > 1
If any combination of 1, 2 or all 3 of the conditions are met then display the text (neither field1
nor field2
ever return null
).
However Crystal Reports is only evaluating the first line of the formula; if field1 = V2
then the field does not show.
Any assistance would be most appreciated.
Upvotes: 4
Views: 77114
Reputation: 9101
Its a bit confusing but try below way...
if you are trying to meet all 3 conditions then you need to write that first because if any of the one condition is met first then control will never reach to statisying all 3 conditions
and after that your regular conditions to satisy each one.
so your formula would be:
If
({table1.field1} = "V1" and
{table1.field2} <> "V2" and
PageNumber > 1)
then false //don't Supress when all are met
else if {table1.field1} = "V1"
Then false //field1 is met so don't supress
else if {table1.field2} <> "V2"
then false //field2 is met don't supress
else if PageNumber > 1
then false //3rd condition is met don't supress
else true //Supress anything as all conditions were failed
Upvotes: 11
Reputation: 7287
Suppression formulas work by suppressing the object when it evaluates to true
and not the other way around. In other words, you need to negate your entire formula.
not(
{table1.field1} = "V1" or
{table1.field2} <> "V2" or
PageNumber > 1
)
becomes, via De Morgan's Law
not({table1.field1} = "V1") and
not({table1.field2} <> "V2") and
not(PageNumber > 1)
which can then be simplified to:
{table1.field1}<>"V1" and
{table1.field2="V2" and
PageNumber = 1
Upvotes: 5
Reputation: 9
Try this If you just want to supress at the filed level-keep it at filed level; if you wanna supress the whole section- put this in section level.
IF ({table1.field1} = "V1" OR {table1.field2} <> "V2" OR PageNumber > 1) THEN FALSE ELSE TRUE
Upvotes: -1