以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]多条件综合过滤模糊查询  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=113570)

--  作者:工匠
--  发布时间:2018/1/18 15:44:00
--  [求助]多条件综合过滤模糊查询
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:多条件综合过滤模糊查询.foxdb

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:多条件综合过滤模糊查询.txt


老师好:
      关于按多列条件综合过滤模糊查询,请帮加入:“品牌产品规格”列按关键字段录入,未录入字段用  ‘ * ’号代替,谢谢!
谢谢!

--  作者:有点甜
--  发布时间: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编辑过]

--  作者:工匠
--  发布时间:2018/1/18 17:00:00
--  
谢谢有点甜老师,这种多条件综合查询可以实现了。
请帮再看看,还有1种情况:
就是要把同时满足这4列录入的条件内容,进行过滤筛选带出都包含这4列录入字段的表内容,如果筛选表内容,不能同时满足4列录入条件的,则筛选值显示为空,并且“品牌产品规格”列要能录入多个候选字段,把 % 号用 * 号代替,(如:*星*1T*)该怎么实现呢,万分感谢!

--  作者:有点甜
--  发布时间: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


--  作者:工匠
--  发布时间:2018/1/18 18:12:00
--  
万分感谢有点甜老师,可以实现了。等我有点成绩了,购买您们家永久版。



图片点击可在新窗口打开查看此主题相关图片如下:弹出窗口.jpg
图片点击可在新窗口打开查看
请老师有时间帮看看,要如何在点击筛选查询时:1.不弹出这个窗口 2.弹出这个窗口,但是不要跟随(form 6eec 5775)

--  作者:有点甜
--  发布时间:2018/1/18 18:19:00
--  
删除msgbox的代码
--  作者:工匠
--  发布时间:2018/1/18 22:16:00
--  
非常感谢老师