在“时间范围”下拉框的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