View Full Version : Select query depending on 3 different text boxes


kc1
02-11-2010, 01:51 PM
Hi All Access Gurus

Got an issue with what I thought would be a simple select query.
On a form called frmMain, there are 3 text boxes that each contain a number.
The query is a group by and sum.
I want to only select the records that don't equal what is in any of the text boxes.
In the criteria I am putting the following:
<>[forms]![frmMain]![textbox1] or [forms]![frmMain]![textbox2] or [forms]![frmMain]![textbox3]
this does not work, however, if I enter the actual numbers in the criteria i.e <>"1" or "2" or "3" it works

I am stumped!

Please help

best regards

KC

SOS
02-11-2010, 01:53 PM
The criteria should actually be AND:

<>[forms]![frmMain]![textbox1] AND <> [forms]![frmMain]![textbox2] AND <> [forms]![frmMain]![textbox3]

And you need the extra <> before each part.

kc1
02-11-2010, 02:00 PM
Thanks

I will give it a go tomorrow.

So why did it work with OR when I actually entered the numbers?

vbaInet
02-11-2010, 02:02 PM
Another suggestion:

NOT IN ([forms]![frmMain]![textbox1], [forms]![frmMain]![textbox2], [forms]![frmMain]![textbox3])

SOS
02-11-2010, 02:05 PM
So why did it work with OR when I actually entered the numbers?
I'm thinking that it really didn't work like you thought it did, but due to whatever data you had it APPEARED to work. But it really shouldn't have either because an OR will let the other numbers come through.