cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Report ignoring third condition in if statment

0 Kudos
258

I have three conditions on a field font to change colour but for some reason it ignores the third condition to change the font colour and if I put the bottom condition at top in the if statement then it works so surely its not handling 3rd condition in the if statement, does any one know a workaround for this issue please?.

IF {days} = 'day1'

OR {day1} = 'day2'

OR {day5} = 'day5' THEN crRed ELSE crBlack

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

If CR runs into a NULL value in the database it will stop processing the formula so add if not isnull to the logic and see if that works

DellSC
Active Contributor
0 Kudos

Try this:

If {days} in ["Day1","Day2","Day5"] then crRed else crBlack

-Dell

0 Kudos

Thanks for the reply, this still doesnt work sorry I forgot to mention Day2 and Day5 values are called from different fields. What would be the best way to write IF NOT IN?

DellSC
Active Contributor
0 Kudos

Ahhh.... I think I know what's happening. Is it possible that the day5 value is null? If so, try this:

IF {days} = 'day1' OR {day1} = 'day2'
  OR (not IsNull({day5}) AND {day5} = 'day5') THEN crRed ELSE crBlack

-Dell

0 Kudos

thank you so much for taking time to get back on this.

Unfortunately still the same. If I move the day5 statement at the top it works but if I move it at the bottom it stopped working :(.

DellSC
Active Contributor
0 Kudos

So, you might have nulls in other fields. Try this:

IF (not IsNull({days}} AND {days} = 'day1')
OR (not IsNull({day1} AND {day1} = 'day2')
OR (not IsNull({day5}) AND {day5} = 'day5') THEN crRed ELSE crBlack

Please note that you MUST use the parentheses as I've laid them out here - it won't work without them.

-Dell