Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Treeview control!!

Status
Not open for further replies.

hirenJ

Programmer
Dec 17, 2001
72
GB

Hi all, I am trying to use a treeview control as a menu navigation system. The control is only holding text values, that when double clicked open up the appropriate form. There are 4 areas of the system each with their own sub areas (child nodes) that refer to the individual forms.

How do I code this in VBA? I have managed to add parent nodes, but child nodes are proving to be difficult. I am using access 2000, not ODE --- what references do I need to set to fully use the treeview control, and how can I add these child nodes?!!




This is the code I already have...
***********************************************************
Private Sub LoadTreeView()

Dim objTreeView As Control
Dim objNode As Node
Dim x As Integer

Set objTreeView = Me.objTreeView


Set objNode = objTreeView.Nodes.Add()
objNode.Text = "Seminar Manager"



With objTreeView.Nodes
Set objNode = .Add("Seminar Manager", tvwChild)
End With

End Sub
************************************************************



Thankyou

Hiren

:eek:)
 
With objTreeView.Nodes
Set objNode = .Add("Seminar Manager", tvwChild,childkeyhere,"testtodisplayhere",imagehere)
End With

 
just to clarify -- thats what I originally had...
but when the code runs, it adds the parent nodes and then with the child node it gives the "error 35601 -- element not found"

what does this mean? Do I need to set a key for the parent nodes, and if so what format would the key take?

thankyou

Hj

:eek:)

 
I am sorry I did not read the above code close enough yes it appears you do not set a key for the parent

.Add ,,"parentkey","Seminar Manager"
.Add "parentkey",tvwchild,"childkey","child text"

good luck



 
that works!! How Do i know add assign images in an imagelist to the parent nodes , and then add code to open up other forms when double clicking on the child nodes?

ThankyoU!

Hj

:eek:P
 
the image list assigns an index to the image. Simply refer to the image index in the treeview node

.Add ,,"parentkey","Seminar Manager",1
.Add "parentkey",tvwchild,"childkey","child text",2

you can add an additional image if you want the image to change when the node is selected
.Add ,,"parentkey","Seminar Manager",1,3

it depends on how you loaded the tree on how you open the form but generally just use something like

private sub treeview1_dblclick()
dim strcrit as string
stricrit = treeview1.selecteditem
'or use selecteditem.key
docmd.openform "formname",,,,,"field = " strcrit
end sub


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top