VBA INSERT INTO 语句(MS Access)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21282613/
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-08 17:36:16  来源:igfitidea点击:

VBA INSERT INTO statement (MS Access)

vba

提问by mrtn

I am having a problem with below and getting a runtime error 3134

我在下面遇到问题并收到运行时错误 3134

LastOrderNumber = DMax("Order", "Model_types")
NewOrderNumber = CLng(LastOrderNumber + 1)

CurrentDb.Execute "INSERT INTO Model_types (Order) " _
            & "VALUES (" & NewOrderNumber & ")"

The field 'Order' in Model_types is a Long Integer.

Model_types 中的“Order”字段是一个长整型。

Any help would be appreciated.

任何帮助,将不胜感激。

回答by parakmiakos

Order is a reserved word. You should change your statement to :

顺序是一个保留字。您应该将您的声明更改为:

CurrentDb.Execute "INSERT INTO Model_types ([Order]) " _
        & "VALUES (" & NewOrderNumber & ")"