# Crystal Reports 2008 - using a Or statement

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
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
try this:

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

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
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
Author Commented:
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.
Commented:

mlmcc
Author Commented:
mlmcc,

Yes some other criteria was involved.

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

thanks
Commented:
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.
Commented:
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
Author Commented:
Thanks
Author Commented:
mlmcc,

Thanks you for bringing that to my attention.

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

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