Full Version: More Than 2 Possible Outcomes For An Iif Statement
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
rcbarrieault
Good Morning,

I have an IIF statement in my basic query to return an answer in a report for me. This gives me the ability to have a this or that answer. However, I have three items listed in that field. Right now my line reads:

Funddoc: iif([document]="Yes","Contract","Not Contract")

But I have in that field these possible answers:
Yes
No
Unspecified

How do I get the above statement to stop returning "Not Contract" when the answer is "Unspecified"?

I want "Yes" to answer "Contract".
I want "No" to answer "Not Contract".
I want "Unspecified" to just answer "Unspecified".

Thanks
lemunk
hi im Not a great Access user but i know how to code, sounds like u could use a nested IF,

Funddoc:iif([document] = "yes", "contract" , iif([document] = "no" , "no Contract", "unspec"))

reads like, IF the doc = yes then say contract, else IF doc says No then say no contract, else just say Unspec

Hope this helps
accesshawaii
You can do something like this.

TheResponse: IIf([document]="Yes","Contract",IIf([document]="No","Not Contract",IIf([document]="Unspecified","Unspecified",[document])))

This would cover all your bases for your 3 criteria. In the event that the field is none of those values then just the actual field value would be displayed.
rcbarrieault
Awesome guys. I just wasn't sure if I could do the nesting. Never tried. Thanks for your help, it's working.
accesshawaii
Glad you got it working.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.