查询表达式'id ='中的运行时错误'3075'语法错误(缺少运算符)

时间:2018-08-08 07:51:35

标签: ms-access access-vba

我正在尝试创建将进行软删除的脚本。显然,运行脚本后遇到了运行时错误。请帮忙。

Private Sub cmdDelete_Click()
Dim db As DAO.Database
    'delete record
    'check existing selected record
    'If Not (Me.frmGatewaySub.Form.Recordset.EOF And Me.frmGatewaySub.Form.Recordset.BOF) Then
        'confirm deletion

        If MsgBox("Are you sure you want to soft delete this?", vbYesNo) = vbYes Then
            'soft delete now
            Set db = CurrentDb

            Call db.Execute( _
                "Update dbo_gateway" & _
                " set deleted_at= now()" & _
                " where id=" & Me.txtID.Value, dbSeeChanges)

            'clear text box
            cmdClear_Click
            Me.frmGatewaySub.Form.Requery

        End If

    'End If

End Sub

1 个答案:

答案 0 :(得分:1)

您的文本框为空,因此:

" where id=" & Me.txtID.Value, dbSeeChanges)

成为:

" where id="

因此,如果txtID为Null,请仔细检查您的代码并阻止其运行。