Solved

ActiveX Treeview Control

Posted on 2011-09-21
8
2,555 Views
Last Modified: 2012-05-12
I have access 2007 and it has been my task to create a tree like structure of categories and sub-categories where they can be selected to categorize different attachments. The problem is I have no experience with using the treeview control although I have coded in Access VBA for years, but not as an expert. Therefore, I am posting here for some help because I don't know how to begin coding. I found several text explanations and few easy to understand examples.
I have one table with an ID, category, and a subcategoryID. Where I to go from here; I'm clueless.
0
Comment
Question by:stevensont
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 36578237

Freeware Instant Treeview (Scroll down to bottom  of the page until you get to Access Tools)
           http://datapigtechnologies.com/AccessMain.htm
Comes with db that has jump start example and an online tutorial. It's very cool.

Here are step by step Treeview instruction with source code and references
           http://www.databasejournal.com/features/msaccess/article.php/3734331/Access-TreeView-ListView-Basics.htm

mx
0
 

Author Comment

by:stevensont
ID: 36579079
Very good stuff DatabaseMX. However, I'm still hungry for more information, I've looked at the sample code and I'm not satisfied that I know everything that i need/want to know. For example: .Nodes.Add(, , strPKey, strPName, "publisher_open", "publisher_closed"). OK, I can figure out that a node is being added, but what is the syntax contants? . Another one, node.tag. What is the tag and what is it used for? That is the type of information that will help me to learn treeview. I hope you understand what I mean.
0
 
LVL 84
ID: 36579288
The

As a side note: Be careful when dealing with ActiveX controls in Access, as many (in fact, nearly all) controls are NOT supported in the Access environment (and especially in the 2007/2010 environments).

With activex controls, you also must insure that the necessary files/libraries are present on your end user machine, if you'll be distributing this to others. That generally means installing some sort of "runtime control" on those machines.

I can't get to the DataPigTechnologies website right now, but the sytnax to add a Node is pretty consistent throughout most controls:

.Nodes.Add("Relative", "Relationship", "Key", "Text", "Image", "SelectedImage")

Relative = The Node this one will be related to (if any)
Relationship = The relationship this Node will have with the Relative node (for example tvwChild)
Key = The Key value of the node. It must be unique
Text = The Text displayed to the user
Image = The Image to be used (if any)
SelectedImage = Image shown when the Node is selected (if any)

So the line you reference:

.Nodes.Add(, , strPKey, strPName, "publisher_open", "publisher_closed").

Adds a "root" node (there are no values in the first two items), with a Key value of <whatever is in strPKey> and display Text of <whatever is in strPName>, and with images as noted.st adds a node. The first to parameters are blanks, which indicate this is not a

Those are basics (to say the least). I'd encourage you to download the source at those listings and review them carefully.

0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 36579873
If you're wanting to learn how, then that's commendable... And looking at existing examples will be a good way to get started.
As both that, and a very simple to implement wrapper for Treeview - there's the example here ("Hierarchical Data in Access with Shaped Recordsets" and the bottom of the page) which implements treeview loading with code such as:

    Dim objTree As New clsShapeTree
    
    With objTree
        Set .Control = Me.tvwDisplay2.Object
        .SourceLoc = ddLocal
        .AddSource "tblParent", , , "NameField"
        .AddSource "tblChild", "ParentID", "ParentID", "ChildName"
        .AddSource "tblSubChild", "ChildID", "ChildID", "SubChildName"
        .AssignRst
    End With

Open in new window


The class itself should give some clues to the methodology if you want to look inside.
0
 

Author Comment

by:stevensont
ID: 36581345
Thanks guys, but I don't think you understand what I meant. While working in Access VBA, if I don't remember or know the syntex of a function, I would normally press F1 for help. Treeview doesn't have help in access.  Treeview help

On the other hand, if I don't remember the syntax of the msgbox function, I press F1 and get the complete syntax.  Msgbox help
What I'm trying to find out is where do I get help to learn all the syntax of treeview?
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 36582740
"What I'm trying to find out is where do I get help to learn all the syntax of treeview?

That's kind of the problem.  It seems to be spread out all over the net.  The Datapig sample got me jump started, and Leigh's example is excellent as well (and see the other examples on that page also).

Here is one additional TV resource:

How to fill a Treeview control recursively in Access 2000
http://support.microsoft.com/kb/209891/en-us

Now ... IF ... I was going to get serious about a TV control, then I would be using this:

http://www.dbi-tech.com/ComponentPage_ctTree.aspx
As do all of their controls, it comes with complete object model documentation and mdb (et al) examples, and has a boatload of functionality.  Unfortunately, it's VERY pricey these days - for the complete toolkit.

This also looks good, but I have not used it:

SftTree/OCX
http://www.softelvdm.com/Products/ActiveXControls/TreeControl.aspx
But ... also quite pricey ... about the price of what the full DBI package used to cost - for 50 some controls.

mx
0
 

Author Closing Comment

by:stevensont
ID: 36583330
I didn't want to think of searching the net or posting a question whenever I experience a problem. However, this wouldn't be the first time. With so many examples and differences, I have a lot of learning to do, but I'm am more than ready. Thanks to everyone who help jump start my new experience. Peace.
0
 
LVL 84
ID: 36584014
The ActiveX control has no builtin help, like Access. Note you can use Intellisense within your VBA code, if you build your objects correctly:

Dim tvw As Treeview (or whatever your Treeview is called)

Set tvw = Me.YourTreeview.Object

Now when you type "tvw.", you'll see all the Properties and Methods available for that Object.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 5 54
Question about Relationship and Userform in Access Database 17 54
trying to catch ODBC error when database opens 2 27
Dcount help 2 13
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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.

770 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