Forums
This topic is locked
No duplicates in drop down
03 Oct 2003 13:44:51 neoz 123 posted:
How do I make it so no duplicate show in a dynamic drop down. Pulling from ACCESS.<pre id=code><font face=courier size=2 id=code>
Form code :
<form name="frmSelect" method="get" action="dbsearch.asp">
<!-- Using javascript with ASP for an automatic submit of selected form value***jmeyers -->
<SELECT name=DbName LANGUAGE=javascript onchange="return dept_onchange(frmSelect)" title="Select exercise to display cooresponding observations." style="color: #003366; font-style: normal; font-family: verdana; font-weight: normal; font-size:10px">
<%
' Populating drop down menu from DbName field in Tbl_Observation table***jmeyers
do until drs.EOF
response.write("<option"
if drs.fields("DbName"=DbName then
response.write("selected"
end if
response.write(">"
response.write(drs.fields("DbName")
drs.MoveNext
loop
drs.Close
set drs=Nothing
%>
</SELECT> <font size="1"><font face="Arial, Helvetica, sans-serif" title="Select exercise to display cooresponding observations.">Select exercise</font></font>
</form>
searchdb page:
<%
If oField <> "" Then
Set conn = Server.CreateObject("ADODB.Connection"
conn.Open("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("AssDB/EFCATDB.mdb")
set rs = Server.CreateObject("ADODB.Recordset"
sql ="SELECT DISTINCT ROW * " _
& "FROM Tbl_Observation WHERE [Tbl_Observation].[DbName] = '" & oField & "'"
Set rs = conn.Execute(sql)
%>
</font id=code></pre id=code>
Replies
Replied 03 Oct 2003 20:09:58
03 Oct 2003 20:09:58 Jon Ford replied:
think this may help...
Try usng a DISTINCT clause in the SQL statement used to create the recordset(s) that are used to populate the drop down boxes. Something like:
SELECT DISTINCT SomeFieldName FROM SomeTableName
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
please let me know thanks - Jon
Try usng a DISTINCT clause in the SQL statement used to create the recordset(s) that are used to populate the drop down boxes. Something like:
SELECT DISTINCT SomeFieldName FROM SomeTableName
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
please let me know thanks - Jon
Replied 03 Oct 2003 20:13:17
03 Oct 2003 20:13:17 neoz 123 replied:
Problem already solved
SELECT DISTINCT DbName FROM Tbl_Observation GROUP BY DbName ORDER BY DbName
The Group By eliiminates the duplicates
SELECT DISTINCT DbName FROM Tbl_Observation GROUP BY DbName ORDER BY DbName
The Group By eliiminates the duplicates