以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]按时段筛选问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=91426)

--  作者:736642114
--  发布时间:2016/10/10 16:09:00
--  [求助]按时段筛选问题
狐表小白一个,第一次使用,很多都不会,请教一下大神,根据时间范围的 今天、本月、今年等,筛选出对应日期!
图片点击可在新窗口打开查看此主题相关图片如下:123.png
图片点击可在新窗口打开查看

--  作者:kjkui
--  发布时间:2016/10/10 16:47:00
--  
在“时间范围”下拉框的ValueChanged事件中写
Dim xz As WinForm.ComboBox = e.Form.Controls("时间范围")
Dim btn1 As WinForm.DateTimePicker = Forms("窗口1").Controls("StartDate")
Dim btn2 As WinForm.DateTimePicker = Forms("窗口1").Controls("EndDate")
If xz.value = "今天"
    Dim y As Integer = Date.Today.Year
    Dim d As Date = Date.Today
    btn1.value = d
    btn2.value = d
    btn1.Enabled = False
    btn2.Enabled = False
End If
在“时间范围”下拉框的TextChanged事件中写
Dim Filter As String

With e.Form.Controls("时间范围")
    Dim xz As WinForm.ComboBox = e.Form.Controls("时间范围")
    If xz.value = "今天"
        Dim y As Integer = Date.Today.Year
        Dim d As Date = Date.Today \'当前时间
        Filter = "创建时间 = \'" & d & "\' And 创建时间 = \'" & d & "\'"
        Tables("订单管理").Filter = Filter
  End If
End With
With e.Form.Controls("StartDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "创建时间 >= \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("EndDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "创建时间 <= \'" & .Value & "\'"
    End If
End With
If Filter > "" Then
    Tables("订单管理").Filter = Filter
End If


--  作者:有点蓝
--  发布时间:2016/10/10 16:48:00
--  
比如今天
Tables("表A").Filter = "日期=\'" & Date.Today & "\'"
本月
Dim d1 As Date = new Date(Date.Today.Year,Date.Today.Month,1)
Dim d2 As Date = d1.AddMonths(1)
Tables("表A").Filter = "日期>=\'" & d1 & "\' and 日期 < \'" & d2 & "\'"



--  作者:kjkui
--  发布时间:2016/10/10 16:52:00
--  
http://www.foxtable.com/webhelp/scr/2720.htm