以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  多字段模糊查询问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=102840)

--  作者:bootes29
--  发布时间:2017/6/26 17:28:00
--  多字段模糊查询问题
各位老师晚上好,我又来给大家添麻烦了,
如图,下面我想 多个字段加空格 模糊查询,
比如:我想查包含:“大”“丽”“版” 三个字符 都有的,帮助里有模糊
查询:
Dim txt As String = e.Form.Controls("TextBox1").Text
Dim tbl As Table = Tables("表a")
If txt = "" Then
    tbl.Filter = ""
Else
    txt = "\'%" & txt & "%\'"
    tbl.Filter = "第一列 Like " & txt 
End If

Dim tbl As Table = Tables("表a")
If e.KeyCode = Keys.Up Then
    tbl.Position = tbl.Position - 1
    e.Cancel = True
ElseIf e.KeyCode = Keys.Down Then
    tbl.Position = tbl.Position + 1
    e.Cancel = True
ElseIf e.KeyCode = Keys.Enter Then
    If tbl.Current IsNot Nothing Then
        Tables("表a").Current("第一列") = tbl.Current("第一列")
    End If
    e.Cancel = True    
    e.Form.Close()
End If

可是这个只能查一个字段,请问老师该如何解决?
图片点击可在新窗口打开查看此主题相关图片如下:未标题-2 拷贝.jpg
图片点击可在新窗口打开查看

--  作者:bootes29
--  发布时间:2017/6/26 17:29:00
--  
这是table
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1216.table


--  作者:有点色
--  发布时间:2017/6/26 18:30:00
--  

textchanged事件

 

Dim txt As String = e.Form.Controls("TextBox1").Text
Dim tbl As Table = Tables("表a")
If txt = "" Then
    tbl.Filter = ""
Else
    Dim filter As String = "1=1"
    For Each s As String In txt.Split(" ")
        Filter &= " and 第一列 Like \'%" & s & "%\'"       
    Next
    tbl.filter = filter
End If


--  作者:bootes29
--  发布时间:2017/6/26 18:36:00
--  
太牛了,有点色 老师。
这个 filter =“1=1” 这是表达的什么?


--  作者:有点色
--  发布时间:2017/6/26 18:42:00
--  
 为了和后面的条件进行连接 1=1 and 条件2 and 条件3 ,如果不写,就多一个and
--  作者:bootes29
--  发布时间:2017/6/26 20:24:00
--  
感谢有点色老师,开眼界了
--  作者:bootes29
--  发布时间:2017/6/26 20:31:00
--  
Dim txt As String = e.Form.Controls("TextBox1").Text
Dim tbl As Table = Tables("查询_Table1")
If txt = "" Then
    tbl.Filter = ""
Else
    Dim filter As String = "1=1"
    For Each s As String In txt.Split(" ")
        Filter &= " and 线路名称 Like \'%" & s & "%\' and 备注 Like \'%" & s & "%\'"        
    Next
    tbl.filter = filter
End If

老师好,为啥,我加了一个备注 列 没有起作用?

--  作者:bootes29
--  发布时间:2017/6/26 20:34:00
--  
知道了 and  应该改成 or  对不对?老师
--  作者:2900819580
--  发布时间:2017/6/26 20:37:00
--  
代码好像没有问题,如果没有显示,那就是你的备注列没有相应的内容
--  作者:有点蓝
--  发布时间:2017/6/26 21:09:00
--  
 and  应该改成 or