Query Parameter

H

Harmony

I am working on a query that pulls its criteria from an
unbound field on a form. I would like it to recognize more
than one entry. For example, if the unbound text box
contains '1 OR 2', I want it to show all records with 1 OR
2 in that field. This doesn't work. I enter that exact
thing into the query criteria directly or if I only entry
one item into the unbound text box, it works.

Any ideas?

Thanks!

Harmony
 
M

[MVP] S.Clark

In a query, to find a field with a 1 or a 2, you would put:

WHERE field = 1 or field = 2

What you think is working, isn't.

You can present the user a MultiSelect List box, step through it's
itemsselected collection, and create an IN Clause.

WHERE field IN ("1","2")

--
HTH,

Steve Clark, Access MVP
FMS, Inc.
Professional Solutions Group
http://www.FMSInc.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Is your Access database too slow?
Are you ready to upgrade to SQL Server?
Contact us for optimization and/or upsizing!
http://www.FMSInc.com/consulting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
H

Harmony

Thanks Steve,

I do have a multiselect List box and then using an event
procedure the items seleced populate an unbound textbox. I
am then pointing that textbox to my query by using forms!
form1!textbox in the criteria of the field I am trying to
filter. I tried to change this to an IN clause as you
suggested and am still getting no returned records. It
seems not to recognize more than one field entry in the
textbox no matter what I do. Do you have any other
suggestions on how I could get the fields selected from my
list box into my where clause in the Access query?

Thanks for your help,

Harmony
 

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