Tutorials

Drop down list search

There are just two simple steps to follow in order to do this.

1. On your search form, make sure you name your drop down list so you can easily identify it.

For example: You might have a drop down list containing Restaurants, Cafe's and Take Aways.
You might also like to add an Any option.
You could name this drop down list ddlPlaceType.

Each of the list options should be assigned a value that you can use in your query - Restaurants will have a value of Restaurant for instance. Give the Any option a value of %.

2. In the recordset builder on your results page, where you need to use the value of the drop down list in your SQL query, you would add a parameter and give it a run-time value of:

Request.Form("ddlPlaceType")

Once that is set up, if the user selects the Restaurant option from the list and submits the form, the value held in ddlPlaceType would be Restaurant - which would be used as the run-time parameter in your SQL query.

Notes:

If you plan on using an Any option in your list, you will need to modify your SQL slightly.

Basically, you're going to ask the database for any records that look LIKE the option the user selects in the drop down list.

Ordinarily, this would be done by surrounding varPlaceType with % symbols.

In this case, we don't want to do that.

Your SQL statement, in this case, might look like this:

SELECT *
FROM myTable
WHERE PlaceType LIKE 'varPlaceType'

Variables

Default Value

Run-time Value

varPlaceType

0

Request("ddlPlaceType")