Access中的Update语句出错

时间:2014-06-30 09:53:20

标签: ms-access

我必须在名为tbl_InvoicewiseDetails的表中更新3个值,我使用UPDATE语句。但是我收到错误no.3144 UPDATE语句中的SYNTAX错误。

我有以下代码:

CurrentDb.Execute "UPDATE tbl_InvoicewiseDetails" _    
    & "Set [Form Status] = " & "Received" & "" _
    & "Set [Form No] = " & Me.FormSerialNo & "" _
    & "Set [Form Amount] =" & Forms![ReceivedbyPBC]![tbl_tempFormDetails].Form![InvoiceValue] & "" _
    & "WHERE [Year&Invoice] =" & Forms![ReceivedbyPBC]![tbl_tempFormDetails].Form![Year&Invoice] & ";"    

请帮忙

这是从SQL View of Query构建器复制的SQL查询: -

UPDATE tbl_InvoiceWiseDetails 
SET tbl_InvoiceWiseDetails.[Form Status] = "Received", 
    tbl_InvoiceWiseDetails.[Form No] = [Forms]![ReceivedbyPBC]![FormSerialNo], 
    tbl_InvoiceWiseDetails.[Form Amount] = [Forms]![tbl_tempFormDetails]![InvoiceValue]
WHERE 
    (((tbl_InvoiceWiseDetails.[Year&Invoice])=[Forms]![tbl_tempFormDetails]![Year&Invoice]));

希望这是有帮助的

1 个答案:

答案 0 :(得分:0)

我认为应该只有一个SET。将所有SET替换为,

如果您有对表单的引用,CurrentDb.Execute也不起作用。你必须使用DoCmd.RunSql。 (编辑:我意识到以前评估过表单引用,所以问题不存在)。

我建议您将语句分配给变量并将变量Debug.Print分配 还

& "Set [Form Status] = " & "Received" & "" _

应该阅读

& "Set [Form Status] = 'Received'" & _

[表格号]是号码吗?如果是字符串,则需要提供引号,如下所示:

& "Set [Form No] = '" & Me.FormSerialNo & "'" _