Can I use OR in the THEN or ELSE portion of an IIF statement?

C

Chuck M

Hi, I have a parameter query that prompts for a CompanyId. That value can be
either 1 or 2. I have a field called Initials that I want to filter on based
on the value of CompanyId. If CompanyId = 2 the I want to return the
Initials 'AAA'. If the value of CompanyId = 1 then I want to return Initials
'BBB' and 'CCC'. The only Initals in the table are 'AAA', 'BBB' and 'CCC'.

Can someone help me with the IIF statement for this or another solution if
IIf is not the answer? The IIf statements I've come up with so far have not
been valid.
 
K

KARL DEWEY

WHERE [CompanyId] = [Enter Company ID] And [Initials] Like IIF([Enter Company
ID] = 2, "AAA", "*")
 
C

Chuck M

Works great! Thanks Karl.
--

Chuck M.


KARL DEWEY said:
WHERE [CompanyId] = [Enter Company ID] And [Initials] Like IIF([Enter Company
ID] = 2, "AAA", "*")

--
KARL DEWEY
Build a little - Test a little


Chuck M said:
Hi, I have a parameter query that prompts for a CompanyId. That value can be
either 1 or 2. I have a field called Initials that I want to filter on based
on the value of CompanyId. If CompanyId = 2 the I want to return the
Initials 'AAA'. If the value of CompanyId = 1 then I want to return Initials
'BBB' and 'CCC'. The only Initals in the table are 'AAA', 'BBB' and 'CCC'.

Can someone help me with the IIF statement for this or another solution if
IIf is not the answer? The IIf statements I've come up with so far have not
been valid.
 

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


Top