Dale,
Public Sub TreeTest(tvw As MSComctlLib.TreeView)
Dim nd As Node
Dim ndRoot As Node
Set ndRoot = tvw.Nodes.Add(, , "A1", "Node 1")
Set nd = tvw.Nodes.Add(ndRoot, tvwChild, "A2", "Node 1.1")
Set nd = tvw.Nodes.Add(ndRoot, tvwChild, "A3", "Node 1.2")
Set ndRoot = tvw.Nodes.Add(, , "A4", "Node 2")
Set nd = tvw.Nodes.Add(ndRoot, tvwChild, "A5", "Node 2.1")
Set nd = tvw.Nodes.Add(ndRoot, tvwChild, "A6", "Node 2.2")
Set nd = Nothing
Set ndRoot = Nothing
End Sub
If you want to make sure a specific node is visible, then use the following
code:
nd.EnsureVisible
Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
"Dale_Fye via AccessMonster.com" <u43991@uwe> wrote in message
news:86e79ec909542@uwe...
> I'm working on adding a treeview control to a form in my mdb file (using
> Access 2007).
>
> I've added the control and have written some code to populate it. I've
> tried
> this with a recursive subroutine, and it did not work (displayed the root
> nodes but no children), so I'm attempting to populate it with just a
> couple
> of nodes, each with two subordinate nodes, using the following code. I
> get
> no errors when I run this code, but my tree view still only displays the
> root
> level nodes (Node 1 and Node 2), and not the children.
>
> Any help would be greatly appreciated
>
> Public Sub TreeTest(tvw As MSComctlLib.TreeView)
>
> Dim nd As MSComctlLib.Node
> Dim ndRoot As Node
>
> Set nd = tvw.Nodes.Add(, , "A1", "Node 1")
> Set ndRoot = nd
>
> Set nd = tvw.Nodes.Add(ndRoot.Key, tvwChild, "A2", "Node 1.1")
> Set nd = tvw.Nodes.Add(ndRoot.Key, tvwChild, "A3", "Node 1.2")
>
> Set nd = tvw.Nodes.Add(, , "A4", "Node 2")
> Set ndRoot = nd
>
> Set nd = tvw.Nodes.Add(ndRoot.Key, tvwChild, "A5", "Node 2.1")
> Set nd = tvw.Nodes.Add(ndRoot.Key, tvwChild, "A6", "Node 2.2")
>
> End Sub
>
> My settings for the control are:
> Style: 5 - tvwTrelinesPictureText
> LineStyle: 1 - tvwRootLines (no difference when I change this)
> LabelEdit: 0 - tvwAutomatic
> BorderStyle:0 - ccNone
> Appearance:1 - 3D
> Enabled - Checked
> Scroll - Checked
>
> --
> HTH
>
> Dale Fye
>
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/For...dules/200807/1
>