Forums

This topic is locked

Search Page with List Values

Posted 02 Jan 2002 01:04:34
1
has voted
02 Jan 2002 01:04:34 Kent Steelman posted:
I am trying to set up a list menu that will allow the user to pick an item and then the results page will show only those items related to the users selection. My problem is I would like to allow the user to have a N/A or All selection. This is a text field. I have tried to use the wildcard of %, but with no success.... I know where to place the "ALL" selection (List Values) and I can obtain a list of records for the user to pick. Can anyone help with the problem.

Wm. Kent Steelman

Replies

Replied 02 Jan 2002 05:14:03
02 Jan 2002 05:14:03 Owen Eastwick replied:
You could do it by making the values in the List/Menu equate to the whole WHERE clause.

First set up a recordset as normal.

Then make the options and values of the List/Menu something like:
Option - All Whatever, Value - WHERE YourRecordIDField <> -1
Option - Item1, Value - WHERE YourItemsField LIKE 'Item1'
Option - Item2, Value - WHERE YourItemsField LIKE 'Item2'

Asuming that your RecordID field is an Autonumber field this will allways contain a Positive number therefore <b>WHERE RecordID &lt;&gt; -1</b> will return all records. If not select an alternative condition that is true for all records.

On the search Results Page Modify the Recordset Source code as follows:

Get rid of the code like this:

&lt;%
Dim RecordsetName__Whatever
RecordsetName__Whatever = "YourField"
if (Request("YourListMenuName" &lt;&gt; "" then RecordsetName__Whatever = Request("YourListMenuName"
%&gt;

Replace it with this:

&lt;%
varWhereString = Request("YourListMenuName"
%&gt;

Then modify the Recordset Source code:

RecordsetName.Source = SELECT WhateverYouWant, WhateverElseYouWant FROM YourTableName " & varWhereString

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo

Reply to this topic