VBA 3134 runtime error

The following code creates an SQL string that generates a syntax error (3134) in MS Access.

        sql = "INSERT INTO tblItems (desc, descExtended, itemNumber, currentPrice) " & _
                     "VALUES (" & _
                     "'" & rs.Fields("Field6") & "', " & _
                     "'" & rs.Fields("Field7") & "', " & _
                     rs.Fields("Field1") & ", " & _
                     rs.Fields("Field8") & _
                     ")"
        db.Execute sql, dbFailOnError

The value of the string "sql", which produces a syntax error:

"INSERT INTO tblItems (desc, descExtended, itemNumber, currentPrice) VALUES ('APPLE GRANNY SMITH SLI IQF', 'GEMS OF FRUIT', 2050791, 49)"

The names of the tables and fields are correct. The "desc" and "descExtended" fields are of type Text. "itemNumber" and "currentPrice" are the number.

+5
source share
1 answer

. DESC SQL-. DESC SQL. [], . ( , , .) .

INSERT INTO tblItems ([desc], descExtended, itemNumber, currentPrice) 
VALUES ('APPLE GRANNY SMITH SLI IQF', 'GEMS OF FRUIT', 2050791, 49)

INSERT INTO tblItems (Descript, descExtended, itemNumber, currentPrice) 
VALUES ('APPLE GRANNY SMITH SLI IQF', 'GEMS OF FRUIT', 2050791, 49)
+5

All Articles