在大家的基础上再改一下:
Dim nms As String() ={"产品","客户","雇员","折扣","日期"}
Dim trv As WinForm.TreeView = e.Sender
Dim flt As String
Dim nd As WinForm.TreeNode
Dim pd As WinForm.TreeNode
For Each nd In e.node.allNodes
nd.Checked = False
Next
pd = e.Node.ParentNode
Do
If pd Is Nothing Then
Exit Do
Else
pd.Checked = False
pd = pd.ParentNode
End If
Loop
For Each nd In trv.AllNodes
If nd.Checked Then
Dim rts() As String = nd.FullPath.Split("\")
Dim val As String = ""
For i As Integer = 0 To rts.length -1
If val > "" Then
val = val & " And "
End If
val = val & nms(i) & " = '" & rts(i) & "'"
Next
If flt > "" Then
flt = flt & " Or (" & val & ")"
Else
flt = val
End If
End If
Next
Tables("订单").Filter = flt