以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]复合筛选的代码,请指教  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=25568)

--  作者:boooxu
--  发布时间:2012/11/12 11:56:00
--  [求助]复合筛选的代码,请指教

图片点击可在新窗口打开查看

如图,筛选有二类条件,状态和分类

要示:

状态或者分类里面是复选是和的关系,

状态与分类之间是交叉的关系。

要求状态或者分类任何一类中,全选或全不选均是全选中的含义

 

请高手帮我检查下代码

-------------------------------------------

Tables("信息表").filter = ""
Dim hg As WinForm.CheckBox = e.Form.Controls("CheckBox1")
Dim ds As WinForm.CheckBox = e.Form.Controls("CheckBox2")
Dim yqx As WinForm.CheckBox = e.Form.Controls("CheckBox3")
Dim filter1 As String

If hg.Checked Then
    If filter1 > "" Then
        filter1 = filter1 & " Or "
    End If
    filter1 = filter1 & " 状态 = \'合格\' "
End If

If ds.Checked Then
    If filter1 > "" Then
        filter1 = filter1 & " Or "
    End If
    filter1 = filter1 & " 状态 = \'待审\' "
End If

If yqx.Checked Then
    If filter1 > "" Then
        filter1 = filter1 & " Or "
    End If
    filter1 = filter1 & " 状态 = \'己取消\'"
End If

If hg.Checked = False AndAlso ds.Checked = False AndAlso  yqx.Checked = False Then
    filter1 = filter1 & " 状态 = \'合格\' or 状态 = \'待审\'  or 状态 = \'己取消\'"
End If

Dim gj As WinForm.CheckBox = e.Form.Controls("CheckBox4")
Dim yb As WinForm.CheckBox = e.Form.Controls("CheckBox5")
Dim filter2 As String

If ds.Checked Then
    If filter2 > "" Then
        filter2 = filter2 & " Or "
    End If
    filter2 = filter2 & " 分类 = \'关键\' "
End If

If yqx.Checked Then
    If filter2 > "" Then
        filter2 = filter2 & " Or "
    End If
    filter2 = filter2 & " 分类 = \'一般\'"
End If

If gj.Checked = False AndAlso yb.Checked = False Then
    filter2 = filter2 & " 分类 = \'关键\' or 分类 = \'一般\' "
End If

If filter1 > "" Then
    If filter2 > "" Then
        filter1 = "(" & filter1 & ")" & " And "  & "(" & filter2 & ")"
    End If
Else
    filter1 = filter2
End If

Tables("信息表").Filter =filter1 & " And " & filter2


--  作者:boooxu
--  发布时间:2012/11/12 12:07:00
--  
调试过,还是走不通呀
--  作者:boooxu
--  发布时间:2012/11/12 12:12:00
--  

谢谢楼上的兄弟,辛苦了,

脚本调试成功