<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Treeview control</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2><A
href="http://www.databaseadvisors.com/newletters/newsletter092001/0109UsingTreeViews.htm">http://www.databaseadvisors.com/newletters/newsletter092001/0109UsingTreeViews.htm</A></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Check out this MTM article by Arthur Fuller -- it
covers a lot. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Susan H. </FONT></DIV>
<DIV><BR> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<P><FONT face=Arial size=2>Hi all</FONT> </P>
<P><FONT face=Arial size=2>I've been playing with the treeview control (v6)
for the first time today. I've worked my way through an MS tutorial, adapting
it to suit my purposes.</FONT></P>
<P><FONT face=Arial size=2>Can anyone help explain why the following code,
which should give me 2 levels on the tree, only gives me the 1st level? None
of the child nodes appear.</FONT></P>
<P><FONT face=Arial size=2>Private Sub Form_Open(Cancel As Integer)</FONT>
<BR><FONT face=Arial size=2>Dim db As Database</FONT> <BR><FONT face=Arial
size=2>Set db = CurrentDb</FONT> </P>
<P><FONT face=Arial size=2>Dim nd As Node</FONT> </P>
<P><FONT face=Arial size=2>Dim cnn As New ADODB.Connection</FONT> <BR><FONT
face=Arial size=2>Set cnn = CurrentProject.Connection</FONT> </P>
<P><FONT face=Arial size=2>Dim rsLevel1 As New ADODB.Recordset</FONT>
<BR><FONT face=Arial size=2>rsLevel1.Open "qryTopLevelTasks", cnn,
adOpenKeyset, adLockOptimistic</FONT> </P>
<P><FONT face=Arial size=2>Dim rsLevel2 As New ADODB.Recordset</FONT>
<BR><FONT face=Arial size=2>rsLevel2.Open "qry2ndLevelTasks", cnn,
adOpenKeyset, adLockOptimistic</FONT> </P>
<P><FONT face=Arial size=2>Dim intIndex As Integer</FONT> </P>
<P><FONT face=Arial size=2>rsLevel1.MoveFirst</FONT> </P>
<P><FONT face=Arial size=2>'add all the top level nodes (tasks with no child
records)</FONT> <BR><FONT face=Arial size=2>Do Until rsLevel1.EOF =
True</FONT> <BR><FONT face=Arial
size=2> Set nd =
Treeview.Nodes.Add()</FONT> <BR><FONT face=Arial
size=2> nd.Text =
rsLevel1!tsk_Description</FONT> <BR><FONT face=Arial
size=2> intIndex = nd.Index</FONT>
<BR><FONT face=Arial size=2> 'add
all the 2nd level nodes matching this as parent task</FONT> <BR><FONT
face=Arial size=2> Do Until
rsLevel2.EOF = True</FONT> <BR><FONT face=Arial
size=2> If
rsLevel2!tsk_ParentTaskID = rsLevel1!tsk_TaskID Then</FONT> <BR><FONT
face=Arial
size=2>
Set nd = Treeview.Nodes.Add(intIndex, tvwChild)</FONT> <BR><FONT face=Arial
size=2>
nd.Text = rsLevel2!tsk_Description</FONT> <BR><FONT face=Arial
size=2> End
If</FONT> <BR><FONT face=Arial
size=2>
rsLevel2.MoveNext</FONT> <BR><FONT face=Arial
size=2>
Loop </FONT><BR><FONT face=Arial
size=2> rsLevel1.MoveNext</FONT>
<BR><FONT face=Arial size=2>Loop</FONT> </P>
<P><FONT face=Arial size=2>End Sub</FONT> </P>
<P><FONT face=Arial size=2>Stepping through the code, the indices match
between the parent and child records and no error comes up.</FONT> </P>
<P><FONT face=Arial size=2>TIA</FONT> </P>
<P><FONT face=Arial size=2>Roz</FONT> </P>
<P>
<HR>
<P></P>_______________________________________________<BR>AccessD mailing
list<BR>AccessD@databaseadvisors.com<BR>http://databaseadvisors.com/mailman/listinfo/accessd<BR>Website:
http://www.databaseadvisors.com<BR></BLOCKQUOTE></BODY></HTML>