标题: 请教树形控件加载数据的问题! [打印本页] 作者: 6831860 时间: 2006-8-23 06:46 标题: 请教树形控件加载数据的问题! Sub loadtree()
Dim objnodes As Node
Dim rst As DAO.Recordset
Dim rs As DAO.Recordset
Dim i, j As Integer
Set objtree = TreeView6.Object
objtree.nodes.Clear
Set objnodes = objtree.nodes.Add(, , "No.1", "所有客户")
Set rst = CurrentDb.OpenRecordset("client查询")
Set rs = CurrentDb.OpenRecordset("client 查询")
For i = 0 To rst.RecordCount - 1
Set objnode = objtree.nodes.Add("No.1", tvwChild, "父" & rst.Fields("TypName"), rst.Fields("TypName"))
Debug.Print rst.Fields("TypName")
rs.MoveFirst
For j = 1 To rs.RecordCount
Debug.Print rs.Fields("TypName")
If rst.Fields("TypName") = rs.Fields("TypName") Then
Set objnode = objtree.nodes.Add("父" & rst.Fields("TypName"), tvwChild, "子" & rs.Fields("name"), rs.Fields("name"))
End If
rs.MoveNext
Next
rst.MoveNext
Next
rst.Close
rs.Close
End Sub