Pass multiparameter 'or' to a Query

  • Thread starter Thread starter xavier
  • Start date Start date
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.
 
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
 
Back
Top