Dim aa As WinForm.TextBox = e.Form.Controls("TextBox3")
Dim Filter As String
Dim str As String
Dim Ast() As String = {"订车单位","派车单位"}
For Each a As String In Ast
If str > "" Then
str = str & " Or "
End If
str = str & "[" & a & "] Like '%" & aa.value & "%'"
Next
If str > "" Then
filter = "(" & str & ")"
End If
With e.Form.Controls("TextBox3")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "[订车单位] Like '%" & .Value & "%'" And "[派车单位] Like '%" & .Value & "%'"
End If
End With
With e.Form.Controls("DateTimePicker1")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "实际用车日期_起 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("DateTimePicker2")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "实际用车日期_起 <= #" & .Value & "#"
End If
End With
If e.Form.Controls("已付款").Checked = True ' 如果付款状态选择了"已付"
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "派车单位结算_租金结算 = True"
End If
If e.Form.Controls("未付款").Checked = True ' 如果付款状态选择了"未付"
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "(派车单位结算_租金结算 = False Or 派车单位结算_租金结算 Is Null)"
End If
If Filter > "" Then
Tables("用车明细表").Filter = Filter
End If