Foxtable(狐表)用户栏目专家坐堂 → 条件查询窗口的疑惑


  共有2877人关注过本帖树形打印复制链接

主题:条件查询窗口的疑惑

帅哥哟,离线,有人找我吗?
game178
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:13 积分:176 威望:0 精华:0 注册:2019/2/26 17:34:00
条件查询窗口的疑惑  发帖心情 Post By: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
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1353 积分:9868 威望:0 精华:0 注册:2015/6/30 8:46:00
  发帖心情 Post By: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
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:13 积分:176 威望:0 精华:0 注册:2019/2/26 17:34:00
  发帖心情 Post By:2019/6/6 14:49:00 [只看该作者]

非常感谢,原来是这里差了点东西。受教了

 回到顶部