Query with Picklist Crieteria - Part 2

E

Eric

OK - I've followed the instructions earlier to create unbound combo boxs that
show the crieteria I want. I'm also able to select several items from these
lists and save it to a text box.

Question: How to I get Multi-Select Values to appear as Query Crieteria?

I can get the query to work if one item is select but not several.

e.g. Part = 1234 (this works), Part = 1234 or 5678 (doesn't work)
 
D

Duane Hookom

Your criteria would need to resolve like:
Part IN ( 1234, 5678 )
Or
(Part =1234 Or Part = 5678)

This will not work for multiple values:
Part IN ( Forms!frmSelect!txtMultipleParts )
 
M

MGFoster

Eric said:
OK - I've followed the instructions earlier to create unbound combo boxs that
show the crieteria I want. I'm also able to select several items from these
lists and save it to a text box.

Question: How to I get Multi-Select Values to appear as Query Crieteria?

I can get the query to work if one item is select but not several.

e.g. Part = 1234 (this works), Part = 1234 or 5678 (doesn't work)

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

If you have the items separated by some delimiter, like a comma, you can
use the InStr() trick:

WHERE InStr("," & Forms!FormName!TextBoxWithCSVstring & ",", "," &
column_name & ",")>0

What this does is for every value in "column_name" it will search the
comma-separated variables in the TextBox "TextBoxWithCSVstring." If one
of the column values equals one of the variables in the TextBox, InStr()
returns a value greater than zero (>0) and the record is selected.

To see how it works put the following in the Debug Window (Ctrl-G):

? instr("," & "hi,there,you" & ",", "," & "you" & ",")

It should return 10. Notice there aren't any spaces between the words
and the commas! If you include spaces it won't work.

If you set it up like this:

? instr("," & "hi,there,you" & ",", "," & "you" & ",")>0

It should return True. A True return in the WHERE clause means select
the record (if it also complies w/ the other criteria).

HTH,
--
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/AwUBSiiDDIechKqOuFEgEQKLIwCfcqjOBbftMyl9oiD4Gqil1mZ+0NUAn0gt
Q8skGnRefx+HH/ebj9pn4KbD
=UrTL
-----END PGP SIGNATURE-----
 

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