以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]动态表达式合成  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=81110)

--  作者:dixiaxiaodan
--  发布时间:2016/2/18 17:40:00
--  [求助]动态表达式合成
 Dim Filter As String
With e.Form.Controls("DateTimePicker1")
    If .Value IsNot Nothing Then
        Filter = "日期 >= \'" & .Value & "\' "
    End If
End With

With e.Form.Controls("DateTimePicker2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "   \'相\\在原条件基础上添加 and
        End If
        Filter = Filter & "日期 <= \'" & .Value & "\' "   \'添加下一个条件
    End If
End With


Dim drs1 As List(Of DataRow)
Dim drs2 As List(Of DataRow)
Dim day_delay As Integer = e.Form.Controls("NumericComboBox1").Value

Dim number_delay As Integer = e.Form.Controls("NumericComboBox2").Value

drs1 = DataTables("故障报告").Select("" & Filter & "")

请大神们帮忙看下,上面标红的代码是不是有问题,不会报错,但筛选出来的不大对,谢谢!

--  作者:大红袍
--  发布时间:2016/2/18 17:42:00
--  

Dim Filter As String
With e.Form.Controls("DateTimePicker1")
    If .Value IsNot Nothing Then
        Filter = "日期 >= #" & .Value & "# "
    End If
End With

With e.Form.Controls("DateTimePicker2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "   \'相\\在原条件基础上添加 and
        End If
        Filter = Filter & "日期 <= #" & .Value & "# "   \'添加下一个条件
    End If
End With


Dim drs1 As List(Of DataRow)
Dim drs2 As List(Of DataRow)
Dim day_delay As Integer = e.Form.Controls("NumericComboBox1").Value
Dim number_delay As Integer = e.Form.Controls("NumericComboBox2").Value

drs1 = DataTables("故障报告").Select(Filter)