Foxtable(狐表)用户栏目专家坐堂 → [求助]多条件综合过滤模糊查询


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

主题:[求助]多条件综合过滤模糊查询

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/1/18 16:32:00 [显示全部帖子]

Dim Filter As String
With e.Form.Controls("省份")
    If .Value IsNot Nothing Then
        Filter = "省份 in ('" & .value.replace(",","','") & "')"
    End If
End With
With e.Form.Controls("区域")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter &= "区域 in ('" & .value.replace(",","','") & "')"
    End If
End With
With e.Form.Controls("产品类")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter &= "产品类 in ('" & .value.replace(",","','") & "')"
    End If
End With
With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Dim str As String = "1=1"
        For Each s As String In .value.split("*")
            If s > "" Then
                str &= " and 品牌产品规格 like '%" & s & "%'"
            End If
        Next
        Filter = filter & "(" & str & ")"
    End If
End With

msgbox(filter)
Tables("表A").Filter = Filter

[此贴子已经被作者于2018/1/18 17:20:39编辑过]

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/1/18 17:21:00 [显示全部帖子]

Dim Filter As String
With e.Form.Controls("省份")
    If .Value IsNot Nothing Then
        Filter = "省份 in ('" & .value.replace(",","','") & "')"
    End If
End With
With e.Form.Controls("区域")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter &= "区域 in ('" & .value.replace(",","','") & "')"
    End If
End With
With e.Form.Controls("产品类")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter &= "产品类 in ('" & .value.replace(",","','") & "')"
    End If
End With
With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Dim str As String = "1=1"
        For Each s As String In .value.split("*")
            If s > "" Then
                str &= " and 品牌产品规格 like '%" & s & "%'"
            End If
        Next
        Filter = filter & "(" & str & ")"
    End If
End With

msgbox(filter)
Tables("表A").Filter = Filter


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/1/18 18:19:00 [显示全部帖子]

删除msgbox的代码

 回到顶部