Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quotes in string causing DAO error 1

Status
Not open for further replies.

jrh1

Programmer
May 8, 2003
5
US
If I run the following code, the values test, test1,1 and 2 are inserted as a record into the entityPos table:

dbs.Execute " INSERT INTO entityPos(subModelNm,entityDisplayNm, horizontalPos,verticalPos) VALUES ('test', 'test1',1,2);"


If I change the values I am inserting into variables, the code fails:
dbs.Execute " INSERT INTO entityPos (subModelNm,entityDisplayNm, horizontalPos,verticalPos) VALUES (var1, var2,var3,var4);"

If I look at the value of the variable var1 or var2 Access is reading it with double quotes. How do I change it so that the variable is read with single quotes?

Thanks much in advance,
Jeff
 
Hi jrh1,

Double quotes and single quotes are all the same to Access - but very different to VBA.

What is wrong is that you have your variable names inside a VBA string, so VBA is interpreting them as text and not as variables. What you need is ..

Code:
"INSERT INTO .... VALUES ('" & var1 & "', '" & var2 & "', " & var3 & ", " & var4 & ");"

Emjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top