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

check boxes in query

Status
Not open for further replies.

meltingpot

Technical User
May 11, 2004
118
GB
Im trying to write a query using 4 checkboxes (true or false).

I have 4 vechicle types , bike, car, van, lorry and would like the user to search for these items using the check boxes, multi selecting the types, so when they check the box (true)they include it in the result set, not checked then not included .

The very simple query …
Result.asp

SELECT bike, car, van, lorry
FROM vehicle
WHERE bike = bike AND car = car AND van = van AND lorry = lorry (this is where I don’t know how use the checkboxes)


Query_vehicle.asp sends these over to the above page

Request.QueryString("bike") check box name

Request.QueryString("car")

Request.QueryString("van")

Request.QueryString("lorry")

Using MS Access 2003 and ASP vbscript

Any ideas ? ?
 
I am still not sure what you want to do. On the one hand you mention multiselect items, on the other you mention check boxes. What is "Bike" in Request.QueryString("bike") equal to?
 
Sorry for not being to clear. ...


The Request.QueryString("bike") is the checkbox (called Bike)form the query page - it passes wheather the checkbox has been ticked or not.So Ill try to be clear..

The querypage (.ASP) has a search section. It contains 4 checkboxes named as above. So if the user wants to see a list of all bikes and cars he checks those boxes, if he doesnt want to see the list of vans and lorries he doesnt check those. Presses 'submit' and it passes the check boxes state via the request.querystring to the SQL qery, as above.

This is where Im stuck, how do i deal with the true/false state of the query string data in the SQL query.

Im on a learning curve so please bare with me :)
 
Are the results you display in an Access database or just hidden panels? What type of script are you using to read the check boxes in your asp page?

This may be better answered in the asp forum.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Ok. Where is not going to help if your table has four columns, one for each vehicle type. This is not a good way to set up such a table as it is not normalized. Your life would be easier with a better set up, here is how it works:
You need to build the query string and I imagine that it would be better for display purposes if the results are returned in a Union query. Say:

Code:
If Request.QueryString("bike")=True Then
   strBike ="Select 'Bike' As VType, Bike As Vehicle From Vehicle Union All "
End If

Request.QueryString("car")=True Then
   strCar ="Select 'Car' As VType, Car As Vehicle From Vehicle Union All "
End If     

Request.QueryString("van")=True Then
   strVan ="Select 'Van' As VType, Van As Vehicle From Vehicle Union All "
End If     

Request.QueryString("lorry")=True Then
   strLorry ="Select 'Lorry' As VType, Lorry As Vehicle From Vehicle Union All "
End If     

strSQL=strBike & strCar & strVan & strLorry

'Trim the last Union All

strSQL=Mid(strSQL,1,Len(strSQL)-10)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top