syntax error in simple INSERT

msmeth
04-16-2004, 08:28 AM
What is wrong with this statement? I'm getting a SYNTAX ERROR IN INSERT INTO STATEMENT error on it. But of course when I put it into Access, it works just fine :mad:


cn.Execute "INSERT INTO Tags ([Tag]) VALUES (" & 5 & ")"


The field Tag is a number field that is the primary key.

Shurik12
04-16-2004, 08:33 AM
"INSERT INTO Tags ([Tag]) VALUES (5)"


Shurik.

msmeth
04-16-2004, 08:40 AM
"INSERT INTO Tags ([Tag]) VALUES (5)"


Shurik.

doesn't like that either....it makes no sense huh

Shurik12
04-16-2004, 08:51 AM
if you field is not autonumber it should work

msmeth
04-16-2004, 08:58 AM
if you field is not autonumber it should work

It's not autonumber. Anyway, I recreated the table and named it something else and it works now. Whatever sense that makes, I don't know...I'll chalk it up to Microsoft.

Thanks tho.

MKoslof
04-16-2004, 06:41 PM
Maybe your database needed to be compacted and repaired. Access databases need to be repaired frequently because it is a flat file and all processing involves reading the whole file into memory.

zy_abc
04-17-2004, 12:06 AM
Why not try the below code:

Dim SQL as String
SQL="INSERT INTO Tags ([Tag]) VALUES (5)"
Docmd.RunSQL(SQL)

I assume that you are writing code in MS-Access VBA.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum