以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]筛选问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=105549) |
-- 作者:KWK001 -- 发布时间:2017/8/22 10:03:00 -- [求助]筛选问题 我想通过日期,以及其它的条件同时查询,但是一下代码只能单步查询,求大神优化一下 If e.Form.Controls("TextBox1").Text = "" Then Dim filter As String = "1=1" 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 Tables("入库1").Filter = filter Else Dim txt As String =e.Form.Controls("TextBox1").Text Dim tbl As Table = Tables("入库1") If txt = "" Then tbl.Filter = "" Else txt = "\'%" & txt & "%\'" tbl.Filter = "背番号 Like " & txt & " Or 管理号码 Like " & txt & " Or 产品 Like " & txt End If End If |
-- 作者:KWK001 -- 发布时间:2017/8/22 11:21:00 -- 请看看可以实现吗? 多条件,多列 模糊查询 .NET Framework 版本:2.0.50727.8670 Foxtable 版本:2017.8.18.1 错误所在事件:窗口,橡胶圈入库,Button1,Click 详细错误信息: 从字符串“背番号 Like \'*427*\'”到类型“Long”的转换无效。 输入字符串的格式不正确。 出错? Dim Filter As String With e.Form.Controls("TextBox1") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = "背番号 Like \'*" & .Value & "*\'" Or "管理号码 Like \'*" & .Value & "*\'" Or " 产品Like \'*" & .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("入库1").Filter = Filter End If
[此贴子已经被作者于2017/8/22 11:21:28编辑过]
|
-- 作者:有点甜 -- 发布时间:2017/8/22 11:31:00 --
Filter = "(背番号 Like \'%" & .Value & "%\' Or 管理号码 Like \'%" & .Value & "%\' 产品 Like \'%" & .Value & "%\')"
|