Private Function DelNode(NodeX As Node)
Dim N As Long
Dim StrSql As String
Dim MoNode() As Node
Dim AddId As Long
Dim TmpNode As Node
With TrvBasePar
If Not (TrvBasePar.Cnn Is Nothing) Then
StrSql = "DELETE FROM " & .TabName & " WHERE " & .ParFld & "='" & Right$(NodeX.Parent.Key, Len(NodeX.Parent.Key) - 1) & "' AND " & _
.ChildFld & "='" & Right$(NodeX.Key, Len(NodeX.Key) - 1) & "'"
TrvBasePar.Cnn.Execute StrSql
End If
If NodeX.Children > 0 Then
AddId = 0
N = NodeX.Child.Index
If .TrvName.Nodes(N).Children > 0 Then
AddId = AddId + 1
ReDim Preserve MoNode(AddId - 1)
Set MoNode(AddId - 1) = .TrvName.Nodes(N)
Else
Set TmpNode = .TrvName.Nodes(N)
If Not (.Cnn Is Nothing) Then
StrSql = "DELETE FROM " & .TabName & " WHERE " & .ParFld & "='" & Right$(TmpNode.Parent.Key, Len(TmpNode.Parent.Key) - 1) & "' AND " & _
.ChildFld & "='" & Right$(TmpNode.Key, Len(TmpNode.Key) - 1) & "'"
.Cnn.Execute StrSql
End If
End If
While N <> NodeX.Child.LastSibling.Index
N = .TrvName.Nodes(N).Next.Index
If .TrvName.Nodes(N).Children > 0 Then
AddId = AddId + 1
ReDim Preserve MoNode(AddId - 1)
Set MoNode(AddId - 1) = .TrvName.Nodes(N)
Else
Set TmpNode = .TrvName.Nodes(N)
If Not (.Cnn Is Nothing) Then
StrSql = "DELETE FROM " & .TabName & " WHERE " & .ParFld & "='" & Right$(TmpNode.Parent.Key, Len(TmpNode.Parent.Key) - 1) & "' AND " & _
.ChildFld & "='" & Right$(TmpNode.Key, Len(TmpNode.Key) - 1) & "'"
.Cnn.Execute StrSql
End If
End If
Wend
If AddId > 0 Then
For N = 0 To AddId - 1
Call DelNode(MoNode(N))
Next
End If
End If