以文本方式查看主题
- Foxtable(狐表) (http://foxtable.net/bbs/index.asp)
-- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2)
---- 模糊查找 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=123372)
|
-- 作者:XINYUEMIN
-- 发布时间:2018/8/13 14:45:00
-- 模糊查找
帮忙看一下下面代码哪里出错了
Dim aa As WinForm.TextBox = e.Form.Controls("TextBox3") Dim Filter As String Dim Ast() As String = {"订车单位","派车单位"} For Each a As String In Ast If .Value IsNot Nothing Then
If Filter > "" Then Filter = Filter & " Or " End If Filter = Filter & "[" & a & "] Like \'%" & aa.value & "%\'" Next With e.Form.Controls("TextBox3") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "[订车单位] Like \'%" & .Value & "%\'" And "[派车单位] Like \'%" & .Value & "%\'" End If End With With e.Form.Controls("DateTimePicker1") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "实际用车日期_起 >= #" & .Value & "#" End If End With With e.Form.Controls("DateTimePicker2") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "实际用车日期_起 <= #" & .Value & "#" End If End With If e.Form.Controls("已付款").Checked = True \' 如果付款状态选择了"已付" If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "派车单位结算_租金结算 = True" End If If e.Form.Controls("未付款").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
|
-- 作者:XINYUEMIN
-- 发布时间:2018/8/13 15:09:00
--
|
-- 作者:有点甜
-- 发布时间:2018/8/13 15:45:00
--
Dim aa As WinForm.TextBox = e.Form.Controls("TextBox3") Dim Filter As String Dim str As String Dim Ast() As String = {"订车单位","派车单位"} For Each a As String In Ast If str > "" Then str = str & " Or " End If str = str & "[" & a & "] Like \'%" & aa.value & "%\'" Next If str > "" Then filter = "(" & str & ")" End If With e.Form.Controls("TextBox3") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "[订车单位] Like \'%" & .Value & "%\'" And "[派车单位] Like \'%" & .Value & "%\'" End If End With With e.Form.Controls("DateTimePicker1") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "实际用车日期_起 >= #" & .Value & "#" End If End With With e.Form.Controls("DateTimePicker2") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "实际用车日期_起 <= #" & .Value & "#" End If End With If e.Form.Controls("已付款").Checked = True \' 如果付款状态选择了"已付" If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "派车单位结算_租金结算 = True" End If If e.Form.Controls("未付款").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
|
-- 作者:XINYUEMIN
-- 发布时间:2018/8/13 21:52:00
--
提示错误 此主题相关图片如下:错误提示.png
|
-- 作者:有点蓝
-- 发布时间:2018/8/13 21:59:00
--
Filter = Filter & "[订车单位] Like \'%" & .Value & "%\' And [派车单位] Like \'%" & .Value & "%\'"
|
-- 作者:XINYUEMIN
-- 发布时间:2018/8/13 22:01:00
--
删除下面代码可以了
With e.Form.Controls("TextBox3") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "[订车单位] Like \'%" & .Value & "%\'" And "[派车单位] Like \'%" & .Value & "%\'" End If End With
|
-- 作者:XINYUEMIN
-- 发布时间:2018/8/13 22:01:00
--
谢谢 有点甜老师
|