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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Select Box

Status
Not open for further replies.

secondreckoned

Technical User
Jan 20, 2004
35
CA
Hi,
I have a Multiple Select Box that displays a list of 'keywords'. I would like the user to be able to select one or more keywords from the list. Once the user hits the submit button I want to return a list of documents associated with the keywords. ie,

'from multiple select list in form
var request.form("keyword")
Set keywordRS = ("Select * From tb_Categories Where Categoryname = 'keyword1' or Categoryname = 'keyword2' or Categoryname = 'keyword3'")

The problem I'm having is the string that is returned from the request.form separates the multiple Categories with comma's ie, cat1, cat2, cat3, cat4 etc...

How would I take that string and separate it into separate words to work it into my recordset sql select statement?

appreciate any help...
 
You should change your query to...

Select * From tb_Categories Where Categoryname In ('keyword1','keyword2','keyword3')

So, in the request.form object, replace comma with apostrophe comma apostrophe

[tt][blue]
SQL = "Select * From tb_Categories Where Categoryname In ('" + Replace(Request.Form("KeyWord"), ",", "','") + "')"
[/blue][/tt]


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Just a slight problem as I see it. This may improve gmmastros posted solution so that it performs.
[tt]
SQL = "Select * From tb_Categories Where Categoryname In ('" + Replace(Request.Form("KeyWord"), ",[highlight] [/highlight]", "','") + "')"
[/tt]
Alternatively, you can also construct the line from request.form("keyword") collection which is one-based.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top