423,491 Members | 2,205 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,491 IT Pros & Developers. It's quick & easy.

Syntax error (comma) in query expression

P: 6
It would be great if someone helps me out!

I'm getting an error as "Syntax error (comma) in query expression" for the below code in MS ACCESS 2007.

CurrentDb.Execute "INSERT INTO empmast(empno,empname,scale) SELECT ([EMP NO ], [EMP NAME], [SCALE]) from TABLEA"

Thanks in advance
Jun 10 '18 #1
Share this Question
Share on Google+
7 Replies


Nauticalgent
P: 69
Only thing I would suggest is removing the parentheses in your select statement. But then, I avoid SQL statements and use stored queries whenever possible.

Have you considered using an Append Query and let Access do the work? They are much more efficient and you can still use the .Execute method to run them.
Jun 10 '18 #2

NeoPa
Expert Mod 15k+
P: 31,037
If it isn't the space after "[Emp No" and before the next "]" then you'll need to show us the actual SQL used (See How to Debug SQL String).
Jun 10 '18 #3

NeoPa
Expert Mod 15k+
P: 31,037
NauticalGent:
Have you considered using an Append Query and let Access do the work? They are much more efficient and you can still use the .Execute method to run them.
As the code shown is exactly that - an example of an Append Query - I'm not sure that's really a supportable comment.

That said, the extra parentheses may well be the issue. Good spot.
Jun 10 '18 #4

Nauticalgent
P: 69
Agreed, they are one and the same. I am going on the premise that Access establishes a query plan for stored queries and does not have to take the time to convert the SQL statement.

I can imagine the overhead is negligible, but that is what I based my statement on...that and the fact I am lazy and prefer Access to do the heavy lifting for me!
Jun 10 '18 #5

NeoPa
Expert Mod 15k+
P: 31,037
I see. You're using the term "Query" for the Access object that's a QueryDef. Fair enough, but I didn't realise that (SQL strings are also generally known as Queries).

As you say, the delay would be negligible. Hard even to quantify.
Jun 11 '18 #6

Nauticalgent
P: 69
Curious as to how the OP is getting along with sorting this out..
Jun 11 '18 #7

NeoPa
Expert Mod 15k+
P: 31,037
Often the way. Unfortunately we have no control over members' manners, or even their lives. There may be various good reasons why they haven't replied as yet. Certainly, an approach whereby you deal with what's in front of you only, is recommended. If you watch the kettle you'll only let yourself in for frustration.
Jun 11 '18 #8

Post your reply

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