|
楼主 |
发表于 2012-11-5 15:37
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub tree()
Dim Rec As New ADODB.Recordset
Dim stRecQL As String
Dim Item As Integer
Dim i As Integer
Dim nodeindex As Node
Set nodeindex = TreeView.Nodes.Add(, , "爷", "楦号")
nodeindex.Sorted = True
Rec.Open "BOM楦号表", CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdTableDirect
For i = 0 To Rec.RecordCount - 1
Set nodeindex = TreeView.Nodes.Add("爷", tvwChild, "父" & Rec.Fields("楦号ID"), Rec.Fields("楦号"))
nodeindex.Sorted = True
Rec.MoveNext
Next
Rec.Close
Rec.Open "BOM型体表", CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdTableDirect
For i = 0 To Rec.RecordCount - 1
Set nodeindex = TreeView.Nodes.Add("父" & Rec.Fields("所属楦号"), tvwChild, "子" & Rec.Fields("型体ID"), Rec.Fields("型体"))
nodeindex.Sorted = True
Rec.MoveNext
Next
Rec.Close
Rec.Open "BOM款号", CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdTableDirect
For i = 0 To Rec.RecordCount - 1
Set nodeindex = TreeView.Nodes.Add("子" & Rec.Fields("所属型体"), tvwChild, "孙" & Rec.Fields("款号ID"), Rec.Fields("款号"))
nodeindex.Sorted = True
Rec.MoveNext
Next
Rec.Close
Me.TreeView.Nodes(1).Expanded = True
End Sub |
|