Syntax Error

  • Thread starter Thread starter Merwin12
  • Start date Start date
M

Merwin12

Hi,
Having a problem with this code:

If (IsNull(Me.txtFName) Or Me.txtFName = "") And (IsNull
(Me.txtclientid) Or Me.txtclientid = "") Then

DoCmd.OpenForm "frmclientsearch", , , "LAST_NAME LIKE " &
Me.txtLName & "*"

End If

Error I got:
Syntax error (missing operator)in query expression
'LAST_NAME LIKE ACC*'

please help...thanks.
 
"LAST NAME LIKE '" & Me.txtName & " *' "

That would readas: LIKE
<space>SingleQuote-DoubleQuote<variable>DoubleQuote-Asterik-SingleQuote-Doub
leQuote

Note also that sometimes you must use the percent sign instead of the
asterik as the wildcard characters. I've noticed this when opening an ADODB
recordset using LIKE ...
 
DoCmd.OpenForm "frmclientsearch", , , "LAST_NAME LIKE """ &
Me.txtLName & "*"""

That's 3 double-quotes after LIKE and *
 
Thank you for the help.
-----Original Message-----
DoCmd.OpenForm "frmclientsearch", , , "LAST_NAME LIKE """ &
Me.txtLName & "*"""

That's 3 double-quotes after LIKE and *

--
HTH
Van T. Dinh
MVP (Access)






.
 
Sorry I need help again to do this search and I'm getting
a syntax error.
Thanks.

DoCmd.OpenForm "frmclientsearch", , , "FIRST_NAME LIKE """
& Me.txtFName & "*""" & "and """ & "LAST_NAME LIKE """ &
Me.txtLName & "*"""
 
Try:

DoCmd.OpenForm "frmclientsearch", , , "FIRST_NAME LIKE """
& Me.txtFName & "*"" AND LAST_NAME LIKE """ &
Me.txtLName & "*"""
 
Thank you so much! It worked!!!!
-----Original Message-----
Try:

DoCmd.OpenForm "frmclientsearch", , , "FIRST_NAME LIKE """
& Me.txtFName & "*"" AND LAST_NAME LIKE """ &
Me.txtLName & "*"""


--
HTH
Van T. Dinh
MVP (Access)







.
 
Back
Top