ADO-SQL LIKE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • GAVO-UK

    #1

    ADO-SQL LIKE

    Hey.

    Using Access ADP and MSDE.

    can some one please tell me what is wrong with this SQL string using
    ADO. I get an error somewhere around the LIKE statement.

    .Source = "SELECT tblCustomer.Fir stName,
    tblCustomer.Las tName, tblCustomer.Pos tCode " & _
    "FROM tblCustomer " & _
    "WHERE (FirstName LIKE '%" &
    Form("txtSearch FirstName") & "%');"


    Thanks a lot.
    GAVO

  • lylefair

    #2
    Re: ADO-SQL LIKE

    My guess is that there is something wrong with
    Form("txtSearch FirstName")
    as I have tested your syntax and it seems to work.
    What is Form? Do you mean Me.txtSearchFir stName.Value or
    Me.txtSearchFir stName.Text? Could you use just txtSearchFirstN ame?
    Could Me.txtSearchFir stName.Value be NULL?

    I would try
    debug.print "SELECT tblCustomer.Fir stName,
    tblCustomer.Las tName, tblCustomer.Pos tCode " & _
    "FROM tblCustomer " & _
    "WHERE (FirstName LIKE '%" &
    Form("txtSearch FirstName") & "%');"
    and examine the string carefully.

    Comment

    • GAVO-UK

      #3
      Re: ADO-SQL LIKE

      Thanks Lylefair.
      The code was fine, the problem was that I was running the code from a
      "onClick" on a label and thefore the text box "txtSearchFirst Name"
      never lost its focus and I believe did not save the value, so what I
      did is, I set the focus on a different control before running the SQL
      and its now working.

      Thanks

      Comment

      Working...