Crystal reports suppression formula with multiple OR operators not working

pwlm picture pwlm · Mar 5, 2015 · Viewed 65.2k times · Source

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.

Answer

Siva picture Siva · Mar 6, 2015

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