Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TreeView Error - Add Node

Status
Not open for further replies.

vix666

IS-IT--Management
Jul 17, 2003
63
0
0
AU
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
 
As is says "c" & iNodeCount + 1 would not be unique
somewhere in oTree.Nodes there is something with that key

change code to make it unique
 
Thanks for your help. In the end i just changed my code to rebuild the tree from the table thus eliminating the need for the line of code that errored. But i will look into this problem as no doubt it may cause other problems in the future from the way it has been built.

Thanks Again

Vicky
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top