[AccessD] Treeview control

Drew Wutka DWUTKA at marlow.com
Tue Apr 29 13:47:04 CDT 2003


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.
 
Drew

-----Original Message-----
From: Roz Clarke [mailto:roz.clarke at donnslaw.co.uk]
Sent: Tuesday, April 29, 2003 9: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 

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


More information about the AccessD mailing list