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

filtering dropdown with a Where Statement 1

Status
Not open for further replies.

tamnet

IS-IT--Management
Jun 2, 2005
31
GB
Is it possible to filter a dropdown by using a where statement I have the following code for my dropdown

Code:
	    <option value="<%=(RSdetails.Fields.Item("RepID").Value)%>"><%=(RSdetails.Fields.Item("Name").Value)%></option>

Couls someone explain the correct syntax to add in the code in red

	    <option value="<%=(RSdetails.Fields.Item("RepID").Value)%>"><%=(RSdetails.Fields.Item("Name").Value)%>[COLOR=red]Where <%=(RSdetails.Fields.Item("Type").Value)= E%>[/color]</option>
 
Why dont you do this at the query level....

SQL = Select blah from mytable Where Type='E'

-DNG
 
or at the dropdown level...you might be having something like this...

while not rs.eof
if RSdetails.Fields.Item("Type").Value="E" then
<option value="<%=(RSdetails.Fields.Item("RepID").Value)%>"><%=(RSdetails.Fields.Item("Name").Value)%>%=(RSdetails.Fields.Item("Type").Value)%></option>
end if
rs.movenext
wend

-DNG
 
DNG,

Thanks for the reply

Sorry I probably did not explain myself fully this is my select

Code:
SELECT CustomerName, CustomerNameID, Address, tblCustomerDeliveryAddress.DeliveryAddress, RepID, Name, Type
FROM tblCustomerDetails, tblCustomerDeliveryAddress, tblReps
WHERE CustomerDetailsID = CustomerNameID AND tblCustomerDeliveryAddress.DeliveryAddress = 'AddID'

and RepID, Name and Type all come from tblReps, in the table there are 2 types of rep Internal & External.

Therefore in my select dropdown my value is RepID and my Label is Name but I would like to be able to only show External reps so I want to filter on type "E"

therefore that was the reason for my original question

I will then create another dropdown where the type will be "I" to filter by Internal Reps.

Any thoughts would be appreciated

Regards

Paul
 
did you try this:

for dropdown 1:

while not rs.eof
if RSdetails.Fields.Item("Type").Value="E" then
<option value="<%=(RSdetails.Fields.Item("RepID").Value)%>"><%=(RSdetails.Fields.Item("Name").Value)%></option>
end if
RSdetails.movenext
wend

for dropdown 2:

while not rs.eof
if RSdetails.Fields.Item("Type").Value="I" then
<option value="<%=(RSdetails.Fields.Item("RepID").Value)%>"><%=(RSdetails.Fields.Item("Name").Value)%></option>
end if
RSdetails.movenext
wend

what we are doing is we are looping through our entire recordset and populating the dropdown only when our condition is satisfied...

try it and let us know if you get any error...

-DNG



 
DNG,
Worked a treat, Thanks so much, A star for you

[2thumbsup]

Regards

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top