More than one criteria value in a query

C

Chris

Hello everyone,

I know I must be missing something simple but I'm trying to add criteria
conditions to a query from a form and I can't seem to get it to work. Below
is my criteria line from my query.

IIf([Forms].[frmWarehouseSearch].[txtBranch]=1,"
110",IIf([Forms].[frmWarehouseSearch].[txtBranch]=2,"
210",IIf([Forms].[frmWarehouseSearch].[txtBranch]=3, " 110" Or "
210"))

My first two iif statements work great and I get the results that I want.
However, when the third condition is true it returns nothing. I know it has
something to do with the dual condition. Can someone tell me how to get
this third condition to work? There has to be a way to insert two values
for the criteria of a query using code. If I were to just type 110 or 210
in the criteria line it would work and bring back all 110 and 210 records.
Any assistance would be great.

Chris
 
K

KARL DEWEY

A couple of things - why do you have leading space before 110 and 210?

In you third condition the 'Or' will be treated as text and not a logical
function. So you got to double up.

IIf([Forms].[frmWarehouseSearch].[txtBranch]=1,"110",IIf([Forms].[frmWarehouseSearch].[txtBranch]=2,"210",IIf([Forms].[frmWarehouseSearch].[txtBranch]=3,
"110", "ERROR"))) OR
IIf([Forms].[frmWarehouseSearch].[txtBranch]=1,"110",IIf([Forms].[frmWarehouseSearch].[txtBranch]=2,"210",IIf([Forms].[frmWarehouseSearch].[txtBranch]=3,
"210", "ERROR")))

You do not have a result for the third condition FALSE. I put 'ERROR' for
that result.
 

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