La tabla la creo así:
Código ASP:
Ver original<form action="referencias.asp" method = "post" id="form3" name="borrar">
<table border="1">
<%if request.Form("valortext2")<>"" then %>
<%valortext = request.Form("valortext2")%>
<%end if%>
<%If valortext <> "" then%>
tablabase.open "select count(n_pedido) as n_pedido from tablabase where n_pedido ='"&valortext&"'", conn%>
<%while not (tablabase.eof)%>
<%Dim existe
Session(tablabase("n_pedido")) = tablabase("n_pedido").value
existe = tablabase("n_pedido")%>
<%tablabase.moveNext%>
<%wend%>
<%tablabase.Close%>
<%if existe = "1" then%>
<%tablabase.open "select id as id from tablabase where n_pedido ='"&valortext&"'", conn%>
<%while not (tablabase.eof)%>
<%Dim id_pedido
Session(tablabase("id")) = tablabase("id").value
id_pedido = tablabase("id")%>
<%tablabase.moveNext%>
<%wend%>
<%tablabase.Close%>
<%if id_pedido<> "" then%>
<%tablabase.open "select id_pedidoHijo,n_pedido from referencias where id_pedidoPadre = '"&id_pedido&"%' order by id_pedidoHijo", conn%>
<%while not (tablabase.eof)%>
<tr align="left">
<%Session(tablabase("id_pedidoHijo")) = tablabase("id_pedidoHijo").value
Session(tablabase("n_pedido")) = tablabase("n_pedido").value
Preserve pedidos(z)
pedidos(z) = tablabase("n_pedido").value
check = cstr(tablabase("id_pedidoHijo").value)%>
<td align="center">
<input type="checkbox" name="ch" value="<%=check%>">
</td>
<td align="left">
<%response.write pedidos(z)%>
</td>
<%i = i + 1
z= z + 1
tablabase.moveNext%>
</tr>
<%wend%>
<%tablabase.Close%>
<input type="hidden" name="valortext2" id="valortext2" value ="<%=valortext%>" />
<%end if%>
<%else%>
<tr>
<%response.write "* El proyecto introducido no existe"%>
</tr>
<%end if%>
<%end If%>
<%end If%>
</table>
<table align="right">
<tr>
<td>
<input type="submit" name="eliminar" value="Eliminar">
<%if Request.Form("ch").Count then%>
<%For i = 1 To Request.Form("ch").Count%>
<%Dim seleccionados
seleccionados = Request.Form("ch")(i)%>
<%tablabase.open "delete from referencias where id_pedidoHijo ='"&seleccionados&"'", conn%>
<%Next%>
<%if Request.Form("valortext2") <> "" then%>
<%Dim valortext2
valortext2 = request.Form("valortext2")%>
<%end if%>
<%end if%>
</td>
</tr>
</table>
</form>