Dim Lbs As String() ={"供货单位","确认付款","金额","日期"} '目錄樹級數
Dim trv As WinForm.TreeView = e.Sender
Dim nd,nd1 As WinForm.TreeNode
Dim flt,s1 As String
Dim n1,Inum As Integer
nd = trv.SelectedNode
For Each nd1 In nd.allNodes '同步子节点选中状态
nd1.Checked = nd.Checked
Next
If nd.ParentNode IsNot Nothing Then '确定父节点选中状态:
For n1 = nd.ParentNode.level To 0 Step -1 '
Inum = nd.ParentNode.Nodes.Count '利用muhua老师的
For Each nd1 In nd.ParentNode.Nodes
Inum+ = Val(nd1.Checked)
Next
nd.ParentNode.Checked = (Inum = 0)
nd = nd.ParentNode
Next
End If
For Each nd In trv.AllNodes
If nd.Level > 0 AndAlso nd.ParentNode.Checked Then '如果父节点选中
Continue For '跳过此节点,处理下一结点
End If
If nd.Checked Then
n1=0
For Each s1 In nd.FullPath.split("\")
flt+ =iif(n1 =0,") Or (" ," and ") & Lbs(n1) & " = '" & s1 & "'"
n1+=1
Next
End If
Next
If flt IsNot Nothing Then
e.Form.Controls("TextBox1").value = flt.Substring(4) & ")"
Tables("疫苗药品入库单").Filter = flt.Substring(4) & ")"
End If