K
Kingdom
I just wanted to add that you would not want to do it this way if your
table contained thousands of rows of data. You would be better off
using two dropdowns: one for the user to select a type, the other to
display the corresponding items based on the type selected.
With a few hundred records, however, both methods should work well.
Frankly, with an Access database, I would be leaning more towards
Tom's method.
Couldn't wait till tomorrow, tried now but I must have messed up I'm
getting an error.
Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.
/simple.asp, line 72 <========which is the end of the file?
This how it looks
<%
Set objDC = Server.CreateObject("ADODB.Connection")
objDC.Open Application("Database1_connectionstring")
%>
<%
dim rsTypes,rsComps, strSQL
Dim sCurCompType
'open the connection, then
Set rsTypes= server.createobject("adodb.recordset")
rsTypes.cursorlocation=adUseClient
strSQL= "SELECT DISTINCT Component_Type " & _
"FROM Parts_Table ORDER BY Component_Type; "
rsTypes.Open strSQL,cn,,,adCmdText
'disconnect the recordset
set rsTypes.ActiveConnection = nothing
Set rsComps= server.createobject("adodb.recordset")
rsComps.cursorlocation=adUseClient
strSQL= "SELECT UniqueID, Component_Type, Price, Component_Name " & _
"FROM Parts_Table ORDER BY Component_Type, Component_Name"
rsComps.Open strSQL,cn,,,adCmdText
'disconnect the recordset
set rsComps.ActiveConnection = nothing
cn.Close: set cn=nothing
'put the unique types into a recordset:
set rsTypes = rs.Clone
'disconnect the recordset
set rsTypes.ActiveConnection = nothing
'Put the components into another recordset and disconnect it
set rsComps = rs.NextRecordset
set rsComps.ActiveConnection = nothing
'clean up the initial recordset
rs.Close: set rs=nothing
cn.Close: set cn=nothing
'Create the dropdowns:
do until rsTypes.EOF
sCurCompType = rsTypes(0).Value
Response.Write "Component Type " & sCurCompType & ": "
Response.Write "<select name=""" & sCurCompType & """>"
rsComps.Filter="Component_Type='" & sCurCompType & "'"
do until rsComps.EOF
Response.Write "<option value-""" & rsComps(0).Value
Response.Write """>" & rsComps(2).Value
Response.Write "</option>"
rsComps.MoveNext
loop
Response.Write "</select><BR>"
rsTypes.MoveNext
loop
rsTypes.close:set rsTypes=nothing
rsComps.close:set rsComps=nothing
%>
</body>
</html>