请教蓝老师,一段用于筛选的代码如下:
With e.Form.Controls("xingming")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Dim txt As String = "'%" & .Value & "%'"
Filter = Filter & "(姓名 Like " & txt & " )"
End If
End With
With e.Form.Controls("xingbie")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Dim txt As String = "'%" & .Value & "%'"
Filter = Filter & "(性别 Like " & txt & " )"
End If
End With
With e.Form.Controls("danwei")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Dim txt As String = "'%" & .Value & "%'"
Filter = Filter & "(工作单位 Like " & txt & " )"
End If
End With
这段代码可对“姓名”、“性别”、“工作单位”三个条件进行组合筛选,但是组合筛选只能是“And”。我的问题是,如果添加一个组合框,含有“And”和“Or”两个组合设置,使代码在“And” 或 “Or” 之间任意改变设置。该如何写代码?谢谢