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

If statement

Status
Not open for further replies.

drai

Programmer
Joined
Oct 23, 2000
Messages
1
Location
US
I have an asp page that selects names out of a column in a database to place them in a drop down box. Problem is that the information is placed by quaters. so the name is in the column multiple times. How do I write the statement to only select the name once and not mulitple times.

Here is the code I have so far:

<select name=&quot;selection&quot;>
<% do while not ors.eof %>
<option><% =ors.fields (&quot;selection&quot;).value %>
</option></font>
<% ors.movenext
loop
'dbobj.close
'set dbobj=nothing%></select>
 
First of all is much faster to pass a SQL statemne then looping through and testing for values.
And if you want just one occurance of an item use DistinctRow: So if there are 20 records and 10 of them are &quot;Smith&quot; and 5 are &quot;Jones&quot; and 5 are &quot;Rayfield&quot; then you will only see 3 items in your dropdown. One Smith, one jones and one Rayfield.

SQLString = &quot;Select DistinctRow Field1 From yourTable Where something = Somethingelse&quot;

then create a loop where is puts just those 3 records in your Selection box
Code:
Set ors.open(SQLString)

<% do while not ors.eof %>
        <option><% =ors.fields(&quot;Field1&quot;).value %>
</option></font>
<% ors.movenext  
loop
Not sure what kind of database you are opening so my &quot;Set&quot; statement may not be right.
[sig]<p>DougP, MCP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top