Hi,
Is there a simple way to find the parent nodes under a given node.
For example I select Node Test, which is a parent, it has 3 children, and
two of those are also parents, and in turn one of those children is also a
parent.
What I want to do is to find out from the node that is selected :-
1. Its key, this is easy
2 for each child of this node that is also a parent what its key is, but
only for nodes that have children.
I know what I need to do in on paper, it is something like this
With selected node, get key convert to int store in array, along with the
name
For each node that is a parent node within the selected node do the same,
get key and name store in array.
Should be simple right? but my brain is melting
here is the code I am using
Sub CopyAllRecords(ByVal sK As String, ByVal ID As Long, ByVal PID As Long)
Dim n As Long
Dim ndeCopy As ComctlLib.Node
Dim arParentFields() As Integer
Dim blChildIsParent as Boolean
Dim iSelNodeChildCount as Integer
ReDim arParentFields(20)
If tvMain.Nodes(sK).Children > 0 Then
Set ndeCopy = tvMain.Nodes(sK).Child
Do While iSelNodeChildCount > 0 And blChildIsParent = True
iSelNodeChildCount = ndeCopy.Children
For n = 1 To iSelNodeChildCount
if nIDCount = UBound(arParentFields) Then
ReDim Preserve arParentFields(UBound(arParentFields) + 20 )
End If
arParentFields(nIDCount) = stripK(ndeCopy.Key)
nIDCount = nIDCount + 1
If n < tvMain.Nodes(sK).Children Then Set ndeCopy = ndeCopy.Next
Next n
iSelNodeChildCount = iSelNodeChildCount - 1
Loop
End If
This does not work, Instead of only processing the nodes under just the
selected node, it does this and every node on the same level as the selected
node.
I hope this is simple, but my head hurts now, can someone put me out of my
misery please
Thanks in advance
Rich