Pass multiparameter 'or' to a Query

X

xavier

I'm realativly new with databases and Access. How do I
pass multiple items to an Access query i.e. city
= "Chicago" or "New York". I can pass single parameters
OK but having trouble with more than one.
 
M

Michel Walsh

Hi,



In the SQL view, the criteria could look like:

WHERE ( "," & param & ",") LIKE "*[ ,]" & FieldName & "[, ]*"


and, to enter the parameter, param, the end user supply the values, separated by coma (or space):

Chicago, NewYork

Note that since the space is used as possible delimiter, it must NOT be part of a the name you are
looking for. If you want use another delimiter, say, /, then



WHERE ( "/" & param & "/") LIKE "*/" & FieldName & "/*"


and the, enter Chicago/New York


(no space immediately after the / ).



If the list is large, or if the table you look into is large, it is preferable to put the name
into a table of their own, then, make an inner join between the two tables.




Hoping it may help,
Vanderghast, Access MVP
 

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