VBA SQL语法问题

时间:2014-07-17 11:09:59

标签: sql vba syntax

我有以下SQL:

SQL = "UPDATE [TBLTMP] SET TBLTMP24 '" & Me.TOWN & "' WHERE TBLTMP00 = '" & "1" & "';"


Table name TBLTMP
Field to update TBLTMP24
Record to update TBLTMP00

我想将“Me.Town”的值存储在表TBLTMP中的TBLTMP24字段中,记录编号为1,任何人都有什么想法可能有用吗?

2 个答案:

答案 0 :(得分:1)

您在=之后错过了SQL语句中的TBLTMP24。您的陈述应该是:

SQL = "UPDATE [TBLTMP] SET TBLTMP24 = '" & Me.TOWN & "' WHERE TBLTMP00 = '" & "1" & "';"

答案 1 :(得分:0)

我认为您只需要在查询中添加=,如下所示:

SQL = "UPDATE TBLTMP SET TBLTMP24 = '" & Me.TOWN & "' WHERE TBLTMP00 = '" & "1" & "';"

如果您想更改某些列,请添加逗号,如下所示:

SQL = "UPDATE TBLTMP SET TBLTMP24 = '" & Me.TOWN & "', another_col = '" & Me.another & "' WHERE TBLTMP00 = '" & "1" & "';"