Solved

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

Posted on 2010-09-21
4
2,047 Views
Last Modified: 2013-11-27
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:

mObjTreeView.Nodes.Clear

Open in new window


I've tried code:

mObjTreeView.Nodes(mObjParent.Index).Nodes.Clear

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?
0
Comment
Question by:colevalleygirl
  • 2
4 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 33725388
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:

http://www.veign.com/code-view.php?type=app&codeid=35

Note also that the Treeview is not a verfied control in Access, therefore you may experience some odd issues.
0
 

Author Comment

by:colevalleygirl
ID: 33726648
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.

Thanks
0
 

Author Closing Comment

by:colevalleygirl
ID: 33726660
Complete solution provided
0
 
LVL 3

Expert Comment

by:yahooooo
ID: 39215065
yup works fine but that code should remove nodes from database as well... What the point other way?
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now