以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]想做一个筛选窗口,认为未填写内容的单元格都符合筛选条件,请问如何实现?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=115823)

--  作者:1452565001
--  发布时间:2018/3/15 10:45:00
--  [求助]想做一个筛选窗口,认为未填写内容的单元格都符合筛选条件,请问如何实现?

想自己做一个筛选窗口,希望显示出符合筛选条件的单元格所在的行,认为空的单元格是符合条件的。

我写的筛选代码是这样的:

DataTables("b1").Save()
Dim Filter1 As String
With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        Filter1 = "a1 <= \'" & .Value & "\' or a1 is null"
    End If
End With
With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If Filter1 >"" Then
            Filter1 = Filter1 & " And "
        End If
        Filter1 = Filter1 & "a21 >= \'" & .Value & "\' or a21 is null"
    End If
End With
With e.Form.Controls("TextBox2")
    If .Value IsNot Nothing Then
        If Filter1 >"" Then
            Filter1 = Filter1 & " And "
        End If
        Filter1 = Filter1 & "a11 >= \'" & .Value & "\' or a11 is null"
    End If
End With
With e.Form.Controls("ComboBox6")
    If .Value IsNot Nothing Then
        If Filter1 >"" Then
            Filter1 = Filter1 & " And "
        End If
        Filter1 = Filter1 & "a17 like \'%" & .Value & "%\' or a17 is null"
    End If
End With
If Filter1 > "" Then
    Tables("a1").Filter = Filter1
End If

但是这个的效果是如果筛选了两个或两个以上的条件就会显示所有的筛选列中空单元格所在行,即便这行里有单元格里的内容是不符合其他筛选条件的。

我希望可以达到筛选之后显示满足所有筛选条件的行,请问该如何修改?


--  作者:有点甜
--  发布时间:2018/3/15 10:53:00
--  

or 条件,要加上括号

 

DataTables("b1").Save()
Dim Filter1 As String
With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        Filter1 = "(a1 <= \'" & .Value & "\' or a1 is null)"
    End If
End With
With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If Filter1 >"" Then
            Filter1 = Filter1 & " And "
        End If
        Filter1 = Filter1 & "(a21 >= \'" & .Value & "\' or a21 is null)"
    End If
End With
With e.Form.Controls("TextBox2")
    If .Value IsNot Nothing Then
        If Filter1 >"" Then
            Filter1 = Filter1 & " And "
        End If
        Filter1 = Filter1 & "(a11 >= \'" & .Value & "\' or a11 is null)"
    End If
End With
With e.Form.Controls("ComboBox6")
    If .Value IsNot Nothing Then
        If Filter1 >"" Then
            Filter1 = Filter1 & " And "
        End If
        Filter1 = Filter1 & "(a17 like \'%" & .Value & "%\' or a17 is null)"
    End If
End With
If Filter1 > "" Then
    Tables("a1").Filter = Filter1
End If


--  作者:1452565001
--  发布时间:2018/3/15 11:09:00
--  
谢谢!