multiple selections from string in criteria (1 Viewer)

Help.Chris

Registered User.
Local time
Today, 23:41
Joined
Oct 11, 2000
Messages
43
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

New member
Local time
Today, 23:41
Joined
Jul 19, 2001
Messages
5
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
where [fieldname] = 'Red' or [fieldname] = 'Blue';"

T
 

KDg

Registered User.
Local time
Today, 23:41
Joined
Oct 28, 1999
Messages
181
Totaly agree with the above, but i always use double quotes " as it saves any potential problems with things like 'o'mahoney'

Drew
 

Users who are viewing this thread

Top Bottom