以文本方式查看主题

-  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=6810)

--  作者:ddlzq
--  发布时间:2010/4/27 21:13:00
--  [求助]再问窗口筛选_可否实现输入的多条件都实现模糊筛选?
Dim Filter As String
With e.Form.Controls("cmbProduct")
    If .Value IsNot Nothing Then
        Filter = "产品 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("cmbCustomer")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "客户 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("cmbEmployee")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "雇员 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("StartDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "日期 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("EndDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "日期 <= #" & .Value & "#"
    End If
End With
If Filter > "" Then
    Tables("订单").Filter = Filter
End If
---------------
以上代码是帮助中的‘窗口筛选’例表中的代码,但这个是完全条件的筛选,可否改成组合框输入条件后,自动变成“包含”式筛选呢?搜了一下咱们论坛的“模糊筛选”没太懂,能不能哪位老师教一下?谢谢了。

--  作者:czy
--  发布时间:2010/4/27 22:16:00
--  

这样?

Dim Filter As String
With e.Form.Controls("cmbProduct")
    If .Value IsNot Nothing Then
        Filter = "产品 Like \'*" & .Value & "*\'"
    End If
End With
With e.Form.Controls("cmbCustomer")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "客户 Like \'*" & .Value & "*\'"
    End If
End With
With e.Form.Controls("cmbEmployee")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "雇员 Like \'*" & .Value & "*\'"
    End If
End With
With e.Form.Controls("StartDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "日期 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("EndDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "日期 <= #" & .Value & "#"
    End If
End With
If Filter > "" Then
    Tables("订单").Filter = Filter
End If


--  作者:ddlzq
--  发布时间:2010/4/28 7:59:00
--  
太感谢CZY老师了!这么晚还在论坛上,我都研究的睡过去了,呵呵。一早就像中彩票一样就收到了满意 的回复。
[此贴子已经被作者于2010-4-28 7:59:48编辑过]

--  作者:blackzhu
--  发布时间:2010/4/28 17:04:00
--  
以下是引用ddlzq在2010-4-28 7:59:00的发言:
太感谢CZY老师了!这么晚还在论坛上,我都研究的睡过去了,呵呵。一早就像中彩票一样就收到了满意 的回复。
[此贴子已经被作者于2010-4-28 7:59:48编辑过]

在版中查yang版以前做的例子可以模糊筛选的.