刚刚的代码在ValueChanged事件中
其中在TextChanged事件中写的是
Dim Filter As String
With e.Form.Controls("选择")
Dim xz As WinForm.ComboBox = e.Form.Controls("选择")
If xz.value = "全部"
Tables("订单管理").ApplyFilter = False
Dim btn3 As WinForm.DateTimePicker = Forms("窗口1").Controls("StartDate")
Dim btn4 As WinForm.DateTimePicker = Forms("窗口1").Controls("EndDate")
btn3.Enabled = True
btn4.Enabled = True
e.Form.Controls("EndDate").Value = Nothing
e.Form.Controls("StartDate").Value = Nothing
Tables("订单管理").Filter = Filter
End If
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
If xz.value = "本周"
Dim y As Integer = Date.Today.Year
Dim w As Integer = Date.Today.DayOfWeek '算出今天是星期几
Dim dt1 As Date = Date.Today.AddDays(-w) '获取本周的第一天
Dim dt2 As Date = Date.Today.AddDays(6 - w) '获取本周的最后一天
'Dim Filter As String
Filter = "时间 >= '" & dt1 & "' And 时间 <= '" & dt2 & "'"
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