|
这是这个过程的部分代码,框架作为查询条件输入,直至展示10级树枝。
Sub sx()
Dim stRecQL As String
Dim Item As Integer
Dim i As Integer
Dim nodindex As Node
Dim lianjie As String
Dim lianjie_a As String
'* -----------------------------------------------------------------
'* 定义各类
'* -----------------------------------------------------------------
Select Case Forms![khgl_z]![框架5]
Case 1
lianjie = "and (convert(datetime,right(left(报价编号,9),8),102)>='" & Forms![khgl_z]!Text171 & "'and " & _
"convert(datetime,right(left(报价编号,9),8),102)<='" & Forms![khgl_z]!Text173 & "') and 报价编号 like '%" & Trim(Forms![khgl_z]!Combo184) & "%'"
Case 2
lianjie = "and (convert(datetime,right(left(报价编号,9),8),102)>='" & Forms![khgl_z]!Text171 & "'and " & _
"convert(datetime,right(left(报价编号,9),8),102)<='" & Forms![khgl_z]!Text173 & "') and 助记码 like '%" & Trim(Forms![khgl_z]!Combo184) & "%'"
Case 3
lianjie = "and (convert(datetime,right(left(报价编号,9),8),102)>='" & Forms![khgl_z]!Text171 & "'and " & _
"convert(datetime,right(left(报价编号,9),8),102)<='" & Forms![khgl_z]!Text173 & "') and 询单单号 like '%" & Trim(Forms![khgl_z]!Combo184) & "%'"
Case 4
lianjie = "and (convert(datetime,right(left(报价编号,9),8),102)>='" & Forms![khgl_z]!Text171 & "'and " & _
"convert(datetime,right(left(报价编号,9),8),102)<='" & Forms![khgl_z]!Text173 & "') and 操作员 like '%" & Trim(Forms![khgl_z]!Combo184) & "%'"
Case 5
lianjie = "and (convert(datetime,right(left(报价编号,9),8),102)>='" & Forms![khgl_z]!Text171 & "'and " & _
"convert(datetime,right(left(报价编号,9),8),102)<='" & Forms![khgl_z]!Text173 & "') and 报价员 like '%" & Trim(Forms![khgl_z]!Combo184) & "%'"
End Select
lianjie_a = "select id from baojia_sx where id1 in (select id from baojia_sx where id1 is null " & lianjie & ""
'设置最顶级的"爷"
'* ---------------------------
Set nodindex = TreeView.Nodes.Add(, , "爷", "报价单列表", "K1", "K2")
nodindex.Sorted = False '*这个是排序,true升序false降序
'* -----------------------------------------------------------------
'*这里的设置跟第一小时里基本是一样的
'*但最后多了一个"K2"的参数,"K1"代表的是未被选中时的图标,"K2"代表是被选中后的图标
'*仔细观察一下,你会发现选中和没选中的图标是不一样的,一个是一个文件夹,一个是一个打开的文件夹
'* -----------------------------------------------------------------
'设置第二级"父"
'* ---------------------------
OpenRS1 "select * from baojia_sx where id1 is null " & lianjie & "ORDER BY id desc", rs
For i = 0 To rs.RecordCount - 1
Set nodindex = TreeView.Nodes.Add("爷", tvwChild, "父" & rs("id"), rs("编号"), "K1", "K2")
nodindex.Sorted = True
rs.MoveNext
Next
rs.Close
'* -----------------------------------------------------------------
'*第一行意思是打开一个表去寻找数据(查询也是可以的)
'*关键在与Add参数的变化
'*大家看第三个参数,在第一小时里,这里是"父1",这里用Rec.Fields("大区ID")来代替"1",意思是用表的编号来代替手工编号
'*第四个参数也是一样,直接用表中的名称字段来取代原来我们手工的命名
'* -----------------------------------------------------------------
'设置第三级"子"
'* ---------------------------
OpenRS1 "select * from baojia_sx where id1 in (select id from baojia_sx where id1 is null " & lianjie & ") ", Rs1
For i = 0 To Rs1.RecordCount - 1
Set nodindex = TreeView.Nodes.Add("父" & Rs1("id1"), tvwChild, "子" & Rs1("id"), Rs1("编号"), "K1", "K2")
nodindex.Sorted = True
Rs1.MoveNext
Next
Rs1.Close
|
|