Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    May 2003
    Location
    Perth, Western Australia, Australia
    Posts
    150
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Removing duplicates from display in combo box

    Hi,
    I'm enquiring on how to not display a duplicate record, as the code below will grab all the data from the MATLGRADE field. Because this is depended on another field, it will at most times display records with the same MATLGRADE more then once. I do not seek to delete the duplicates, just do not want them repeated 20 or so times in the combo box. Just displayed once. Thanks in advance.

    <tr>
    <td>
    <select name="matlGrade">
    <option value="matlGrade">MatlGrade</option>
    <%
    s = Request.Form("matlGrade")
    if strMod <> "Parts" then
    set oRs = oConn.execute("Select matlGrade From tblSheets Where Parts = '" & strMod & "'")
    do while not oRs.eof
    %>
    <option value="<%=oRs("matlGrade")%>"<%if s = oRs("matlGrade") then%>selected<%end if%>><%=oRs("matlGrade")%></option>
    <%
    oRs.moveNext
    loop
    set oRs = nothing
    end if
    %>
    </select>
    </td>
    <td>Select material grade</td>
    </tr>

  2. #2
    2 Star Lounger
    Join Date
    May 2003
    Location
    Perth, Western Australia, Australia
    Posts
    150
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Removing duplicates from display in combo box

    I never thought the day would come when I would reply to my own post. But anyway, its as simple as putting the Distinct clause.
    Select DISTINCT matlGrade From tblSheets Where Parts = '" & strMod

    Hope that helps me out [img]/forums/images/smilies/smile.gif[/img]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •