|
2#
楼主 |
发表于 2015-1-26 16:31:59
|
只看该作者
代码是这样的:
'==================================
'加载Treeview - DBOM
'==================================
Sub DBOMTreeAdd(ByVal lngProductID As Long, ByRef objTree As TreeView)
Dim db As dao.Database
Dim rst As dao.Recordset
Dim nodCurrent As node
Dim strText$
Dim bk$
Set rst = CurrentDb.OpenRecordset("tblBOM_Design")
'清空所有树
objTree.Nodes.Clear
'查找第一个符合标准的值
rst.FindFirst " FMainID=" & lngProductID
Do Until rst.NoMatch
strText = "[" & DLookup("[FProductCode] & '-' & [FNote]", "tblProduct", "FProductID=" & rst!FChildID) & _
"]--配额:" & rst!FQty & _
IIf(IsNull(rs!FNote), "", ";" & rst!FNote)
bk = rst.Bookmark
objTree.Nodes.Add , , "a" & rst!FDBOMID, strText, 1, 2
nodCurrent.Expanded = True
rst.Bookmark = bk
rst.FindNext "FMainID=" & lngMaterialID
Loop
Exit_BOMTreeAdd:
Set rst = Nothing
End Sub |
|