Here is my current code:

Code:
Private Sub tvPS_NodeClick(ByVal Node As Node)
    'If Node.Children > 0 Then
    '    Set Node = Node.Child
    '    r = 1
    '    Do
    '        MsgBox (Node.Text & " is the Text and " & Node.Key & " is the key.")
    '        Set Node = Node.Next
    '    Loop Until Node Is Nothing
    'End If
    Dim objNode As Node
    'clear any existing rows
    msfgPS.Rows = msfgPS.FixedRows
    msfgWC.Rows = msfgWC.FixedRows
    If Node.Children > 0 Then
        Set objNode = Node.Child
        Do
            If RIGHT$(objNode.Key, 4) = "_MAT" Then
               With msfgPS
                    .AddItem ""
                    .TextMatrix(.Rows - 1, 3) = objNode.Text
                    .Row = .Rows - 1
                    .Col = 3
                    .ForeColor = vbBlue
                    .CellAlignment = flexAlignCenterCenter
               End With
            Else
                With msfgWC
                    .AddItem ""
                    .TextMatrix(.Rows - 1, 4) = objNode.Text
                    .Row = .Rows - 1
                    .Col = 4
                    .ForeColor = vbRed
                    .CellAlignment = flexAlignCenterCenter
                End With
            End If
            Set objNode = objNode.Next
        Loop Until objNode Is Nothing
    End If
End Sub
What I need to do, is query an Oracle Database to get all items in the row where PS_IMKEY = objNode.Text. I then, need to step through the Recordset and for each column in the database that comes back, write it's value to a cell in the FlexGrid. Can someone help me figure the best way to do this? I need to know where I should call a separate sub that will take care of the query and FlexGrid population or in the If...Then statement, have a connection in both possible situations. Example:

[code]
Private Sub tvPS_NodeClick(ByVal Node As Node)
'If Node.Children > 0 Then
' Set Node = Node.Child
' r = 1
' Do
' MsgBox (Node.Text & " is the Text and " & Node.Key & " is the key.")
' Set Node = Node.Next
' Loop Until Node Is Nothing
'End If
Dim objNode As Node
'clear any existing rows
msfgPS.Rows = msfgPS.FixedRows
msfgWC.Rows = msfgWC.FixedRows
If Node.Children > 0 Then
Set objNode = Node.Child
Do
If RIGHT$(objNode.Key, 4) = "_MAT" Then
'CONNECT HERE
With msfgPS
.AddItem ""
.TextMatrix(.Rows - 1, 3) = objNode.Text
.Row = .Rows - 1
.Col = 3
.ForeColor = vbBlue
.CellAlignment = flexAlignCenterCenter
End With
Else
'CONNECT HERE
With msfgWC
.AddItem ""
.TextMatrix(.Rows - 1, 4) = objNode.Text
.Row = .Rows - 1
.Col = 4
.ForeColor = vbRed
.CellAlignment = flexAlignCenterCenter
End With
End If
Set objNode = objNode.Next
Loop Until objNode Is Nothing
End If
End Sub