Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Subreport selection formulas Post Reply Post New Topic
Author Message
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Topic: Subreport selection formulas
     Posted: 08 Jun 2011 at 9:17am
I sent two fields from the main report into a subreport.
The subreport runs a separate query and filters results based on the selection criteria.

It's basically A or B, however the results I get only match those that satisfy condition A.

When I write B or A, it only matches those that satisfy condition B.

Condition A checks whether the argument is in an array (that is created on the spot), while condition B checks equality.

I'm not sure why it only matches one condition and ignores the other.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 08 Jun 2011 at 9:59am
what does the code look like?  seems odd, that it would behave like that.  I am assuming that the value to be tested for equality is in the array as well.
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 08 Jun 2011 at 10:18am
{?param1} in split({field1}) or {?param2} = {field2}

Field1 and field2 are both strings, except field1 has a specific format that I can split on.

Edited by Keikoku - 08 Jun 2011 at 10:18am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 09 Jun 2011 at 10:18am

so {?param1} in split({field1}) or {?param2} = {field2}  give just {?param1} in split({field1})

and {?param2} = {field2} or {?param1} in split({field1}) just gives {?param2} = {field2}
 
How interesting....
 
have you tried the obvious...
({?param1} in split({field1})) or ({?param2} = {field2})
 
nothing else really comes to mind




IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 13 Jun 2011 at 3:11am
Tried that as well.

I tried some simpler conditions like {?param1} = "this" or {?param2} = "that" but even that resulted in the same behavior.

Can't imagine where the problem might be.
When switching the order of the conditions, I get two distinct set of results.

It's possible that my data is not actually what I expect though, but after checking it, doesn't seem to be the case.

EDIT: I decided to print out the boolean value in a formula and it definitely does seem to be checking only the first condition. At least, it doesn't print true when it should when the second condition is met.

Edited by Keikoku - 13 Jun 2011 at 3:43am
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 16 Jun 2011 at 3:29am
Found the problem.
I wasn't checking for null values.

The clue was when I was doing a simple {field} <> ' ' and then only the fields that had a value printed True while the others didn't even print anything.

The proper conditions should be


(not isnull({field1}) and {field1} = ...) or (not isnull({field2}) and {field2} in split(...))


Edited by Keikoku - 16 Jun 2011 at 3:31am
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum