以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  多值字段查询请教  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=103946)

--  作者:wanzijiayou
--  发布时间:2017/7/20 10:32:00
--  多值字段查询请教

您好,我在多值字段查询上遇到了问题.

 

表中比如添加多值字段A|B|C|D,在筛选的时候代码如下:

 

With e.Form.Controls("cmdGeneName")
    If .Value IsNot Nothing Then
Dim txt As String = "\'%" & .Value & "%\'"
        If Filter> "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & ("基因名称 Like " & txt)
    End If
End With


问题是:我必须按顺序选择,A,B才能筛选出来,如果先选B,再选A就查不出来,请问有什么解决办法?即使打乱顺序选择也能筛选出来,在线等,谢谢


--  作者:有点甜
--  发布时间:2017/7/20 10:39:00
--  
With e.Form.Controls("cmdGeneName")
    If .Value IsNot Nothing Then
        If Filter> "" Then
            Filter = Filter & " And "
        End If
        Dim txt As String = "1=1"
        For Each s As String In .value.split(",")
            txt = txt & " and 基因名称 like \'%" & s & "%\'"
        Next
        Filter = Filter & txt
    End If
End With

--  作者:wanzijiayou
--  发布时间:2017/7/20 10:48:00
--  
非常感谢您,有点甜老师,代码没问题。