IIF statement and multiple items

  • Thread starter Thread starter rookie
  • Start date Start date
R

rookie

I have 3 fields (see below) and each of them contains True or False. I was
trying to write a query that combined all of them and output only 1 of the 3
fields. For example, [WFL] = True, [Ab without Asp] = False, and [Ab w/ Asp]
= False. Therefore, the final output on my expression should say "WFL"
because it's True and the rest are false. I attempted to create an expression

[WFL]
[Ab without Asp]
[Ab with Asp]

MBS Findings: IIf([WFL] = "True" or [Ab without Asp] = "True" or [Ab with
Asp] = "True",.....)


I was lost afterwards since I knew i couldn't list 3 items after the
comma...Please help!!

Rookie
 
SWITCH( [wfl], "I used WFL",
[Ab without Asp], "I used Ab alone",
[Ab with Asp], "I used both Ab and Asp",
true, "I used something else, if I used anything")



Vanderghast, Access MVP
 
Hi Vanderghast,
If I'm not mistaken, the Switch function applies to VBA section.
unfortunately, I don't know how to use it. Can I use the switch function in
the expression builder?
If so, how do i write it? I don't get it...

thanks!
Rookie

vanderghast said:
SWITCH( [wfl], "I used WFL",
[Ab without Asp], "I used Ab alone",
[Ab with Asp], "I used both Ab and Asp",
true, "I used something else, if I used anything")



Vanderghast, Access MVP




rookie said:
I have 3 fields (see below) and each of them contains True or False. I was
trying to write a query that combined all of them and output only 1 of the
3
fields. For example, [WFL] = True, [Ab without Asp] = False, and [Ab w/
Asp]
= False. Therefore, the final output on my expression should say "WFL"
because it's True and the rest are false. I attempted to create an
expression

[WFL]
[Ab without Asp]
[Ab with Asp]

MBS Findings: IIf([WFL] = "True" or [Ab without Asp] = "True" or [Ab with
Asp] = "True",.....)


I was lost afterwards since I knew i couldn't list 3 items after the
comma...Please help!!

Rookie
 
Hi Vanderghast,
I did some more research and realized i can use switch in my expression
builder. However, it didn't work! Everything under MBS findings was "Ab
without Asp". What did i do wrong?

MBS Findings: Switch([Ab without Asp]=True,"Ab without Asp",[Ab with
Asp]=True,"Ab with Asp",[WFL]=True,"WFL")

thanks!
Rookie

vanderghast said:
SWITCH( [wfl], "I used WFL",
[Ab without Asp], "I used Ab alone",
[Ab with Asp], "I used both Ab and Asp",
true, "I used something else, if I used anything")



Vanderghast, Access MVP




rookie said:
I have 3 fields (see below) and each of them contains True or False. I was
trying to write a query that combined all of them and output only 1 of the
3
fields. For example, [WFL] = True, [Ab without Asp] = False, and [Ab w/
Asp]
= False. Therefore, the final output on my expression should say "WFL"
because it's True and the rest are false. I attempted to create an
expression

[WFL]
[Ab without Asp]
[Ab with Asp]

MBS Findings: IIf([WFL] = "True" or [Ab without Asp] = "True" or [Ab with
Asp] = "True",.....)


I was lost afterwards since I knew i couldn't list 3 items after the
comma...Please help!!

Rookie
 
Switch returns the first (leftmost) companion for the test which evaluates
to true, so I suspect it is simply the case that [Ab without Asp] is true.
So, even if the other tests are also true, only the companion of the first
test which evaluates to true would ever be returned.

Note that it is useless to test it = true, well, I assumed it is already
Boolean.


Vanderghast, Access MVP


rookie said:
Hi Vanderghast,
I did some more research and realized i can use switch in my expression
builder. However, it didn't work! Everything under MBS findings was "Ab
without Asp". What did i do wrong?

MBS Findings: Switch([Ab without Asp]=True,"Ab without Asp",[Ab with
Asp]=True,"Ab with Asp",[WFL]=True,"WFL")

thanks!
Rookie

vanderghast said:
SWITCH( [wfl], "I used WFL",
[Ab without Asp], "I used Ab alone",
[Ab with Asp], "I used both Ab and Asp",
true, "I used something else, if I used anything")



Vanderghast, Access MVP




rookie said:
I have 3 fields (see below) and each of them contains True or False. I
was
trying to write a query that combined all of them and output only 1 of
the
3
fields. For example, [WFL] = True, [Ab without Asp] = False, and [Ab w/
Asp]
= False. Therefore, the final output on my expression should say "WFL"
because it's True and the rest are false. I attempted to create an
expression

[WFL]
[Ab without Asp]
[Ab with Asp]

MBS Findings: IIf([WFL] = "True" or [Ab without Asp] = "True" or [Ab
with
Asp] = "True",.....)


I was lost afterwards since I knew i couldn't list 3 items after the
comma...Please help!!

Rookie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

#Error in query 4
IIF Function 3
Formula nesting with IF statements 2
Totals Query Help 3
iif statement 4
Problems with IIf() 7
IIF Statements 5
VBA Compare part of cell to another cell and then calculate 0

Back
Top