J
JB
I have a form that I want to enable users to filter by entering a search
criteria and then display only records that display that criteria in any of 3
columns.
example.
If user enters Pat in the txtSearch field, records that contain patricia
smith, john patterson, Spatterri & Co in the ContactName, Company_Name or
Name fields.
Here is the code I have used without success.
If somebody could tell me what I'm doing wrong it would be appreciated.
Private Sub btn_search_Click()
If Not IsNull(TxtSearch) Then
Dim stSearchCriteria As String
stSearchCriteria = "[ContactName]=" & "'*" & Me![TxtSearch] & "*'" Or
"[Company_Name]=" & "'*" & Me![TxtSearch] & "*'" Or "[Name]=" & "'*" &
Me![TxtSearch] & "*'"
DoCmd.ApplyFilter , stSearchCriteria
Else
MsgBox "Enter the text to search for", vbOKOnly, "Search Text"
End If
End Sub
criteria and then display only records that display that criteria in any of 3
columns.
example.
If user enters Pat in the txtSearch field, records that contain patricia
smith, john patterson, Spatterri & Co in the ContactName, Company_Name or
Name fields.
Here is the code I have used without success.
If somebody could tell me what I'm doing wrong it would be appreciated.
Private Sub btn_search_Click()
If Not IsNull(TxtSearch) Then
Dim stSearchCriteria As String
stSearchCriteria = "[ContactName]=" & "'*" & Me![TxtSearch] & "*'" Or
"[Company_Name]=" & "'*" & Me![TxtSearch] & "*'" Or "[Name]=" & "'*" &
Me![TxtSearch] & "*'"
DoCmd.ApplyFilter , stSearchCriteria
Else
MsgBox "Enter the text to search for", vbOKOnly, "Search Text"
End If
End Sub