Passing MultiSelect ListBox string items to a parameter query

  • Thread starter Thread starter FrancisC
  • Start date Start date
F

FrancisC

Good day,

I'm designing a Select query by form (QBF) in which users
can select several string-type items ('OR') from Listboxes
so that they can generate datasets that are intersection
('AND') combinations of theses various Listboxes.

So far, I've been able to work out the datasets generated
by individual selection from each listbox, but to group
several strings I need to somehow insert " OR " (quotes
included) into the resulting string that will be passed to
my queries' expression. I tried with apostrophes as in:

strList = string1' OR 'string2' OR 'string3

but I guess as this passed to the query's criteria field,
quotes are added before and after the concatenated string
and Access takes it as one string, not three.

There is probably a very simple solution to this,

If you have any suggestions, please let me know

Francis
 
Thanks Sandra,

That's the general direction I was heading but I needed
your nudge...

Much appreciated,

Francis
-----Original Message-----
Hi Francis,

You can't use a parameter to pass in a list of items this way (it would be
nice if you could). Instead, you can build the entire SQL string using VBA.
Here's an article that shows you how:

http://www.mvps.org/access/forms/frm0007.htm


--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Good day,

I'm designing a Select query by form (QBF) in which users
can select several string-type items ('OR') from Listboxes
so that they can generate datasets that are intersection
('AND') combinations of theses various Listboxes.

So far, I've been able to work out the datasets generated
by individual selection from each listbox, but to group
several strings I need to somehow insert " OR " (quotes
included) into the resulting string that will be passed to
my queries' expression. I tried with apostrophes as in:

strList = string1' OR 'string2' OR 'string3

but I guess as this passed to the query's criteria field,
quotes are added before and after the concatenated string
and Access takes it as one string, not three.

There is probably a very simple solution to this,

If you have any suggestions, please let me know

Francis


.
 
Back
Top