谢谢各位,我的方法如下,已试成功。敬请各位老师评点:
Dim Str0 As String = "000"
Dim Str1,Str2,Str3 As String
If Forms("窗口1").Controls("TextBox1").Value IsNot Nothing
Str1 = Forms("窗口1").Controls("TextBox1").Value.Trim()
Str0 = "1" & str0.SubString(1,2)
End If
If Forms("窗口1").Controls("TextBox2").Value IsNot Nothing
Str2 = Forms("窗口1").Controls("TextBox2").Value.Trim()
Str0 = str0.SubString(0,1) & "1" & str0.SubString(2,1)
End If
If Forms("窗口1").Controls("TextBox3").Value IsNot Nothing
Str3 = Forms("窗口1").Controls("TextBox3").Value.Trim()
Str0 = str0.SubString(0,2) & "1"
End If
Select Case Str0
Case "000"
Tables("表1").Filter = ""
Case "100"
Tables("表1").Filter = "[名称] like '*" & Str1 & "*'"
Case "010"
Tables("表1").Filter = "[名称] like '*" & Str2 & "*'"
Case "001"
Tables("表1").Filter = "[名称] like '*" & Str3 & "*'"
Case "110"
Tables("表1").Filter = "[名称] like '*" & Str1 & "*' And [名称] Like '*" & Str2 & "*'"
Case "011"
Tables("表1").Filter = "[名称] like '*" & Str2 & "*' And [名称] Like '*" & Str3 & "*'"
Case "101"
Tables("表1").Filter = "[名称] like '*" & Str3 & "*' And [名称] Like '*" & Str1 & "*'"
Case "111"
Tables("表1").Filter = "[名称] like '*" & Str1 & "*' And [名称] Like '*" & Str2 & "*' And [名称] Like '*" & Str3 & "*'"
End Select