以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  条件查询窗口的疑惑  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=135726)

--  作者:game178
--  发布时间:2019/6/2 8:14:00
--  条件查询窗口的疑惑
为什么查询的时候只取最后一个查询条件,不能联合查询呢?高手帮忙看看问题在什么地方,谢谢

图片点击可在新窗口打开查看此主题相关图片如下:qq图片20190602081104.png
图片点击可在新窗口打开查看


Dim Filter As String
With e.Form.Controls("combobox1")
    If .Value IsNot Nothing Then
             Filter = "考试性质= \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("combobox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If 
        Filter = "考试年月= \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("combobox3")
    If .Value IsNot Nothing Then
       If Filter > "" Then
            Filter = Filter & " And "
        End If 
          Filter = "班级= \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("combobox4")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If 
        Filter = "科类= \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("combobox5")
    If .Value IsNot Nothing Then
       If Filter > "" Then
            Filter = Filter & " And "
        End If 
        Filter = "姓名= \'" & .Value & "\'"
    End If
End With

If Filter > "" Then
    Tables("成绩表").Filter = Filter
End If

--  作者:2900819580
--  发布时间:2019/6/2 11:01:00
--  

Dim Filter As String
With e.Form.Controls("combobox1")
    If .Value IsNot Nothing Then
             Filter = "考试性质= \'" & .Value & "\'"
    End If
End With


With e.Form.Controls("combobox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter &= "考试年月= \'" & .Value & "\'"
    End If
End With


With e.Form.Controls("combobox3")
    If .Value IsNot Nothing Then
       If Filter > "" Then
            Filter = Filter & " And "
        End If
          Filter &= "班级= \'" & .Value & "\'"
    End If
End With


With e.Form.Controls("combobox4")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter &= "科类= \'" & .Value & "\'"
    End If
End With


With e.Form.Controls("combobox5")
    If .Value IsNot Nothing Then
       If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter &= "姓名= \'" & .Value & "\'"
    End If
End With


If Filter > "" Then
    Tables("成绩表").Filter = Filter
End If

[此贴子已经被作者于2019/6/2 11:01:21编辑过]

--  作者:game178
--  发布时间:2019/6/6 14:49:00
--  
非常感谢,原来是这里差了点东西。受教了