I have just picked up this project and have never used treeviews in vba before and have done some research but still cannot understand why I am getting an error.
My code is posted below and it error occurs on the "oTree.Nodes.Add oTree.DropHighlight, tvwChild, "c" & iNodeCount + 1, moNode.Text" and the error message is "An error occured while trying to move the node. Key is not unique in collection"
I am trying to move the value from one tree view to another and it selects the item to move and inserts it into the table without any errors, but when you try and attach it to the node it errors.
Any help would be greatly appreciated.
Many Thanks in advance
Vicky
'Create a reference to the TreeView control.
Set oTree = Me!ConsTree.Object
'If nothing is selected for drag, do nothing.
If moNode Is Nothing Then
Else
If oTree.DropHighlight Is Nothing Then
'nothing?
ElseIf moNode.Text <> oTree.DropHighlight.Text Then
'add to table
Set cn = CurrentProject.Connection
cn.Execute ("insert into consolidations values ('" & oTree.DropHighlight & "','" & moNode.Text & "')")
Set cn = Nothing
oTree.Nodes.Add oTree.DropHighlight, tvwChild, "c" & iNodeCount + 1, moNode.Text
End If
End If
My code is posted below and it error occurs on the "oTree.Nodes.Add oTree.DropHighlight, tvwChild, "c" & iNodeCount + 1, moNode.Text" and the error message is "An error occured while trying to move the node. Key is not unique in collection"
I am trying to move the value from one tree view to another and it selects the item to move and inserts it into the table without any errors, but when you try and attach it to the node it errors.
Any help would be greatly appreciated.
Many Thanks in advance
Vicky
'Create a reference to the TreeView control.
Set oTree = Me!ConsTree.Object
'If nothing is selected for drag, do nothing.
If moNode Is Nothing Then
Else
If oTree.DropHighlight Is Nothing Then
'nothing?
ElseIf moNode.Text <> oTree.DropHighlight.Text Then
'add to table
Set cn = CurrentProject.Connection
cn.Execute ("insert into consolidations values ('" & oTree.DropHighlight & "','" & moNode.Text & "')")
Set cn = Nothing
oTree.Nodes.Add oTree.DropHighlight, tvwChild, "c" & iNodeCount + 1, moNode.Text
End If
End If