Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIf Statement

Status
Not open for further replies.

valterduarte

Technical User
Nov 25, 2005
15
PT
Hello!

I have a problem with an IIF Statement in a query, that I would like to ask for help solving it:

I have something like this:

Table A:
Field AX:
A1
A2
A3

Table B:
Field BX:
B1
B2
B3

I have a form-based query. I have a list box in the FORMX with option1 and option2. One of the criterias in this query is supposed to return all records similar to Field AX when option1 is selected and all records similar do Field BX when option2 is selected.

The code in this criteria looks like this:

IIF(([Forms]![FORMX]![List Box]=option1);
In (SELECT [Field AX] FROM [Table A]);
In (SELECT [Field BX] FROM [Table B]))

What am I doing wrong?

Thank you!
 
Perhaps something like this:
(In (SELECT [Field AX] FROM [Table A]) AND [Forms]![FORMX]![List Box]=option1) OR (In (SELECT [Field BX] FROM [Table B]) AND [Forms]![FORMX]![List Box]=option2)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top