Greg writes "const REC_ID = 0const PARENT_REC_ID = 1const REC_TITLE = 2const REC_NUMBER = 3dim cn, rstPhone, strSQLdim strArrRows, intRowCount, intIndexstrSQL = "SELECT numID, numParentID, txtTitle, txtNumber " & _ "FROM tblPhoneList " & _ "ORDER BY numID "' function to get connection, in another includeset cn = fncGetConnection( ) set rstPhone = server.CreateObject( "ADODB.Recordset" )rstPhone.ActiveConnection = cnrstPhone.CursorType = adOpenStaticrstPhone.Open strSQLstrArrRows = rstPhone.GetRows()intRowCount = rstPhone.RecordCountrstPhone.Closecn.Closeset rstPhone = nothingset cn = nothingintIndex=0-- Some HTML stuff' Find the top-level entities in the hierarchyfor intIndex = 0 To intRowCount - 1 'Response.Write "intIndex = " & intIndex ' If the Parent is equal 0(is NULL), we have a top level if int(strArrRows(PARENT_REC_ID, intIndex)) = 0 then ' Start looking for children PrintRow strArrRows(REC_ID, intIndex), strArrRows(REC_TITLE, intIndex), strArrRows( REC_NUMBER, intIndex ), 0 end ifnext sub PrintRow(nRegionID, strTitle, strNumber, intLevel ) dim intIndex 'Write out the current level Response.Write "<TR>" & Cat( intLevel, "<TD></TD>") & "<TD>" & strTitle & "</TD><TD>" & strNumber & "</TD></TR>" for intIndex = 0 To intRowCount - 1 ' IF the row we're looking at has a parent of the region passed in, then delve into its children. if strArrRows(PARENT_REC_ID, intIndex) = nRegionID then ' Call our PrintRow function to find the children of this record and so on. PrintRow strArrRows(REC_ID, intIndex), strArrRows(REC_TITLE, intIndex), strArrRows( REC_NUMBER, intIndex ), intLevel + 1 end if Nextend subfunction Cat( intTimes, strWhat ) dim i, strTemp for i = 1 to intTimes strTemp = strTemp & strWhat next Cat = strTempend function
This might help someone, I found the outline somewhere else on the web.Doing a search is a challenge though, just finding where you are starting from... I guess it will require finding all of the head parents within the set of data."