stevensont
asked on
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.
I have one table with an ID, category, and a subcategoryID. Where I to go from here; I'm clueless.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
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:
The class itself should give some clues to the methodology if you want to look inside.
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
The class itself should give some clues to the methodology if you want to look inside.
ASKER
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.
On the other hand, if I don't remember the syntax of the msgbox function, I press F1 and get the complete syntax.
What I'm trying to find out is where do I get help to learn all the syntax of treeview?
On the other hand, if I don't remember the syntax of the msgbox function, I press F1 and get the complete syntax.
What I'm trying to find out is where do I get help to learn all the syntax of treeview?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
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.
ASKER