TreeView Control not working

Kevin_S

Registered User.
Local time
Today, 10:16
Joined
Apr 3, 2002
Messages
635
Hi All -

I am trying to implement a TreeView control in my form and its not working for me. I have found a few examples of this control and I am trying to adapt the code to my db with little success and I'n not sure of the reason why as it seems pretty straight forward. I keep getting error 438: Object does not support this property or method when I try to run the code. The first line in the code is highlighted. Here is the code:
Private Sub Form_Load()
'Manufacture and Testing
TreeCtrl.Nodes.add , , "level1item1", "Manufacture and Testing", "Folder"
TreeCtrl.Nodes.add "level1item1", tvwChild, "frmBASMAIN", "Boating Main", "Form"
TreeCtrl.Nodes.add "level1item1supplementary", tvwChild, "frmAccessibility", "Accessibility", "Form"
End Sub

Any ideas why this isn't working..?

Thanks,
Kev
 
I'll take 5 stabs in the dark.

1. Your third line is attempting to add a child node to a parent node that doesn't exist.

2. You haven't linked your imagelist control to your treeview control or you are referencing a key in your image control that doesn't exist.

3. A magical curse was directed against your house or business that will never allow you to use the treeview control. (Halloween is just around the corner.)

4. You haven't properly registered either the treeview or imagelist controls or both.

5. You're attempting to alter a control from a module other than the form's module that holds the control.

Regards,
Tim
 
3. A magical curse was directed against your house or business that will never allow you to use the treeview control. (Halloween is just around the corner.)

Its got to be that one :D

But seriously now - like I said above I basically cut and copied this over to try and adapt it to my own needs and I haven't ever set up a control like this before...

So... From the top:
1. Your third line is attempting to add a child node to a parent node that doesn't exist.

Ok... How do I correct this? OR do you know of documentation where it discusses this control and how to set it up?
2. You haven't linked your imagelist control to your treeview control or you are referencing a key in your image control that doesn't exist.
I haven't done this either... Again - can you point me to where I can find out how to set this up or could you possibly provide me with an example (I have looked at all the examples in this forum but they all refer to A-97 and when I try to set them up in 2002 it doesn't carryover
4. You haven't properly registered either the treeview or imagelist controls or both.

5. You're attempting to alter a control from a module other than the form's module that holds the control.
Its not either of these two as I have these taken care of...

Thanks for the help Tim,
Kev
 
Hi, Kevin,

Search on "Treeview Control" at MSDN.COM or support.microsoft.com and you should hit gold.

(I also vaguely recall a post here long ago by -- I think -- PaddyIrishMan (don't quote me on that one) with sample code, if not a file attachment, that illustrated how to connect a treeview control to an imagelist so that you can put icons next to each node, ala Windows Explorer...)

Regards,
Tim
 
message me....

E-mail me Monday or PM me. I have a sample database that tell you how to build a tree. I think it has module and of course a form to utilize the tree thing.

my e-mail is dianna@webcultivator.com or PM me.

Dianna
 
Tim -

I'm taking a look at the info on msdn now and working on getting the control to work - thanks for pointing me to a good resource.

Dianna -

Thanks for the offer to help and if I can't get it on my own in the next day or two I'll definitley take you up on your offer and shoot you an e-mail on Monday...

Thanks to both of you for the help -
Kevin
 
Just another thing. If you've used a treeview control standard to a previous version of Access then you may also find that you have problems. I found this when converting a 97 database to XP.
 
i give this a shot. i'm not sure about images i think you have to use a ImageList ActiveX control to do it right, but as far as the basic tree structure. if you just want a static tree for navigational purposes you can try this:


1. first make sure you've registered the ActiveX control
2. drag control onto the form
3. name the control something like "TreeViewCtl"
4. paste the following code onto the OnLoad Event


Dim objTree As TreeView
Dim nodRoot As Node
Dim nodCurrent As Node

Set objTree = Me.TreeViewCtl.Object

Set nodRoot = objTree.Nodes.Add(, , "level1item", "Manufacturing and Testing")
Set nodCurrent = objTree.Nodes.Add(nodRoot, tvwChild, "frmBASMAIN", "Boating Man")
Set nodCurrent = objTree.Nodes.Add(nodCurrent, tvwChild, "frmAccessibility", "Accessibility")



Note: that each Set nod..... statement should all be on one line.

hope that helps.
 
Here is the Sample Tree DB

Here is the sample tree DB.

It works on my access2k machine.

Good Luck

Dianna
 

Attachments

Follow Up:

OK - Thanks to all that have helped so far as I know have a working tree view but now I have two additional questions in regards to the tree view control:

1) - I am attempting to use the the image list control to add graphics to the nodes but I keep getting the following error and I'm not sure how to trouble shoot it as I can't find much documentation on it. The error is number 35613: stating, "ImageList must be initialized before it can be used...?"

Any ideas on what I'm doing wrong and how I initialize the image list control?


3)- How do I go about setting up a click event for the nodes? I want to open certain forms depending on which node is clicked but I'm not finding much information on this...

Thank to all for the continued assistance :D

Kev
 
Kevin_S said:
3)- How do I go about setting up a click event for the nodes? I want to open certain forms depending on which node is clicked but I'm not finding much information on this...

In the module of your form the treeview's events can be seen. You are looking for Node_Click.

You can determine what to do by evaluating the clicked node's key.
 
Hi Mile -

I don't see the node_click event either in the forms events, the form detail events, nor the controls events...? What am I missing here..?

I am using the example posted by Dianna above and I don't see the event in here example either however, it looks as though she created an even (Private Sub MyTreeView_NodeClick) which I can do I just didn't know if this was the perferred way to go about setting this up...?

Thank -Kev
 
Kevin_S said:
I don't see the node_click event either in the forms events, the form detail events, nor the controls events...? What am I missing here..? (Private Sub MyTreeView_NodeClick) which I can do I just didn't know if this was the perferred way to go about setting this up...?

In a VB module there are 2 comboboxes at the top - by default they say (General) and (Declarations) or something like that. On the left one select your treeview control and then on the right one the list of events pertaining to that control appear. Select NodeClick.
 
Ahhh Yes :D I'm being a little thick today and I wasn't following your train of thought (got it now)...


Any ideas/thoughts on how to initialize an ImageList control...? I cant seem to get the treeview control to recognize the image list...?

Thanks Mile-
Kev
 
Kevin_S said:
Any ideas/thoughts on how to initialize an ImageList control...? I cant seem to get the treeview control to recognize the image list...?

I have no idea as I've never used an ImageList control. Have you tried the MS Knowledge Base?
 
Yeah - unfortunitely I've been up and down that site without uch help. I'll keep looking...

Thanks for the help ,
Kev
 
Nevermind - I got everything worked out (still being think headed today!)

Thanks to all who posted!
Kev
 
what did you do to initialize the imagelist control. i tried adding it and i'm getting the same initialization error.

thanks
 
Hi There -

You have to bind the ImageList control to the TreeView Control. To do this - place both controls on the form and then in the ImageList property for the TreeView control you have to select the name of your image list from the drop down menu.

Note* The ImageList property for the TreeView Control IS NOT ACCESSED through the standard properties menu for the control (the usually prop. window that has an event, data, other, all tab) but from a special control menu (this is where I got lost also) that is accessed by double-clicking the TreeView Control in design view... This will open up the special properties window and this works for both the TreeView and the Image List Control....


HTH,
Kev
 

Users who are viewing this thread

Back
Top Bottom