Error using Like* operator

  • Thread starter Thread starter Pamela
  • Start date Start date
P

Pamela

I have a pop-up from that launches from my switchboard to allow users to type
text that filters the records in my form upon opening it. I'm not being able
to get the Like* operator to work though. I want users to be able to search
the records without having the exact name. (Yes, everyone says to do it w/ a
cbo on the ID of the form,l but can't get that to work either - would really
prefer this way) I am starting from the cmd button wizard and trying to
change the code. Here's the error I'm getting:

Syntax error (missing operator) in query expression '[Owners name]= .Like *
&[Text1]& *'.

Here's my code:

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_Assn"

stLinkCriteria = "[Owners Name]= .Like * & [Text1] & *"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

Thanks so much!
Pamela
 
It should be;

stLinkCriteria = "[Owners Name] Like ""*" & [Text1] & "*"""

For clarifification, after the word Like that's two double quotes,
an asterisk and another double quote, followed by & [Text1] & then
a double quote, an aterisk, and three double quotes.
 
Back
Top