更新语句中的VBA语法错误,3144

时间:2016-06-18 16:08:42

标签: sql vba access-vba ms-access-2010

我是VBA新手,无法查询工作

db.Execute "UPDATE t_inquiry " _
    & "SET [car rental contract printed?] = True " _
    & "WHERE [Customer_ID] = (SELECT [Gast_ID] FROM t_customer WHERE t_customer.[Mail 1] = '" & [rs]![Mail 1] & "')" _
    & "AND [car rental contract printed?] = [rs]![car rental contract printed?];"

第二行出了问题" where where"如果我删除该行,则查询有效。

有人有任何想法吗?感谢

1 个答案:

答案 0 :(得分:3)

检查字符串连接线之间的间距(对我来说,我通常在开始时放置空间以明显看到)。另外,使用IN运算符而不是子查询的等式=

db.Execute "UPDATE t_inquiry" _
    & " SET [car rental contract printed?] = True" _
    & " WHERE [Customer_ID] IN (SELECT [Gast_ID] FROM t_customer WHERE t_customer.[Mail 1] = '" & [rs]![Mail 1] & "')" _
    & " AND [car rental contract printed?] = " & [rs]![car rental contract printed?] & ";"