老师,在学习窗口筛选时,发现只能筛选出于条件一样的结果,我要模糊查询这个代码怎么写啊?比如查询条件输入123,把有关123的客户全部筛选出来。
Dim Filter As String
With e.Form.Controls("cmbCustomer")
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
我这样做能实现,但是只能按照先后顺序,逐个输入条件才能查询
Dim sbxh As WinForm.ComboBox = e.Form.Controls("机构")
Dim sbxlh As WinForm.TextBox = e.Form.Controls("名称")
Dim StartDate As Date = #1/1/1900#
If e.Form.Controls("起始日期").Value <> Nothing
StartDate = e.Form.Controls("起始日期").Value
End If
Dim EndDate As Date = #12/30/2099#
If e.Form.Controls("截止日期").Value <> Nothing
EndDate = e.Form.Controls("截止日期").Value
End If
Tables("表A").Filter = "机构 Like '" & sbxh.Text & "' AND 名称 Like '*" & sbxlh.Text & "*' and 登记时间 >= #" & StartDate & "# And 登记时间 <= #" & EndDate & "# "
[此贴子已经被作者于2016/7/29 11:04:17编辑过]