?
Solved

Crystal Reports 2008 - using a Or statement

Posted on 2012-09-19
12
Medium Priority
?
399 Views
Last Modified: 2012-09-20
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
Comment
Question by:Amour22015
10 Comments
 
LVL 12

Accepted Solution

by:
Jared_S earned 1000 total points
ID: 38415154
try this:

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

Author Comment

by:Amour22015
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

by:Amour22015
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 101

Expert Comment

by:mlmcc
ID: 38415399
Was this part of a larger selection criteria?

mlmcc
0
 

Author Comment

by:Amour22015
ID: 38415420
mlmcc,

Yes some other criteria was involved.

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

thanks
0
 
LVL 1

Expert Comment

by:nicde
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

by:James0628
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

by:Amour22015
ID: 38417540
Thanks
0
 

Author Comment

by:Amour22015
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

by:Amour22015
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"]

Thank you for your help....
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

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…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question