Hierarchy problem, PART 2

# Thread: Hierarchy problem, PART 2

1. Member
Join Date
Dec 1969
Posts
36

## Hierarchy problem, PART 2

I made a recursive function that goes through the records in a table and puts them in a combo box with the parent on top of the childs, here&#039;s the code:<BR><BR>Function chkChildren(id)<BR> Dim rsChildren<BR> <BR> Set rsChildren = objConn.Execute("SELECT * FROM galerias WHERE parentID="& id &"")<BR> <BR> If rsChildren.Eof And rsChildren.Bof Then<BR> Exit Function<BR> Else<BR> &#039;If we have children loop through them<BR> Do While Not rsChildren.Eof<BR> Response.Write "&#060;option value="& """" & rsChildren("titulo") & """"& "&#062;"& "---" & rsChildren("titulo") & "&#060;/option&#062;" & vbCrLf<BR> <BR> &#039;Recursion here so we can check the children for more children<BR> chkChildren(rsChildren("id"))<BR> rsChildren.Movenext<BR> Loop<BR> End If<BR>End Function<BR><BR><BR>Now check out this bit "---" in the response.write part.. this adds --- to the first child found, but I what I want is to add 3 more of these to second level and so on, leaving me with a tree structure.<BR>How could I accomplish this considering what I already have?

2. Senior Member
Join Date
Dec 1969
Posts
6,476

## RE: Hierarchy problem, PART 2

Dim strTree<BR>strTree = ""<BR><BR>Do While Not rsChildren.Eof<BR>strTree = (strTree & "---") &#039;in loop everytime it gets here it adds --- to the strTree<BR>Response.Write "&#060;option value="& """" & rsChildren("titulo") & """"& "&#062;"& strTree & rsChildren<BR><BR>Not sure if thats what you mean.<BR>But should give you example for you to work with.<BR><BR>Hope this helps.<BR>Russell M

3. Member
Join Date
Dec 1969
Posts
36

## RE: Thanks

I knew it was something like that thanks a lot it worked :)

#### Posting Permissions

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