By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,491 Members | 1,868 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,491 IT Pros & Developers. It's quick & easy.

Help with SELECT syntax

P: n/a
I have a bit of code that loops through a listbox and creates a string of
multiple selections and then passes that string to a SQL statement. However,
I cannot seem to get a handle on the proper syntax for the WHERE clause to
properly pass the string in the format of 'X' OR 'Y' to the query's criteria
field. Can someone clarify this syntax or point me to a good example of
using a varible string in the WHERE clause of a SQL statement?
Thanks in advance
Mar 6 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Use the IN operator

The SQL statement will end up something like this:
WHERE MyTextField IN ("X", "Y", "Z")

Here's an example that loops through the ItemsSelected in a multi-select
list box and builds up that kind of string:
Use a multi-select list box to filter a report
at:
http://allenbrowne.com/ser-50.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Terry C." <cl*******@yahoo.com> wrote in message
news:lV******************@southeast.rr.com...
I have a bit of code that loops through a listbox and creates a string of
multiple selections and then passes that string to a SQL statement.
However, I cannot seem to get a handle on the proper syntax for the WHERE
clause to properly pass the string in the format of 'X' OR 'Y' to the
query's criteria field. Can someone clarify this syntax or point me to a
good example of using a varible string in the WHERE clause of a SQL
statement?
Thanks in advance

Mar 7 '06 #2

P: n/a
Br
Terry C. wrote:
I have a bit of code that loops through a listbox and creates a
string of multiple selections and then passes that string to a SQL
statement. However, I cannot seem to get a handle on the proper
syntax for the WHERE clause to properly pass the string in the format
of 'X' OR 'Y' to the query's criteria field. Can someone clarify this
syntax or point me to a good example of using a varible string in the
WHERE clause of a SQL statement? Thanks in advance


How about showing us what you've done so we can see where you've gone wrong?
--
regards,

Br@dley
Mar 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.