By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,504 Members | 2,606 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,504 IT Pros & Developers. It's quick & easy.

INSERT INTO PROBLEM

P: n/a
I have the following lines in a macro:
sql = "INSERT INTO IM (ITEM, DESC) VALUES (vitem, ndesc)"

DoCmd.RunSQL sql

Every time I execute the macro, I get a run time error saying there is a
syntax error in the INSERT INTO command. I have tried numerous variations
with the same result.

I would greatly appreciate anybody's help in pointing me in the right
direction.

John Cantlin
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The most obvious and likely culprit is "DESC", which it appears that you
have chosen as a field name. Unfortunately, it is a reserved SQL\Access
word, and cannot be used as a field name in any SQL. You will need to
change the field name.

There may of course be other problems.

BTW, save yourself a line of code and just write:

DoCmd.RunSQL "INSERT INTO IM (ITEM, DESC) VALUES (vitem, ndesc)"

Also, consider NOT using macros, but instead use VBA.
Darryl Kerkeslager

<jp*******@cox.net> wrote in message
news:cQnxd.60658$ka2.51585@fed1read04...
I have the following lines in a macro:
sql = "INSERT INTO IM (ITEM, DESC) VALUES (vitem, ndesc)"

DoCmd.RunSQL sql


Nov 13 '05 #2

P: n/a
.... and don't post twice under different messages, because I now see that
Mr. Steele already answered your question, so I just wasted 5 minutes of my
life, and I'm not getting any younger or smarter.
Darryl Kerkeslager

<jp*******@cox.net> wrote:

I would greatly appreciate anybody's help in pointing me in the right
direction.

John Cantlin

Nov 13 '05 #3

P: n/a
I apologize. The dup msg was a mistake..
"Darryl Kerkeslager" <Ke*********@comcast.net> wrote in message
news:Ib********************@comcast.com...
... and don't post twice under different messages, because I now see that
Mr. Steele already answered your question, so I just wasted 5 minutes of my life, and I'm not getting any younger or smarter.
Darryl Kerkeslager

<jp*******@cox.net> wrote:

I would greatly appreciate anybody's help in pointing me in the right
direction.

John Cantlin


Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.