以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  筛选问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=75084)

--  作者:cwm591825
--  发布时间:2015/9/26 10:29:00
--  筛选问题

老师,请帮忙看看下面代码:

 

Dim Filter As String

With e.Form.Controls("ComboBox2")
    If .Value IsNot Nothing Then
              Filter = Filter & "类别 = \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("ComboBox3")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If

        If .Value = "计件工价" Then
        Filter = Filter & "注释 <> \'全套\' Or 注释 Is Null"
        End If
      
         If .Value = "多套模具组合工价" Then
         Filter = Filter & "注释 = \'全套\'"
         End If
    End If
End With

If Filter > "" Then
    Tables("机房计件工价").Filter = Filter
End If

 

由于注释含有全套、其他字符和空值,

筛选注释不是全套+不同类别时,筛选结果并不是我想要的同时满足:注释不是全套和不同类别。


--  作者:狐狸爸爸
--  发布时间:2015/9/28 8:31:00
--  
抱歉, 没有看懂你的问题,能否做个例子说话。
--  作者:大红袍
--  发布时间:2015/9/28 10:44:00
--  

Dim Filter As String = "1=1"

With e.Form.Controls("ComboBox2")
    If .Value IsNot Nothing Then
        Filter = Filter & " and 类别 = \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("ComboBox3")
    If .Value IsNot Nothing Then
       
        If .Value = "计件工价" Then
            Filter = Filter & " and (注释 <> \'全套\' Or 注释 Is Null)"
        End If
       
        If .Value = "多套模具组合工价" Then
            Filter = Filter & " and 注释 = \'全套\'"
        End If
    End If
End With

If Filter > "" Then
    Tables("机房计件工价").Filter = Filter
End If


 


--  作者:cwm591825
--  发布时间:2015/9/28 18:12:00
--  

谢谢老师!!