Access 2013 插入/更新

Access 2013 Insert / update

我有一个用于添加用户的表单。

我可以在 table 中添加、删除行,但是如果用户已经存在,我会假装更新。

我的目标是按子表单中的行进行编辑。 但是每次我按更新它都会给我一个错误。

Run-time error '3075' Syntax error operator in query expression.

我的操作码是这个

Private Sub cmdAdd_Click()
    'quando se carrega em Adicionar há 2 opcoes
    '1-Insert
    '2-Update
    If Me.txtuserid.Tag & "" = "" Then

        '1
        CurrentDb.Execute "INSERT INTO user(userid, username, userfunction, usercc) " & _
                " VALUES(" & Me.txtuserid & ",'" & Me.txtusername & "','" & Me.txtuserfun & "','" & Me.txtusercc & "')"
     Else
     '2
     CurrentDb.Execute "UPDATE user " & _
            " SET userid=" & Me.txtuserid & _
            ", username=" & Me.txtusername & "'" & _
            ", userfunction =" & Me.txtuserfun & "'" & _
            ", usercc =" & Me.txtusercc & "'" & _
            " WHERE userid =" & Me.txtuserid.Tag
      End If
    'clear fields
    cmdClear_Click
    'refresh
    SubForm1.Form.Requery
End Sub 

我做错了什么?

您是否在更新语句中遗漏了 '

CurrentDb.Execute "UPDATE user " & _
        " SET userid=" & Me.txtuserid & _
        ", username='" & Me.txtusername & "'" & _
        ", userfunction ='" & Me.txtuserfun & "'" & _
        ", usercc ='" & Me.txtusercc & "'" & _
        " WHERE userid =" & Me.txtuserid.Tag