筛选的问题,代码改为:
Dim trv As WinForm.TreeView = e.Sender
Dim flt As String
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim pd As WinForm.TreeNode = nd.ParentNode
Do
If pd Is Nothing Then
Exit Do
End If
If pd.Checked Then
Continue For
Else
pd = pd.ParentNode
End If
Loop
If nd.Checked Then
If flt > "" Then
flt = flt & " Or " '注意用or而不是And
End If
If nd.Level = 0 Then '注意下面的条件都要用括号括起来
flt = flt & "( 入职年份 = '" & nd.Text & "')"
ElseIf nd.level = 1 Then
flt = flt & "( 入职年份 = '" & nd.ParentNode.Text & "' And 部门 = '" & nd.Text & "')"
ElseIf nd.level = 2 Then
flt = flt & "( 入职年份 = '" & nd.parentNode.ParentNode.Text & "' And 部门 = '" & nd.ParentNode.Text & "' And 办公室 = '" & nd.Text & "')"
ElseIf nd.level = 3
flt = flt & "( 入职年份 = '" & nd.parentNode.parentNode.ParentNode.Text & "' And 部门 = '" & nd.parentNode.ParentNode.Text & "' And 办公室 = '" & nd.parentNode.Text & "' And 性别 = '" & nd.Text & "')"
End If
End If
Next
Tables("表A").Filter = flt
你搞得也太复杂了,太多层的最好不要多选,单选就行:
http://www.foxtable.com/help/topics/0917.htm