以文本方式查看主题

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

--  作者:zhangxl1964
--  发布时间:2015/11/21 14:43:00
--  筛选求助
老师:你好!

      我需要对人员名册进行筛选统计。
      1、登记日期  小于某个登记日期
      2、离职日期  大于某个离职日期
      3、离职日期  或者离职日期为空
     下面代码中的离职日期为空如何修改?请帮助。
     Dim Filter As String

With e.Form.Controls("登记日期")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "登记日期 <= \'" & .Value & "\'"
    End If
End With


With e.Form.Controls("离职日期")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "离职日期 = \' Is null \'"  \'离职日期为空
    End If
End With
With e.Form.Controls("离职日期")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "离职日期 >= \'" & .Value & "\'"
    End If
End With

If Filter > "" Then
    Tables("在职查询_Table1").Filter = Filter
End If

--  作者:Hyphen
--  发布时间:2015/11/21 14:52:00
--  
 Filter = Filter & "离职日期 Is null " \'离职日期为空
--  作者:Hyphen
--  发布时间:2015/11/21 14:56:00
--  

Dim Filter As String

With e.Form.Controls("登记日期")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "登记日期 <= \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("离职日期")
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    If .Value Is Nothing Then
        Filter = Filter & "离职日期 Is null "  \'离职日期为空
    Else
        Filter = Filter & "离职日期 >= \'" & .Value & "\'"
    End If
End With

If Filter > "" Then
    Tables("在职查询_Table1").Filter = Filter
End If