Solved

Crating a tree view in Access 2007

Posted on 2010-09-20
5
1,007 Views
Last Modified: 2013-12-20
I am using Access 2007 at work and feel that using a tree view to represent a structured hierarchy as a series of nodes is the best and most intuitive way to present my material.  My application comes with two flavors of Tree View: "Microsoft Treeview Control, Version 5.0 (SP2)" and "Microsoft Treeview Control, Version 6.0".  The program does not allow even to use version 5.0, saying I don't have privileges.  I can place version 6.0 into my application, but none of the tutorials I've seen corresponds with the properties and methods avialable on the control.  The most obvious lack is the absence of the "NODES" property, and, hence, the "NODES.ADD" method.  The control looks like it should be the right one, but I can't program it in the most obvious and fundamental ways!  I appreciate your help, as always.
I've included a screenshot for clarity.
Thanks, ~Peter Ferber

Treeview-NoNodesProperty.bmp
0
Comment
Question by:PeterFrb
  • 2
  • 2
5 Comments
 
LVL 84
ID: 33720921
The control you're trying to use is NOT certified for use in the Access environment, thus you may find that it does not behave as intended. There are some 3rd party tools that include treeviews (DBI components, for example) that do claim to work, but make sure they're certified for usin in Access 2007.

That said, in general in order to get to the Properties and Methods of an ActiveX in Access, you must declare an Object:

Dim tvw As Treeview

Set tvw = Me.MyTreeviewControl.Object

Access interacts with ActiveX controls very much differently than does other enviroments, which is the reason for the odd referencing method.
0
 

Author Comment

by:PeterFrb
ID: 33721315
Very interesting comments: thank you for that.  I do note that the Access version of the TreeView object does contain the Nodes property and the Nodes.Add method, but, as anticipated, I get a non-compatible error when attempting to assign an Access TreeView object with the version 6 of the TreeView I inserted (see accompanying screenshot).  

I have 2 questions: 1) Does Access 2007  provide a skimpier selection of controls as its predecessor, as seems to be the case here?  2) Is it possible to instantiate an Access TreeView object from within a form using the Treeview variable?  I believe I've done this in VB6, but it's been a very long while.  

Thanks much,
~Peter Ferber
Treview-CodeError.bmp
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 33758939
I use treeviews all the time.  Take a look at the sample database at the bottom of this question.
When you right click the treeview in design mode, and view the events in the Properties dialog, you don't see very many.  But when you go to the VB IDE, select and select the treeview control from the dropdown, then all the events associated with it will display in the other dropdown.
Additionally, you need to make sure you have MSCOMCTL.OCX in your references, this is generally located in the Windows\system32 folder.
0
 
LVL 84
ID: 33760005
To be clear, there is no such thing as an "Access Treeview Object". This is an ActiveX control that is built for use with other environments that just happens to work (sometimes) in the Access environment.

The ActiveX controls you see are a listing of ALL controls installed/registered on that specific machine. It has nothing at all to do with the installation of Access. If ProgramA installs ActiveXControl123, then Access will (usually) see a listing for ActiveXControl123. This does NOT mean that you can use that control, or that it will work in Access. It just means the control has been installed on the machine.

As I instructed in my earlier comment, you must set the variable to the .Object:

Dim tvw As Treeview
SEt tvw = Me.MyTreeviewControl.Object

This will give you Intellisense. As Dale said, you would need to move to the VBA Editor in order to see all of the events for that control.

0
 

Author Closing Comment

by:PeterFrb
ID: 33774413
I used this, and it worked.  Thank you!
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Steps to upgrade a Access 2003 application to 2013 3 34
Filter cbo on datasheet - 11 31
Archiving Access table older than 6 months 9 38
Calculation in Access 5 25
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

786 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