Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
For Each nd As WinForm.TreeNode In trv.AllNodes
nd.Checked = not nd.Checked
Next
Dim nms As String() = {"产品","客户"} '指定生成目录树的各列
Dim qts As String() = {"'","'"} '指定将各列的值括起来的符号,这里都是字符型,所以都是单引号
Dim flt As String = ""
For Each nd As WinForm.TreeNode In trv.AllNodes
If nd.Checked AndAlso nd.level = 1 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) & " = " & qts(i) & rts(i) & qts(i)
Next
If flt > "" Then
flt = flt & " Or (" & val & ")"
Else
flt = val
End If
End If
Next
Tables("订单").Filter = flt