|
3#
楼主 |
发表于 2011-4-20 16:29:51
|
只看该作者
Private Sub Form_Load() '加载树内容
Dim objNode As Node
Dim rst As DAO.Recordset
Dim MaxLevel As Integer '最大级别
Dim i As Integer
Set objTree = Me.TreeView0.Object
objTree.Nodes.Clear '这句不可少
Set objNode = objTree.Nodes.Add(, , "NO.1", "存货档案", "K1", "K2") ' 设置最顶层
MaxLevel = CurrentDb.OpenRecordset("SELECT DBO_存货分类.层数 FROM DBO_存货分类 order by DBO_存货分类.层数 desc;")(0).Value
For i = 1 To MaxLevel
Set rst = CurrentDb.OpenRecordset("SELECT DBO_存货分类.层数,DBO_存货分类.存货分类编码,DBO_存货分类.存货分类名称 FROM DBO_存货分类 where DBO_存货分类.层数=" & i & ";")
Do Until rst.EOF
If rst!层数 = 1 Then '顶层菜单
Set objNode = objTree.Nodes.Add("NO.1", 4, "NO." & Trim(rst!存货分类编码), Trim(rst!存货分类名称), "K1", "K2")
Else
Set objNode = objTree.Nodes.Add("NO." & Left(rst!存货分类编码, (rst!层数 - 1) * perSectionLong), 4, "NO." & Trim(rst!存货分类编码), Trim(rst!存货分类名称), "K1", "K2")
End If
rst.MoveNext
Loop
Next
Me.TreeView0.Nodes(1).Expanded = True
Call TreeView0_NodeClick(objTree.Nodes(1))
End Sub
以上代码是mdb加载树节点的,我想转到ADP中不知怎样改? |
|