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

Syntax error - INSERT INTO and SELECT statements

P: 5
I get syntax errors while trying to copy all data from a query into a table using INSERT INTO and SELECT.
Here are the lines:

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO LoadTBTemp[(Data1[, Data2[, Data3[, Data4[, Data5[, Data6[, Data7[, Data8[, Data9[, Data10[, Data11[, Data12[, Data13[, Data14[, Data15]])]
  2.     SELECT [qryCpCpk.]Data1[, Data2[, Data3[, Data4[, Data5[, Data6[, Data7[, Data8[, Data9[, Data10[, Data11[, Data12[, Data13[, Data14[, Data15]
  3.     FROM LoadTB
Error for INSERT INTO: Expected: end of statement
Error for SELECT: Expected: Case

I'm still using ACCESS 2003 (VBA 6.3).

Would someone please kindly point out the problems or suggest a better codes for me? Thanks very much,
Feb 22 '12 #1
Share this Question
Share on Google+
9 Replies


Rabbit
Expert Mod 10K+
P: 12,327
You have a bunch of extraneous square brackets.
Feb 22 '12 #2

P: 5
Thanks for quick response. That's the exact brackets format from MS site.
Feb 22 '12 #3

Rabbit
Expert Mod 10K+
P: 12,327
You have misunderstood Microsoft's syntax.

That only designates that what follows is optional syntax. And if you choose to use the optional syntax, you don't use the brackets.
Feb 22 '12 #4

P: 5
I have removed the brackets but same error prompted. I' a newbie. Would you please show me your fix? Greatly appreciated.
Feb 22 '12 #5

Rabbit
Expert Mod 10K+
P: 12,327
Show us what you have after you've removed the brackets.
Feb 22 '12 #6

P: 5
Here it is:
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO LoadTBTemp (Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10, Data11, Data12, Data13, Data14, Data15)
  2.     SELECT qryCpCpk.Data1, qryCpCpk.Data2, qryCpCpk.Data3, qryCpCpk.Data4, qryCpCpk.Data5, qryCpCpk.Data6, qryCpCpk.Data7, qryCpCpk.Data8, qryCpCpk.Data9, qryCpCpk.Data10, qryCpCpk.Data11, qryCpCpk.Data12, qryCpCpk.Data13, qryCpCpk.Data14, qryCpCpk.Data15
  3.     FROM qryCpCpk
Feb 22 '12 #7

Rabbit
Expert Mod 10K+
P: 12,327
Please use code tags when posting code.

And show us the SQL for qryCpCpk and the table definition of LoadTBTemp.
Feb 22 '12 #8

P: 5
I thank you for your time and patience. I have figured out a way around this problem, using Append Query.

But I have a quick favor to ask: is there command to merge fields of data into another field? This is my problem. I'm trying to calculate std. dev. of these 15 columns of data for a specific range of date. Since ACCESS 2003 only could do it for 1 field, I am trying to "merge" all 15 data fields into one and calculate std.dev. from there. Is this possible?

I am sorry to ask too much. If you think I violate any rule here, please tell me and don't need to response to my programming ignorance. Thanks.
Feb 22 '12 #9

NeoPa
Expert Mod 15k+
P: 31,275
@NikArt.
We don't allow separate follow-up questions in existing threads, aspecially when there is no obvious connection. We're happy to answer any properly expressed question though, as long as it's posted in its own thread.

As for the original question of this thread, I find it hard to accept that any problems you may have experienced after the code was changed for post #7 can be related to the code you're using. It seems to be fine and I certainly would not expect the original errors to have persisted. I would go as far as to say that I believe this question has an answer.
Feb 24 '12 #10

Post your reply

Sign in to post your reply or Sign up for a free account.