VB Code:
Function RetrieveData(ByVal rs As ADODB.Recordset, intIndent As Integer, _
ByVal strNode As String, _
Optional ByVal strChildNode As String) As String
Dim Col As ADODB.Field
Dim strReturnedSQL As String
Dim rsChild As ADODB.Recordset
Do While Not rs.EOF
For Each Col In rs.Fields
If Col.Name = strNode Then
If Col.Type <> adChapter Then
' Output the non-chaptered column
strReturnedSQL = Col.Value
Else
' Retrieve the Child recordset
Set rsChild = Col.Value
rsChild.MoveFirst
strReturnedSQL = RetrieveData(rsChild, intIndent + 4, strChildNode)
rsChild.Close
Set rsChild = Nothing
End If
End If
Next
rs.MoveNext
Loop
RetrieveData = strReturnedSQL
rs.MoveFirst