Foxtable(狐表)用户栏目专家坐堂 → 条件筛选问题


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

主题:条件筛选问题

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


加好友 发短信
等级:婴狐 帖子:34 积分:303 威望:0 精华:0 注册:2015/3/24 9:31:00
条件筛选问题  发帖心情 Post By:2015/5/26 16:52:00 [只看该作者]

如上图,怎么实现选择了民族为汉族之后直接点查询就能出来所有汉族学生的信息,不用四项都选择才能点击查询?

Dim mz As WinForm.ComboBox = e.Form.Controls("民族")
Dim xb As WinForm.ComboBox = e.Form.Controls("性别")
Dim zzmm As WinForm.ComboBox = e.Form.Controls("政治面貌")
Dim hklx As WinForm.ComboBox = e.Form.Controls("户口类型")

Tables("学生基本信息表").filter="民族 ='" & mz.Text & "' and 性别 ='" & xb.Text & "' and 政治面貌 = '" & zzmm.Text & "' and 户口类型= '" & hklx.Text & "'"
图片点击可在新窗口打开查看此主题相关图片如下:条件筛选.jpg
图片点击可在新窗口打开查看

 回到顶部
帅哥哟,离线,有人找我吗?
Bin
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2015/5/26 16:55:00 [只看该作者]


 回到顶部
帅哥哟,离线,有人找我吗?
sloyy
  3楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2180 积分:13816 威望:0 精华:2 注册:2012/2/25 10:59:00
  发帖心情 Post By:2015/5/26 17:04:00 [只看该作者]

先判断查询条件是否为空,不为空则加条件
Dim mz As WinForm.ComboBox = e.Form.Controls("民族")
Dim xb As WinForm.ComboBox = e.Form.Controls("性别")
Dim zzmm As WinForm.ComboBox = e.Form.Controls("政治面貌")
Dim hklx As WinForm.ComboBox = e.Form.Controls("户口类型")
dim filter as string

            filter=""
       
        If mz <>"" Then
            If Filter > "" Then
                Filter = Filter & " And "
            End If
            Filter = Filter & "[民族]  ='" & mz & "'"
        End If

If xb <>"" Then
            If Filter > "" Then
                Filter = Filter & " And "
            End If
            Filter = Filter & "[性别]  ='" & xb & "'"
        End If
If zzmm<>"" Then
            If Filter > "" Then
                Filter = Filter & " And "
            End If
            Filter = Filter & "[政治面貌]  ='" & zzmm & "'"
        End If
If hklx <>"" Then
            If Filter > "" Then
                Filter = Filter & " And "
            End If
            Filter = Filter & "[户口类型]  ='" & hklx & "'"
        End If
Tables("学生基本信息表").filter=filter
[此贴子已经被作者于2015/5/26 17:04:28编辑过]

 回到顶部