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

    Unanswered: SQL insert into problem with Quotes

    Basically I have a drop down box and I want the variable to read the value selected from the drop down box.

    Everything is working apart from I have to put quotes around each of the entry's in the box or the SQL will not work .

    I am trying to say select * from table where company='value in box'

    However I am unsure how I put quotes around the variable name?

    I thought it was like this but it does not seem to work. "'" & variable & "'"

    Sorry this is hard to explain.

    Many Thanks in advance for any help.

  2. #2
    Join Date
    Oct 2005
    Show me your connection string and the recordset statement your created, and I will fix it for you. HOw do you want to start the query, by button click or by change of value of your combox?

    remember for the string var you use "Select * from table where mystringfield ='" & StringVariable & "'", Connection

    For numeric variable you use
    RS.Open "Select * from table where mynumericfield =" & NumericVariable, COnnection
    Last edited by fredservillon; 11-25-05 at 19:32.

  3. #3
    Join Date
    Nov 2003
    Christchurch, New Zealand
    instead of this
    Code: "Select * from table where mystringfield ='" & StringVariable & "'", Connection
    I would use...
    quote = chr(34) "Select * from table where mystringfield =" & quote  & StringVariable & quote, Connection
    otherwise you can have problems with words that have ' in them...

    NOTE: I am not certain that 34 is the correct chr code... but it is pretty close...

Posting Permissions

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