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
 
M

MGFoster

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

To reference a form you should to use the bang "!" instead of the dot
"." 'cuz you're referring to the form in the Collection of Forms - the
"!" means refer to the object in the collection; "." means refer to the
single Object:

Forms!frmWarehouseSearch!txtBranch

Your last IIf() function should look like this:

IIf(Forms!frmWarehouseSearch!txtBranch=3, "110", "210")

The True and False expressions are separated by a comma not "OR."
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBScGA2YechKqOuFEgEQL9OQCg6Tfgnz8qGn/8jAqFSlJcbkVcVnwAn2pz
fhzWkNGoJXAjRMvONntnZfQZ
=gXvg
-----END PGP SIGNATURE-----
 
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

Top