Quote marks for Numeric vs. Text??? (data type conversion error)

W

worksfire1

I am so confused in my procedure where I am trying to take 2 text fields
from a multi-list box and insert them into a table as text. I keep getting a
data type conversion error. Does this error mean something is wrong with me
having a text versus numeric quoting in my INSERT INTO statement? Please
help me make this where it will grab the 2 text fields and insert them into
tblTest as text fields without the "data type conversion" error.

db.Execute "INSERT INTO tblTest " & _
"(Firstfieldname, Sixthfieldname)" & _
"VALUES(" & """ & ctl.ItemData(varItem) & """, """ & ctl.Column(6, varItem)
& "")"
 
G

George Nicholson

As written:
"....Sixthfieldname)VALUES(...."

try adding a space before VALUES.

HTH,
 
W

worksfire1

It finally worked when I put single quotes around the text field. Is that
correct that single quotes are for text? Or did I just luck up for some
other reason?
 
M

Marshall Barton

worksfire1 said:
It finally worked when I put single quotes around the text field. Is that
correct that single quotes are for text? Or did I just luck up for some
other reason?


That would only make a difference if the text vield contains
a " character.

You can use either ' or " to enclose a string value in an
SQL statement. However, if whichever quote you use to
enclose the string also appears inside the string, then you
must double up on that character inside the string.

& """, """ & Replace(ctl.Column(6, varItem), """", """""") &
""")"
 

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