[AccessD] Treeview control

Susan Harkins harkins at iglou.com
Tue Apr 29 10:11:21 CDT 2003


Treeview controlhttp://www.databaseadvisors.com/newletters/newsletter092001/0109UsingTreeViews.htm

Check out this MTM article by Arthur Fuller -- it covers a lot. 

Susan H. 


  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 



------------------------------------------------------------------------------


  _______________________________________________
  AccessD mailing list
  AccessD at databaseadvisors.com
  http://databaseadvisors.com/mailman/listinfo/accessd
  Website: http://www.databaseadvisors.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030429/14abecbc/attachment-0001.html>


More information about the AccessD mailing list