<!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.2722.900" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=505194618-29042003><FONT face=Arial color=#0000ff size=2>I may
be WAY off on this, but whenever I use a treeview, I assign my own key, and
text, with the .Add function. It doesn't look like you are assigning
keys.</FONT></SPAN></DIV>
<DIV><SPAN class=505194618-29042003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=505194618-29042003><FONT face=Arial color=#0000ff
size=2>Drew</FONT></SPAN></DIV>
<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
9: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></BODY></HTML>