<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Treeview control</TITLE>
<META content="MSHTML 6.00.2800.1141" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=720485014-29042003><FONT face=Arial color=#0000ff
size=2>Shouldn't you move to rsLevel2's first record each time you hit a new
rsLevel1 record?</FONT></SPAN></DIV>
<P><FONT face=Arial><FONT size=2><SPAN
class=720485014-29042003>HTH</SPAN>,</FONT></FONT> </P>
<P><FONT face=Arial size=2>Jim DeMarco</FONT> <BR><FONT face=Arial
size=2>Director of Product Development</FONT> <BR><FONT face=Arial
size=2>HealthSource/Hudson Health Plan</FONT> </P>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Roz Clarke
[mailto:roz.clarke@donnslaw.co.uk]<BR><B>Sent:</B> Tuesday, April 29, 2003
10:47 AM<BR><B>To:</B> 'accessd@databaseadvisors.com'<BR><B>Subject:</B> [AccessD] Treeview control<BR><BR></FONT></DIV>
<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></BLOCKQUOTE><CODE><FONT SIZE=3><BR>
<BR>
***********************************************************************************<BR>
"This electronic message is intended to be for the use only of the named recipient, and may contain information from Hudson Health Plan (HHP) that is confidential or privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited. If you have received this message in error or are not the named recipient, please notify us immediately, either by contacting the sender at the electronic mail address noted above or calling HHP at (914) 631-1611. If you are not the intended recipient, please do not forward this email to anyone, and delete and destroy all copies of this message. Thank You".<BR>
***********************************************************************************<BR>
</FONT></CODE>
</BODY></HTML>