View Full Version : multiple selections from string in criteria


Help.Chris
07-19-2001, 06:14 AM
I have a form with a multiselect list box, this is populating a text box with a criteria so search on in a query. The criteria is formated with or's in it,
ie.

selection1 or selection2 or selection 3

When I reference this text box in query is works with only 1 selection, but multiple brings up no results. I thinks Access is enclosing the string in quotes, so one works, but in multiple selection the quotes are going round the whole string. I have tried using " in the string around each selection but this returns no results at all.

Does anybody have any idea what I can do.

Thanks for any help in advance.

Chris

tzimak
07-19-2001, 11:41 AM
Instead of just putting "or" in between the values, you have to put " [fieldname] = 'selection1' or ". Also, use ' (single quote) in code rather than " (double quote).

So the final result would be something like "Select * from [table] where [fieldname] = 'Red' or [fieldname] = 'Blue';"

T

KDg
07-19-2001, 12:35 PM
Totaly agree with the above, but i always use double quotes " as it saves any potential problems with things like 'o'mahoney'

Drew