vba 语法错误:SQL 语句查询表达式中的逗号?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22413569/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 02:21:24  来源:igfitidea点击:

Syntax Error: Comma in Query Expression of SQL Statement?

sqlvbams-access

提问by user2296381

Alright folks, I am 100% Batshit insane at this point. Can someone possibly help me here? I'm clueless after trying EVERYTHING and searching for others with this experience. I'm at a loss here. I've tried brackets around all the table/field names. I've tried taking the tablename off the Select fields, I've tried moving the parenthesis backwards and forwards but to no avail.

好吧,伙计们,在这一点上,我 100% 疯了。有人可以在这里帮助我吗?在尝试了一切并寻找具有这种经验的其他人之后,我一无所知。我在这里不知所措。我试过在所有表/字段名称周围加括号。我试过从 Select 字段中删除表名,我试过前后移动括号但无济于事。

The error I get is: "Syntax Error (comma) in query expression. '( [F1], [F2], [F3], [F4], [F5], [F6], [F7], [F8] )'.

我得到的错误是:“查询表达式中的语法错误(逗号)。'( [F1], [F2], [F3], [F4], [F5], [F6], [F7], [F8] ) '。

    CurrentDb.Execute "INSERT INTO [tblSalesJournal] ( [Store], [Business Unit], [Country], [State], [Store Type], [Net Sales], [Fee], [Total] ) " & _
    "SELECT ( [F1], [F2], [F3], [F4], [F5], [F6], [F7], [F8] ) " & _
    "FROM [tblImport]"

Any help is GREATLY appreciated

任何帮助是极大的赞赏

回答by Fionnuala

The problem is:

问题是:

SELECT ( [F1], [F2], [F3], [F4], [F5], [F6], [F7], [F8] )

You should not bracket a SELECT statement, therefore

不应将 SELECT 语句括起来,因此

SELECT [F1], [F2], [F3], [F4], [F5], [F6], [F7], [F8]

Some MS errors are odd.

一些 MS 错误很奇怪。