Allen Browne Client Search Multiple Like Statements

G

Guest

Hi all,
I need to have this code search multiple fields, but I keep getting
"Expected end of statement" on the Me in the second to last line:

If Not IsNull(Me.txtFilterMainName) Then
'strWhere = strWhere & "([MainName] Like ""*" & Me.txtFilterMainName
& "*"") AND "
strWhere = strWhere & "([Address1] Like ""*" & Me.txtFilterMainName
& "*"") OR " & _
strWhere = strWhere & " ([StreetName] Like "" * " &
Me.txtFilterMainName & " * "") Or "
strWhere = strWhere & "([From] Like "" * " Me.txtFilterMainName
& " * "") Or "
strWhere = strWhere & "([To] Like "" * " & Me.txtFilterMainName
& " * "") And "
End If

Thanks,
NickX
 
D

Douglas J. Steele

You're missing an ampersand between "" * " and Me.txtFilterMainName

BTW, are those spaces actually in your code? If so, you won't find anything
unless the value in the From field starts and ends with a space.
 
G

Guest

It is usually the obvious ones that give you the isn't it?!?
Thank you very much, Douglas, I would have stared at that for hours and
still probably not seen it.
Agian, Thanks;
NickX

Douglas J. Steele said:
You're missing an ampersand between "" * " and Me.txtFilterMainName

BTW, are those spaces actually in your code? If so, you won't find anything
unless the value in the From field starts and ends with a space.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Nick X said:
Hi all,
I need to have this code search multiple fields, but I keep getting
"Expected end of statement" on the Me in the second to last line:

If Not IsNull(Me.txtFilterMainName) Then
'strWhere = strWhere & "([MainName] Like ""*" &
Me.txtFilterMainName
& "*"") AND "
strWhere = strWhere & "([Address1] Like ""*" &
Me.txtFilterMainName
& "*"") OR " & _
strWhere = strWhere & " ([StreetName] Like "" * " &
Me.txtFilterMainName & " * "") Or "
strWhere = strWhere & "([From] Like "" * " Me.txtFilterMainName
& " * "") Or "
strWhere = strWhere & "([To] Like "" * " & Me.txtFilterMainName
& " * "") And "
End If

Thanks,
NickX
 
G

Guest

....that give you (the most trouble)...

Douglas J. Steele said:
You're missing an ampersand between "" * " and Me.txtFilterMainName

BTW, are those spaces actually in your code? If so, you won't find anything
unless the value in the From field starts and ends with a space.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Nick X said:
Hi all,
I need to have this code search multiple fields, but I keep getting
"Expected end of statement" on the Me in the second to last line:

If Not IsNull(Me.txtFilterMainName) Then
'strWhere = strWhere & "([MainName] Like ""*" &
Me.txtFilterMainName
& "*"") AND "
strWhere = strWhere & "([Address1] Like ""*" &
Me.txtFilterMainName
& "*"") OR " & _
strWhere = strWhere & " ([StreetName] Like "" * " &
Me.txtFilterMainName & " * "") Or "
strWhere = strWhere & "([From] Like "" * " Me.txtFilterMainName
& " * "") Or "
strWhere = strWhere & "([To] Like "" * " & Me.txtFilterMainName
& " * "") And "
End If

Thanks,
NickX
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top