Dim Filter As String
With e.Form.Controls("ComboBox8")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
If .Value.Contains("-") Then
Dim srr() As String = .Value.split("-")
Filter = Filter & "色号='" & srr(0) & "' And 颜色='" & srr(1) & "'"
Else
Dim txt As String = "'%" & .Value & "%'"
Filter = Filter & "(色号 Like " & txt & " Or 颜色 Like " & txt & " )"
End If
End If
End With
With e.Form.Controls("ComboBox7")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
If .Value.Contains("-") Then
Dim srr1() As String = .Value.split("-")
Filter = Filter & "客户编号='" & srr1(0) & "' And 面料名称='" & srr1(1) & "'"
Else
Dim txt1 As String = "'%" & .Value & "%'"
Filter = Filter & "(客户编号 Like " & txt1 & " Or 面料名称 Like " & txt1 & " )"
End If
End If
End With
With e.Form.Controls("ComboBox9")
If .Text IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Dim txt2 As String = "'%" & .Text & "%'"
Filter = Filter & "品牌 Like " & txt2
' Filter = Filter & "品牌 = '" & .Value & "'"
End If
End With
With e.Form.Controls("ComboBox10")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Dim txt3 As String = "'%" & .Value & "%'"
Filter = Filter & "款号 Like " & txt3
End If
End With
With e.Form.Controls("ComboBox11")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Dim txt4 As String = "'%" & .Value & "%'"
Filter = Filter & "交货单位 Like " & txt4
End If
End With
With e.Form.Controls("DateTimePicker4")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "交货日期 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("DateTimePicker5")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "交货日期 <= #" & .Value & "#"
End If
End With
'MsgBox(Filter)
Tables("窗口3_Table1").Filter = Filter
如何让代码知道ComboBox9是输入的数据还是下拉列表选择的数据呢?
我的想法是如果输入的数据模糊查找,但是下拉列表则是按照下拉列表的数据查找
比如当我ComboBox9输入1,则在表中相关列查找并筛选包含1的数据,如果ComboBox9下拉列表选择1,则是在表中相关列筛选1的数据