Solved

# Crystal Reports 2008 - using a Or statement

Posted on 2012-09-19
Medium Priority
399 Views
Hi and thanks

I want a formula that checks for 2 conditions on one field

Example:
{field1} = "1" Or "2"
{field1} = "1 Or 2"

I tried above but got errors

thanks
0
Question by:Amour22015

LVL 12

Accepted Solution

Jared_S earned 1000 total points
ID: 38415154
try this:

{field1} = "1" Or {field1} = "2"
0

Author Comment

ID: 38415178
I tried:
{field1} = "1" Or {field1} = "2"

but received a lot of records so something is wrong with that formula

maybe:
({field1} = "1" Or {field1} = "2")

I am going to try that also...

Thanks
0

Author Comment

ID: 38415190
when I tried:
({field1} = "1" Or {field1} = "2")
Crystal reports converted it to:
{TEMP_PWC_Sales_Report_SP_MAIN.mclassextension_code} in ["100", "200"]

maybe it is now correct.
0

LVL 101

Expert Comment

ID: 38415399

mlmcc
0

Author Comment

ID: 38415420
mlmcc,

Yes some other criteria was involved.

{field1} and
{field2} and
{field3} and
{so on}

thanks
0

LVL 1

Expert Comment

ID: 38415472
in order to combine AND and OR operators you should separate them in groups with brackets: A=B AND (C=D OR D=E)

with the brackets the result will return all records with A=B and at least one of the other 2 C=D OR D=E
without the brackets  the result will be all records with A=B AND C=D + all records with D=E which is wrong

({field1} = "1" Or {field1} = "2") is the correct way to handle this.
Crystal will change your records selection formula to convert the Crystal Syntax to your database syntax if it is possible to apply the where clause on the server.
0

LVL 35

Expert Comment

ID: 38416776
Not much to add.  It looks like you've got this pretty well covered.  But, FWIW, you could also use

{field1} in [ "1", "2" ]

It's just another way to say the same thing.

CR does not support the (A = B or C or D) type syntax.  You have to spell it out like (A = B or A = C or A = D), or use something else, like A in [ B, C, D ].

James
0

Author Comment

ID: 38417540
Thanks
0

Author Comment

ID: 38417734
mlmcc,

Thanks you for bringing that to my attention.

How can I reopen the question? or is it you that can do that?

Thanks
0

Author Closing Comment

ID: 38418258
when I tried:
({field1} = "1" Or {field1} = "2")
Crystal reports converted it to:
{TEMP_PWC_Sales_Report_SP_MAIN.mclassextension_code} in ["100", "200"]

0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to increase the row limit in Jasper Server.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Please read the paragraph below before following the instructions in the video ā there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, ā¦
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery procedā¦
###### Suggested Courses
Course of the Month15 days, 5 hours left to enroll