troubleshooting Question

Access: Use comma separated textbox value as filter for query using WHERE (field IN (Forms!formname!textbox))

Avatar of noahisaac
noahisaacFlag for United States of America asked on
Microsoft AccessSQL
5 Comments1 Solution2342 ViewsLast Modified:
Hi -

I have a multiselect listbox that dumps its values out into a textbox in the form of a comma separated list.  The values look like this:

'wv13Ce','Rja3SH','JifFZ1','VR0UHl'

I want to use those values to filter a query, like this:

SELECT * FROM table WHERE (field IN (Forms!myform!textbox))

This is not working, though.  The query returns no results.  If I explicitly state the values in the query, it works as expected, like this:

SELECT * FROM table WHERE (field IN ('wv13Ce','Rja3SH','JifFZ1','VR0UHl'))

I've tried wrapping the form field and its values in double quotes, single quotes, no quotes, but it doesn't seem to matter.  If I'm referencing the value of the form field, the query doesn't work.

I can use VBA to rewrite the SQL of the query, but I'd like to avoid this if possible, as I have dozens of queries that need to do this (and I'm not sure how well this would work on a multi-user db).

Any ideas / suggestions?

Thanks,
Noah
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros