Foxtable(狐表)用户栏目专家坐堂 → 模糊查找


  共有2196人关注过本帖树形打印复制链接

主题:模糊查找

帅哥哟,离线,有人找我吗?
XINYUEMIN
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:146 积分:1301 威望:0 精华:0 注册:2018/1/26 9:23:00
模糊查找  发帖心情 Post By: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
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:146 积分:1301 威望:0 精华:0 注册:2018/1/26 9:23:00
  发帖心情 Post By:2018/8/13 15:09:00 [只看该作者]

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:求助.txt


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By: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
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:146 积分:1301 威望:0 精华:0 注册:2018/1/26 9:23:00
  发帖心情 Post By:2018/8/13 21:52:00 [只看该作者]

提示错误
图片点击可在新窗口打开查看此主题相关图片如下:错误提示.png
图片点击可在新窗口打开查看

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110629 积分:563047 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/8/13 21:59:00 [只看该作者]

Filter = Filter &  "[订车单位] Like '%" & .Value & "%' And [派车单位] Like '%" & .Value & "%'"

 回到顶部
帅哥哟,离线,有人找我吗?
XINYUEMIN
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:146 积分:1301 威望:0 精华:0 注册:2018/1/26 9:23:00
  发帖心情 Post By: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
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:146 积分:1301 威望:0 精华:0 注册:2018/1/26 9:23:00
  发帖心情 Post By:2018/8/13 22:01:00 [只看该作者]

谢谢 有点甜老师

 回到顶部