Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Value in Textbox feeds criteria field in query 1

Status
Not open for further replies.

foundryqa

Technical User
Oct 17, 2001
162
US
I am trying to use the value property of a textbox as the criteria for a query. I have verified that the criteria field is being filled from the textbox and the system works well when the value in the textbox is "57" or "103", but when the value is "57 or 93 or 105" then the query returns nothing. If I type "57 or 93 or 105" directly into the criteria field of the query then it returns all of the appropriate records. I have tried all sorts of different combinations of quotation marks and the like and have come up with nothing. I used the information from thread702-96918 to get me this far, but am in need of further help.

Thank you in advance.
 
That won't work, because Access is trying to find a match for a literal "57 or 93 or 105". I think you are going to have to parse the string and build your query so that it is searching like so:

WHERE MyValue = "57" OR
MyValue = "93" OR
MyValue = "105"
Terry M. Hoey
 
Thanks Terry, that makes sense. I have parsed strings in the past, but am unsure of where to put this "where" clause. I thought all evening about your response and am unsure of how to work it into my app. I have a multiselect listbox that is filled from a query. I would like the user to make his selections and then requery with only those selections. I read an approach to accomplishing this would be to iterate throught the selecteditems collection and build a string that read "57 or 92 or 108". From there it said to assign the string to a hidden textbox on the form and then possibly feed the value of the control to the criteria field of the query. As you already pointed out this approach does not work because access takes the string as literal. Maybe the whole approach is inappropriate for the task. Do you have any broader suggestions on the approach for creating a query from a multiselect listbox?

Thanks again.
Fred
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top