以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  按时间筛选问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=123231)

--  作者:weipeng6999
--  发布时间:2018/8/10 11:57:00
--  按时间筛选问题
老师,我有两个textbox框,两个datetimepicker框,进行筛选。

Dim sf As WinForm.TextBox = e.Form.Controls("按地区查询")
Dim dwmc As WinForm.TextBox = e.Form.Controls("按单位查询")
Dim ksrq As WinForm.DateTimePicker = e.Form.Controls("起始日期")
Dim jsrq As WinForm.DateTimePicker = e.Form.Controls("结束日期")
If sf.Value IsNot Nothing Then
    Tables("查询窗口_查询").Filter = "省份 Like \'*" & sf.text & "*\'"
End If
If dwmc.Value IsNot Nothing Then
    Tables("查询窗口_查询").Filter = "单位名称 Like \'*" & dwmc.text & "*\'"
End If
Dim Filter As String
If ksrq.Value IsNot Nothing Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "日期 >= \'" & ksrq.Value.Date & "\'"
End If

If jsrq.Value IsNot Nothing Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "日期 < \'" & jsrq.Value.Date.adddays(1) & "\'"
End If

按开始和结束时间查询无动作,请问是代码哪里的问题。textbox的查询正常
[此贴子已经被作者于2018/8/10 12:02:44编辑过]

--  作者:有点甜
--  发布时间:2018/8/10 12:04:00
--  


Dim sf As WinForm.TextBox = e.Form.Controls("按地区查询")
Dim dwmc As WinForm.TextBox = e.Form.Controls("按单位查询")
Dim ksrq As WinForm.DateTimePicker = e.Form.Controls("起始日期")
Dim jsrq As WinForm.DateTimePicker = e.Form.Controls("结束日期")
Dim Filter As String = "1=1"
If sf.Value IsNot Nothing Then
    Filter &= " and 省份 Like \'%" & sf.text & "%\'"
End If
If dwmc.Value IsNot Nothing Then
    Filter &= " and 单位名称 Like \'%" & dwmc.text & "%\'"
End If

If ksrq.Value IsNot Nothing Then
    Filter = Filter & " and 日期 >= #" & ksrq.Value.Date & "#"
End If

If jsrq.Value IsNot Nothing Then
    Filter = Filter & " and 日期 < #" & jsrq.Value.Date.adddays(1) & "#"
End If

Tables("查询窗口_查询").Filter = filter