Clearing the child nodes of a node in a treeview in vba

How can I clear the child nodes below a given parent node in a treeview control using vba. I know how to clear all the nodes in a treeview using:


Open in new window

I've tried code:


Open in new window

but it won't compile. Is the syntax wrong or can I just not do what I'm trying to do so simply? If I need a sub-routine, can anyone get me started?
Who is Participating?
Scott McDaniel (Microsoft Access MVP - EE MVE )Connect With a Mentor Infotrakker SoftwareCommented:
Which Treeview are you using? There are several, and some of them are 3rd party controls.

Here's how to clear the ChildNodes of the VBA treeview:

Note also that the Treeview is not a verfied control in Access, therefore you may experience some odd issues.
colevalleygirlAuthor Commented:
I'm using the TreeView Windows Common control. The code you pointed me to works fine, although I've modified it to identify the parent node via its index.

colevalleygirlAuthor Commented:
Complete solution provided
yup works fine but that code should remove nodes from database as well... What the point other way?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.