Jim DeMarco
Jdemarco at hshhp.org
Tue Apr 29 09:51:50 CDT 2003
Shouldn't you move to rsLevel2's first record each time you hit a new rsLevel1 record? HTH, Jim DeMarco Director of Product Development HealthSource/Hudson Health Plan -----Original Message----- From: Roz Clarke [mailto:roz.clarke at donnslaw.co.uk] Sent: Tuesday, April 29, 2003 10:47 AM To: 'accessd at databaseadvisors.com' Subject: [AccessD] Treeview control Hi all 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. 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. Private Sub Form_Open(Cancel As Integer) Dim db As Database Set db = CurrentDb Dim nd As Node Dim cnn As New ADODB.Connection Set cnn = CurrentProject.Connection Dim rsLevel1 As New ADODB.Recordset rsLevel1.Open "qryTopLevelTasks", cnn, adOpenKeyset, adLockOptimistic Dim rsLevel2 As New ADODB.Recordset rsLevel2.Open "qry2ndLevelTasks", cnn, adOpenKeyset, adLockOptimistic Dim intIndex As Integer rsLevel1.MoveFirst 'add all the top level nodes (tasks with no child records) Do Until rsLevel1.EOF = True Set nd = Treeview.Nodes.Add() nd.Text = rsLevel1!tsk_Description intIndex = nd.Index 'add all the 2nd level nodes matching this as parent task Do Until rsLevel2.EOF = True If rsLevel2!tsk_ParentTaskID = rsLevel1!tsk_TaskID Then Set nd = Treeview.Nodes.Add(intIndex, tvwChild) nd.Text = rsLevel2!tsk_Description End If rsLevel2.MoveNext Loop rsLevel1.MoveNext Loop End Sub Stepping through the code, the indices match between the parent and child records and no error comes up. TIA Roz *********************************************************************************** "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". *********************************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030429/47496837/attachment-0001.html>