Access TreeView "Key is not unique in collection"

I know this is a groaner questions, but does anybody have any troubleshooting tricks for this?

I have checked the code in the .Nodes.Add that sets the Relative: and Key: values until my eyes bleed, and it looks fine.

What's driving me crazy is that the error only occurs when I expand on the parent nodes on the 2nd level, in a particular order.

Thanks for any help

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

A few possible places to look for answers:

Experts Exchange (similar question and a solution): 

     - This solution is good since it provides a script example for eliminating duplicates with the query used to reference the database.

Microsoft (scroll down to "How to Link Nodes in the TreeView Control"): 

     - This provides some basics on implementing TreeView Controls and potential hazards

These were a couple of basic ones talking about "Key is not unique in collection." If you need additional assistance, it would be good if you could post additional detail. Also, if you can extract the data and run a script to create the tree again, it might strip out the problem node (guessing the tree is too big to debug visually).

Sorry I cannot be more specific without seeing more about your specific issue. Again, provide a bit more detail if you need additional assistance.

Thanks, Eric.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
When you add your keys, how do you do it? If I recall correctly, the Key value for a Treeview Node can only be a String, and if you're depending on values like "001" to be different from "01" then sometimes the conversion process will strip out those preceding zeros.

Can you post your code where you're building your tree?
mlagrangeAuthor Commented:
LSM - ok, I changed th key for forming a node from
"LevelX=" & CStr(RcdID)
"LevelX=" & Format(RcdID, "00000000")
and the problem stopped happening

Eric - great links

Thanks to you both
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.