Solved

Access 2007 Populate TreeView

Posted on 2011-03-17
4
903 Views
Last Modified: 2012-06-27
I need to come up with a clever way to populate a tree view.  My Data is organized like this

IDTag                                      Building              Floor                Area
PP-O2C01-01                       Operations           2nd                    East
PP-O2C01-02                       Operations           2nd                    East
PP-O2C01-03                       Operations           2nd                    West
PP-C3C04-01                       Command            3rd                     East
XF-O3C01-01                        Operations           3rd                    West

......
I am trying to create a function that I can pass in Building, Floor, Area (All boolean) and populate a treeview like this:

Command
|----3rd
       |----East
             |----PP-C3C04-01
Operations
|----2nd
|     |----East
|     |     |----PP-O2C01-02
|     |     |----PP-O2C01-01
|     |----West
|           |----PP-O2C01-03
|----3rd
|     |----West
|           |----XF-O3C01-01


I would like to make the function editable so that I can determine the level of organizing... so if I pass in just Building as True then it will only show

Command
|----PP-C3C04-01
Operations
|----PP-O2C01-02
|----PP-O2C01-01
|----PP-O2C01-03
|----XF-O3C01-01

All of the data is in [Main-Location] Field Names are IDTag, Building, Floor, Area

I will follow up with what I have so far.
0
Comment
Question by:VTKegan
  • 2
4 Comments
 
LVL 10

Author Comment

by:VTKegan
Comment Utility
My Main issue is the Key property of each node.  I keep running into duplicate values.  I can't, for example, just assign it the Floor '2nd' because there may be a 2nd floor in multiple buildings.

So I would have to assign it BuildingName-Floor.

Since I would like to create a function with the parameters I cannot determine really the order of operations.

Because If I pass in Building only I can do that easily

but if I pass in Building and Floor, it gets tricky, but the code would be different if I passed in BUilding and Area.
0
 
LVL 30

Assisted Solution

by:SiddharthRout
SiddharthRout earned 200 total points
Comment Utility
See if this example helps you?

http://www.freevbcode.com/ShowCode.asp?ID=7554

Sid
0
 
LVL 24

Accepted Solution

by:
Bitsqueezer earned 300 total points
Comment Utility
Hi,

maybe the attached file is what you're searching for. It is done with a class module also using the "WithEvents" keyword so you can set all TreeView events inside the class. The advantage is that you can work with multiple TreeViews with this method without the need to code events again and again.

But the main thing is of course the FillTree function with which you can populate a TreeView based on the grouped style of your data. You can also set a level parameter so all unneeded levels are left out.

Cheers,

Christian
GroupTrees.zip
0
 
LVL 10

Author Comment

by:VTKegan
Comment Utility
Thanks for the suggestions... I'm not going to be able to check these out on Monday.  I'll report back then.

Thanks
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.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

763 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

8 Experts available now in Live!

Get 1:1 Help Now