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

Looping through querystring??

Status
Not open for further replies.

humbleprogrammer

Programmer
Oct 30, 2002
315
US
Hi,

I have a list box of values that the user can choose multiple values from. When the form posts with the "Get" method to the query page the querystring displays the list box value for each selection like following:
AllReports.asp?Project_Auto_Entity=GMC+1-Ton+Truck&Project_Auto_Entity=Jeep+Grand+Cherokee

I am trying to use the Project_Auto_Entity values to query the database. Is there a way I can loop through this querystring, grab the 1st Project_Auto_Entity, query the DB and then grab the 2nd Project_Auto_Entity and query the DB? Any suggestion are greatly appreciated.

Thanks!
 
You'll need to split the querystring, because you are calling all your querystring vars the same so the server concantenates(spelling?) them with a ", " IE

Request.QueryString("Project_Auto_Entity") will be set too GMC+1-Ton+Truck, Jeep+Grand+Cherokee

aryAuto = Split(Request.ServerVariables("QUERY_STRING"), ", ")

**NOTE use Request.QueryString("Project_Auto_Entity") if you are using other vars in the querystring

Then use
For i = 0 to Ubound(aryAuto)
strSQL = "SELECT * FROM TABLE WHERE FIELD='" & aryAuto(i) & "'"
Set RS = dbConn.Execute(strSQL)
"Any other code you need to do with the RecordSet"
Next
Set RS = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top