Solved

ActiveX Treeview Control

Posted on 2011-09-21
8
2,505 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
Comment Utility

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
Comment Utility
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
Comment Utility
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
 
LVL 44

Expert Comment

by:Leigh Purvis
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:stevensont
Comment Utility
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
Comment Utility
"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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

762 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

11 Experts available now in Live!

Get 1:1 Help Now