以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]筛选时带*号就出错 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=174973) |
-- 作者:hbkongxin -- 发布时间:2022/2/14 9:41:00 -- [求助]筛选时带*号就出错 这个代码我是设置在窗口全局事件 TEXTCHANGED里的,哪里有问题吗 Dim Filter As String With e.Form.Controls("业务员") If .text IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "业务员 like \'%" & .text & "%\'" End If End With With e.Form.Controls("客户") If .text IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "客户 like \'%" & .text & "%\'" End If End With With e.Form.Controls("花号") If .text IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "花号 like \'%" & .text & "%\'" End If End With With e.Form.Controls("面料") If .text IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "面料 like \'%" & .text & "%\'" End If End With |
-- 作者:有点蓝 -- 发布时间:2022/2/14 9:49:00 -- 比如:Filter = Filter & "花号 like \'%" & .text.replace("*","[*]") & "%\'" 在字符串的中间不允许使用通配符。例如,不允许 \'赫*丰\',也不允许 \'赫%丰\'。 由于* 和 % 默认作为通配符,如果要将其作为比较内容的一部分,必须用方括号括起来,例如: [型号] Like \'A[*]%\' 表示型号以“A*”开头。 |
-- 作者:hbkongxin -- 发布时间:2022/2/14 9:58:00 -- 嗖嘎,感谢蓝老师 |