ms access - vba:编译错误:预期:=
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31329829/
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
ms access - vba: Compile Error: expected: =
提问by PeterTaylorXC
I have a subroutine as below
我有一个子程序如下
Public Sub updateStagesTable(sName As String, percentageValue As Double)
stageName = "'" & sName & "'"
sSQL = "INSERT INTO StagesT ([Stage Name], [Stage Value In Percentage]) VALUES (" & stageName & "," & percentageValue & ");"
DoCmd.SetWarnings False
DoCmd.RunSQL sSQL
End Sub
and I call it from another subroutine as below
我从另一个子程序调用它,如下所示
economy = 3.53
updateStagesTable ("Economy", economy)
But I get this compile error
但我得到这个编译错误
Compile Error: expected: =
I don't understand what I am doing wrong here. Please help.
我不明白我在这里做错了什么。请帮忙。
回答by Tim Williams
updateStagesTable ("Economy", economy)
should be
应该
updateStagesTable "Economy", economy
with no parentheses
没有括号
See related: Unexpected results from typename
请参阅相关:typename 的意外结果
回答by PeterTaylorXC
I have never liked this peculiarity of VB so I always use the alternate CALL syntax, in your case this would be:
我从不喜欢 VB 的这种特性,所以我总是使用备用的 CALL 语法,在你的情况下,这将是:
Call updateStagesTable("Economy", economy)
which does allow the parentheses that all other languages expect
这确实允许所有其他语言所期望的括号

