Forums

This topic is locked

Sql..........HELP!!!!!!!!!!!!

Posted 26 Jul 2003 20:55:52
1
has voted
26 Jul 2003 20:55:52 paolo titolo posted:
I made a form for a query where you can select the eyes color ,associated to a value (blue=1, green=2, nero=3)
I will like to include all the values in case the list is not selected
I tryed to associat a neg value (as many people do (-1)) but I don't know how to write it in sql
I use Ultradev recordset
I need somethig like:

SELECT *
FROM table1
WHERE (if the value of the form is >1 then eyes = to the value of the form else il the value of the formi <1 then thake all the valuesof eyes > di 1)

i don't know how to write itin sql...
Maybe the are other ways to get it..
thanks

Replies

Replied 27 Jul 2003 04:32:04
27 Jul 2003 04:32:04 Owen Eastwick replied:
Set up your list/menu:

<select name="selEyeColour">
<option value="-1">Any</opton>
<option value="1">Blue</opton>
<option value="2">Green</opton>
<option value="3">Brown</opton>
</select>


Then you need to consruct the SQL Statement in script first, for example:

strSQL = "SELECT * FROM table1"
varEyeColour = Request("selEyeColour"
If varEyeColour <> -1 Then strSQL = strSQL & " WHERE EyeColor = " & varEyeColour


Then modify the recordset.source line of the recordset code, something like:

rsName.Source = strSQL

Regards

Owen.

-------------------------------------------------------------------------------------------
Used programming books and web development software for sale (UK only): www.tdsf.co.uk/tdsfdemo/Shop.htm

Developer services and tutorials: www.drdev.net

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

Reply to this topic