Solved

Crating a tree view in Access 2007

Posted on 2010-09-20
5
1,012 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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 …

733 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