以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 【求助】请帮我看看这段模糊筛选代码应该怎么写 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=57736) |
-- 作者:heavenrr -- 发布时间:2014/9/30 11:21:00 -- 【求助】请帮我看看这段模糊筛选代码应该怎么写 我想要做一个筛选窗口,筛选项目包括产品、客户、雇员和起止时间,按照教程里的代码编写完毕后运行没有问题,但是我现在需要做下修改,希望对雇员一项进行模糊检索,比如雇员的全名叫“EP04”,我希望只搜索“04”或“4”就可以完成整个筛选,但是这段代码我不会写了,还请各位前辈给看看,修改一下,谢谢! Dim Filter As String With e.Form.Controls("产品") If .Value IsNot Nothing Then Filter = "产品 = \'" & .Value & "\'" End If End With With e.Form.Controls("客户") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "客户 = \'" & .Value & "\'" End If End With With e.Form.Controls("雇员") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "雇员 = \'" & .Value & "\'" End If End With With e.Form.Controls("日期起") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "日期 >= #" & .Value & "#" End If End With With e.Form.Controls("日期止") 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 |
-- 作者:菲舍尔 -- 发布时间:2014/9/30 11:22:00 -- 把 Filter = Filter & "雇员 = \'" & .Value & "\'" 改成 Filter = Filter & "雇员 like \'%" & .Value & "%\'" 或者 Filter = Filter & "雇员 like \'*" & .Value & "*\'" |
-- 作者:有点甜 -- 发布时间:2014/9/30 11:23:00 -- 原本的 Filter = Filter & "雇员 = \'" & .Value & "\'"
改成 Filter = Filter & "雇员 like \'%" & .Value & "%\'" |
-- 作者:heavenrr -- 发布时间:2014/9/30 11:35:00 -- 非常感谢二位,已按照你们的方法解决问题,再次感谢! |