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

  • Thread starter Thread starter Chuck M
  • Start date Start date
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.
 
WHERE [CompanyId] = [Enter Company ID] And [Initials] Like IIF([Enter Company
ID] = 2, "AAA", "*")
 
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.
 
Back
Top