Dim Filter As String
Dim txt As String = e.Form.Controls("ComboBox1").Text
With e.Form.Controls("ComboBox1")
If .Value IsNot Nothing Then
txt = "'%" & txt & "%'"
filter = "姓名 Like " & txt & " Or 客户信息 Like " & txt (‘ 问题是出现在紫色代码这一段,如果去掉就正常了。但我也想查询姓名字段和客户信息字段这二栏)
vars("姓名") = txt
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 & "#"
vars("起始日期") = .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 & "#"
vars("终止日期") = .Value
End If
End With
If Filter > "" Then
DataTables("表A").loadfilter = filter
DataTables("表A").load()
Tables("表A").Filter = Filter
end If
筛选出来日期段不是 datatimepicker1和datatimepicker2控件选出来的日期段。