Link to home
Start Free TrialLog in
Avatar of camco
camco

asked on

IIf statment with two variables

I am trying to get this to work but it always shows NO

=IIf([Text17]="NIKON COOLPIX 2 YEAR WARR" OR "NIKON COOLPIX 3 YEAR WARR","YES","NO")

Thanks for the help!
Ward
ASKER CERTIFIED SOLUTION
Avatar of med39
med39

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Harisha M G
Hi camco,
=IIf([Text17]="NIKON COOLPIX 2 YEAR WARR" OR [text17] ="NIKON COOLPIX 3 YEAR WARR","YES","NO")


Bye
---
Harish
med39,
    You are very fast !!

camco,
    You can use "And", "Or" and "Not" operators to logically join more than one conditions :)
could also be done like this:

=IIf([Text17]="NIKON COOLPIX 2 YEAR WARR", "YES",IIF([Text17] = "NIKON COOLPIX 3 YEAR WARR","YES","NO"))

using nested IIF() function calls.

AW
Avatar of EricJamesOlson
EricJamesOlson

how about using a string compare function instead.  

IIF((StrComp([Text17],"NIKON COOLPIX 2 YEAR WARR") = 0) OR (StrComp([Text17],"NIKON COOLPIX 3 YEAR WARR") = 0),"YES,"NO")

and another suggestion, use the entire Text17 name, referencing forms collection and form name,   (ie. [Forms]![frmMyFORM]![Text17])  
Avatar of camco

ASKER

Wow that was fast! Thanks for the help.

Ward
camco, you should have selected the first comment as the answer or should have split the points
Harish,

Thanks for your fairness.  I appreciate it.

-med39
Or did you select mine as the answer because of the next comment?
med39, please post a question in CS to select your comment as the answer or to split.
Avatar of camco

ASKER

I just screwed up. Sorry!

Ward
Harish,

Re: "please post a question in CS to select your comment as the answer or to split".  I don't know what this means.

-m
Harish,

Thanks again.  You have my respect.

-m
Avatar of camco

ASKER

Sorry that I caused so much trouble.

Ward
Thanks Lunchy,

Cheers med39!