Syntax Error

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.
 
S

Scott McDaniel

"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 ...
 
V

Van T. Dinh

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

That's 3 double-quotes after LIKE and *
 
M

Merwin12

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)






.
 
M

Merwin12

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 & "*"""
 
V

Van T. Dinh

Try:

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

Merwin12

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)







.
 

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