I spent several Hours on this one myself. To help with the learning curve I did a search via google and found several docs to help me out.
but here it is in a nut shell
Place the treeview control on the form and name it treeview1
this code goes in the form load event
Private Sub Form_Load()
'first you have to add the parent
Treeview1.nodes.add , ,"Parentkey","Parent"
'Then add the child
Treeview1.nodes.add "Parentkey",tvwChild,"Childkey","Child"
'Now a child of the child
Treeview1.nodes.add "Childkey",tvwChild,"Child2key","Child2"
end sub
this is basically the "Hello World" version of the data tree and you will get into things like recursion and such but it is well worth the time to learn it as it is a very powerful feature. You will find it is much more then just for file and folders it is great where ever there is a hierarchy. I use it to show the buildings then the floors located in those buildings then the rooms located on the floor then the equipment located in the rooms then the parts for that equipment ect..
Good luck and hope this helps
Just a note about legal niceties. The TreeView control is not part of Access. The one provided with Visual Basic is not licensed for redistribution as part of an Access application. If you intend to distribute your application, you may be violating your license terms. Rick Sprague
RickSpr,
I have TreeView control installed on my Access Toolbox as part of the standard installation, so does this mean that i can distribute applications with it, or will i still be violating license terms.
I'm pretty sure a TreeView control didn't come as part of my Office 97 or Office 2000 Developer Edition versions of Access. If yours was installed as part of Access, you probably have a license to redistribute it (check the help file for "redistributables" and "license" to be sure). But just being able to install it on the toolbar doesn't mean it's licensed for redistribution. Rick Sprague
What is the best point to call value from the TreeView, i got it to output in the debug window from the form timer, but if i tried to insert the line into any of the controls event procuedures i just got an error message saying that the object variable was not set.
Since I'm not sure what you are attempting to do it is hard to say what the best point is.
Try this example
Private Sub treeview1_DblClick()
dim Retstr as string
retstr = me!treeview1.Object.Selecteditem
msgbox (retstr)
end sub
you can use several of the objects events to do just about anything.
I suggest you do a search on treeview and you will find many fine examples. I spent several days before I felt like I had mastered it.
Thats just about what i wanted, i didn't know you could use the same call events as on a normal control, because they arent listed in the properties box.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.