Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2758
  • Last Modified:

ActiveX Treeview Control

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
stevensont
Asked:
stevensont
  • 3
  • 2
  • 2
  • +1
2 Solutions
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:

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
 
stevensontAuthor Commented:
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
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Leigh PurvisDatabase DeveloperCommented:
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
 
stevensontAuthor Commented:
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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
"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
 
stevensontAuthor Commented:
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
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now