以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]筛选查询窗口实现不了 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=91033) |
-- 作者:烟斗木木 -- 发布时间:2016/9/28 8:45:00 -- [求助]筛选查询窗口实现不了 从帮助文档里复制的代码,并进行修改。现情况如下,输入落实人,单击查询,可筛选;选择开始和结束日期,单击筛选,所有行消失。代码如下: Dim Filter As String With RibbonTabs("Workday").Groups("Filter").Items("cmbCustomer") If .Text IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "落实人 = \'" & .Text & "\'" End If End With With RibbonTabs("Workday").Groups("Filter").Items("StartDate") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "发布日期 >= #" & .Value & "#" End If End With With RibbonTabs("Workday").Groups("Filter").Items("EndDate") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "发布日期 <= #" & .Value & "#" End If End With If Filter > "" Then Tables("工作安排").Filter = Filter End If 另外,如何实现筛选包含某名字的行(落实人可能某个表格中有张三李四,此代码只能搜索只含有张三的行,同时包含张三李四的行无法筛选出来)
|
-- 作者:blackzhu -- 发布时间:2016/9/28 8:53:00 -- 本身就是这样呀,你想查询张三,怎么查李四呢? 除非你只查日期. Dim Filter As String With RibbonTabs("Workday").Groups("Filter").Items("cmbCustomer") If .Text IsNot Nothing Then Filter = "落实人 like \'*" & .Text & "*\'" End If End With With RibbonTabs("Workday").Groups("Filter").Items("StartDate") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "发布日期 >= #" & .Value & "#" End If End With With RibbonTabs("Workday").Groups("Filter").Items("EndDate") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "发布日期 <= #" & .Value & "#" End If End With If Filter > "" Then Tables("工作安排").Filter = Filter End If 这样改可以模糊查询名字. |
-- 作者:烟斗木木 -- 发布时间:2016/9/28 8:57:00 -- [求助] 谢谢,谢谢 |