Solved

ActiveX Treeview Control

Posted on 2011-09-21
8
2,581 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 - Microsoft MVP, Access and Data Platform) 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
Back Up Your Microsoft Windows Server®

Back up 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.

 
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 - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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…

830 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