I have the following structure

VB Code:
  1. '- CONNECTION
  2. '- TYPE
  3. '- SQL
  4. '        - 'AAA'
  5. '- PARAMETERS
  6. '        - PARAM
  7. '               - 'XXX'
  8. '               - 'YYY'
and I wanted to get the values XXX and YYY into a string which calls the RetrieveData method i.e strParam = RetrieveData(adoRS, 0, "Parameters", "Param").

'AAA' is returned into a separate string that calls the RetrieveData method i.e strSQL = RetrieveData(adoRS, 0, "SQL")

I have the following code
VB Code:
  1. Function RetrieveData(ByVal rs As ADODB.Recordset, intIndent As Integer, _
  2.                       ByVal strNode As String, _
  3.                       Optional ByVal strChildNode As String) As String    
  4.  
  5.     Dim Col             As ADODB.Field
  6.     Dim strReturnedSQL  As String
  7.     Dim rsChild         As ADODB.Recordset
  8.    
  9.     Do While Not rs.EOF
  10.         For Each Col In rs.Fields
  11.         If Col.Name = strNode Then
  12.             If Col.Type <> adChapter Then
  13.                 ' Output the non-chaptered column
  14.                 strReturnedSQL = Col.Value
  15.             Else
  16.                 ' Retrieve the Child recordset
  17.                 Set rsChild = Col.Value
  18.                 rsChild.MoveFirst
  19.                 strReturnedSQL = RetrieveData(rsChild, intIndent + 4, strChildNode)
  20.                 rsChild.Close
  21.                 Set rsChild = Nothing
  22.             End If
  23.         End If
  24.         Next
  25.         rs.MoveNext
  26.     Loop
  27.     RetrieveData = strReturnedSQL
  28.     rs.MoveFirst

The code currently gets the value AAA into strSQL but it has trouble getting XXX and YYY into strParams- strParams is always empty

If someone could help me adjust the loop, it would be immensely appreciated!!

thanks in advance