I have a command button to perform record filter attached to the following code
Now, I just want to have only one text box to search in [SongNumber], [Title], [Author] and [Keywords]. How can I combine them into one statement.
I tried:
It never works as I expected but gives me all records I have in my database.
Thanks for any help!
Gelsea
Code:
Private Sub cmdSearch_Click()
Dim strWhere As String
Dim lngLen As Long
If Not IsNull(Me.txtSongNumber) Then
strWhere = strWhere & "([SongNumber] = Like ""*" & Me.txtSongNumber & "*"") AND "
End If
If Not IsNull(Me.txtTitle) Then
strWhere = strWhere & "([Title] = Like ""*" & Me.txtTitle & "*"") AND "
End If
If Not IsNull(Me.txtAuthor) Then
strWhere = strWhere & "([Author] = Like ""*" & Me.txtAuthor & "*"") AND "
End If
If Not IsNull(Me.txtKeywords) Then
strWhere = strWhere & "([Keywords] = Like ""*" & Me.txtAuthor & "*"") AND "
End If
I tried:
Code:
If Not IsNull(Me.txtKeywords) Then
strWhere = strWhere & "([SongNumber] OR [Title] OR [Author] OR [Keywords] = Like ""*" & Me.txtAuthor & "*"") AND "
End If
Thanks for any help!
Gelsea