Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2009

    Red face Unanswered: Variable problem

    i need my where statement to pull the text to complete the statement from a variable

    such as

    SELECT "column_name"
    FROM "table_name"
    WHERE "column_name" variable

    variable = "like "*" variable1 AND LIKE "*" & variable2 & "*""

    i cant get the above to work. i have not been able to find the answer my head cant take it. pleaseeeeeeeeeeeeeee help!
    why cant i do this? is there a way?

  2. #2
    Join Date
    May 2005
    Welcome to the forums

    Martin Green: Putting SQL and VBA together

    Me.Geek = True

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    if its a sting/text column then the value/parameter has to be encapsualtred in either single or double quotes
    strSQl = "Select my, column, list from mytable"
    strSQl = strSQL & " where acolumn = '" & avariable & "'"

    some people prefer to use the chr$(34) .. generates a " to act as the quote symbol to make it easier to read the SQL
    strSQl = strSQL & " where acolumn = " & chr$(34) & avariable & chr$(34)
    if its a numeric column then you dont use the quote marks.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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