以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  关于组合查询问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=101598)

--  作者:benwong2013
--  发布时间:2017/6/3 17:22:00
--  关于组合查询问题
在模糊查询设置的是如下:

1. 希望文本框1输入一个条件之后可以同时在多个栏位A,B,C,D中查询;
2.希望文本框2 和文本框3输入不同的内容都在固定栏位E中查询;

最终查询结果如下:

A or B or C or D And E(文本框2)
A or B or C or D And E(文本框3)

请问这个代码应该如何处理?

--  作者:有点蓝
--  发布时间:2017/6/3 17:51:00
--  
参考:http://www.foxtable.com/webhelp/scr/1058.htm

With e.Form.Controls("cmbCustomer")
    
If .Value IsNot Nothing Then
        
If Filter > "" Then
            Filter = Filter & 
" And "
        
End If
        Filter = Filter & 
"客户 = \'" & .Value & "\' or 列2 = \'" & .Value & "\' or 列3 = \'" & .Value & "\'"
    
End If
End
 With

--  作者:benwong2013
--  发布时间:2017/6/3 21:45:00
--  
若是模糊查询应该如何处理?
--  作者:zoyong
--  发布时间:2017/6/3 21:47:00
--  
LINK


--  作者:有点色
--  发布时间:2017/6/4 11:37:00
--  

 参考

 

http://www.foxtable.com/webhelp/scr/0102.htm

 


--  作者:benwong2013
--  发布时间:2017/6/4 16:59:00
--  
Dim Filter As String
With e.Form.Controls("Textdengji")
    If .Value IsNot Nothing Then
        Dim txt As String = "\'%" & .Value & "%\'"
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & ("食品大类一级 Like " & txt & " Or 食品亚类二级 Like " & txt  & " Or 食品品种三级 Like " & txt  & " Or 食品细类四级 Like " & txt)
    End If
End With
With e.Form.Controls("Textteam")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(varchar,报价分组) like \'%" & .Value & "%\'"
    End If
End With
With e.Form.Controls("TextSTD")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(varchar,标准) like \'%" & .Value & "%\'"
    End If
End With
With e.Form.Controls("TextItem")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(varchar,检测项目) like \'%" & .Value & "%\'"
    End If
End With
If Filter > "" Then
    DataTables("B_TtemNo").LoadFilter = Filter
    DataTables("B_TtemNo").Load
End If

请问这个代码应该如何改?

--  作者:有点色
--  发布时间:2017/6/4 17:12:00
--  

 

Filter = Filter & "(食品大类一级 Like " & txt & " Or 食品亚类二级 Like " & txt  & " Or 食品品种三级 Like " & txt  & " Or 食品细类四级 Like " & txt & ")"