以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]请问老师筛选的问题代码  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=99558)

--  作者:biaoai2011
--  发布时间:2017/4/21 12:53:00
--  [求助]请问老师筛选的问题代码
请问老师:我在筛选的条件里放置了组合框,当我选定多项数据的时候就筛选不出数据,如果只选定一项数据的时候就能筛选得出。是我的代码哪里写错了吧?请老师帮我看看。
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:查询.rar


--  作者:有点色
--  发布时间:2017/4/21 14:15:00
--  

改一下代码

 

Dim Filter As String
With e.Form.Controls("序号1")
    If .Value IsNot Nothing Then
        Filter = "序号 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("年度1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "年度 in (\'" & .Value.replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("季度1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "季度 in (\'" & .Value.replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("道路名称1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "道路名称 in (\'" & .Value.replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("隐患地名1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "隐患地名 = \'" & .Value & "\'"
    End If
End With
If e.Form.Controls("yizhenggai").Checked = True \' 如果付款状态选择了"已整改"
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "是否整改 = True"
End If
If e.Form.Controls("quanbu").Checked = True \' 如果付款状态选择了"全部" Then
Tables("道路隐患表").ApplyFilter = False
End If
If e.Form.Controls("weizhenggai").Checked = True \' 如果付款状态选择了"未整改"
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "是否整改 = False Or 是否整改 Is Null"
End If
If Filter > "" Then
    Tables("道路隐患表").Filter = Filter
End If