Print Page | Close Window

OR statement not working correctly

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=15535
Printed Date: 01 May 2024 at 1:02pm


Topic: OR statement not working correctly
Posted By: MrPozor
Subject: OR statement not working correctly
Date Posted: 03 Feb 2012 at 4:08am
Hi,

I have a problem with an OR statement in Crystal Reports.

Basically I want to get a list of entries where either one of two checkboxes has been ticked.

I put the following into the record select:

{vPerson.pers_ma_1} = "Y" or {vPerson.pers_ma_2} = "Y"

but this does not list entries where ma_1="" and ma_2 ="Y"

If I reverse the formula, i.e.

{vPerson.pers_ma_2} = "Y" or {vPerson.pers_ma_1} = "Y"

I get the opposite, i.e. entries with ma_1="Y" and ma_2 ="" are missing.

Normally, for an OR statement the order of parameters should not matter, right? This is driving me insane!

Thanks for your help,

MrPozor



Replies:
Posted By: rkrowland
Date Posted: 03 Feb 2012 at 5:11am
Hmm that is weird...
 
You could try using a nested if statement rather than or;
 
if {vPerson.pers_ma_1} = "Y" then True else
if {vPerson.pers_ma_2} = "Y" then True else False
 
Though I expect that would give the same results, maybe something to do with null fields but I can't say for certain.
 
Regards,
Ryan.


Posted By: DBlank
Date Posted: 03 Feb 2012 at 5:18am
likely it is NULLs.
if Null is not accounted for in the set up or in the formula it stops evaluating the formula when it hits a null and returns no value for that row.
 
In the formula editor (for your OR formula) set the pick list option to use 'default vaues for nulls'


Posted By: MrPozor
Date Posted: 03 Feb 2012 at 5:24am
You were both right about the NULLs.

Using the 'default vaues for nulls' works perfectly!

Thanks a lot for your help.

Kind regards,

MrPozor



Print Page | Close Window