Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    14

    Unanswered: Like Statement Dosent Work

    CQ.SQL = "PARAMETERS something1 LONG; " & _
    " SELECT * FROM TELEPHONE_DIRECTORY" & _
    " WHERE EXTENSION_NO LIKE '[something1]%' " & _
    " ORDER BY LAST_NAME, EXTENSION_No ; "
    Public Sub Text1_change()
    CQ![something1] = Text1.Text
    .......
    .......(more coding)

    end sub
    everything works if i change the sql statement WHERE EXTENSION_NO = [something1]

  2. #2
    Join Date
    Dec 2003
    Location
    Oklahoma, USA
    Posts
    354
    Are you using SQL Server?

    If you were using Oracle, the query would be:

    Code:
    ...
    ' WHERE EXTENSION_NO LIKE "'|| something1 || '"%' ...
    NOTE: ... EXTENSION_NO LIKE (single tick)(double tick) || something1 || (single tick)(double tick)%(single tick) ... in the variation of SQL you are using, you'll switch single and double tick use.

    I wonder if the name of the variable is being put into your query instead of the value...

    JoeB

  3. #3
    Join Date
    Feb 2004
    Posts
    14
    NO JOY STILL

  4. #4
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    Access 2002,

    Select *
    from table
    where column LIKE [param] &'*'
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  5. #5
    Join Date
    Feb 2004
    Posts
    14

    issue solved

    CQ.SQL = "PARAMETERS something1 string; " & _
    " SELECT * FROM TELEPHONE_DIRECTORY" & _
    " WHERE EXTENSION_NO LIKE [something1] " & _
    " ORDER BY LAST_NAME, EXTENSION_No ; "

    Public Sub Text1_change()
    CQ![something1] = "*" & Text1.Text & "*"
    .......
    .......(more coding)

    1. by changing the statement CQ![something1] = Text1.Text TO CQ![something1] = "*" & Text1.Text & "*" everything works

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •