我正在尝试创建一个表格,以允许您注册用户。我查过教程,但似乎都没有用。这是我目前使用的代码:
CurrentDb.Execute "INSERT INTO tblUser(User ID, Fullname, Username, Password, Security) " _
& VALUES & " (" & Me.ID & ",'" & Me.Fullname & "','" & Me.Uname & "','" & _
Me.uPass & "','" & Me.Pri & "')"
运行代码时,我得到:
运行时错误'3134':INSERT INTO语句中的语法错误。
答案 0 :(得分:1)
两个错误:
您在一个字段中有空格。如果有空格,请使用方括号 或使用保留字。
VALUES必须包含在字符串中,而不是作为变量。
更正:
CurrentDb.Execute "INSERT INTO tblUser([User ID], Fullname, Username, Password, Security) " & _
"VALUES (" & Me.ID & ",'" & Me.Fullname & "','" & Me.Uname & "','" & _
Me.uPass & "','" & Me.Pri & "')"
答案 1 :(得分:0)
根据我的评论,尝试以下操作:
CurrentDb.Execute "INSERT INTO tblUser(User ID, Fullname, Username, Password, Security) " _
& "VALUES(" & Me.ID & ",'" & Me.Fullname & "','" & Me.Uname & "','" & _
Me.uPass & "','" & Me.Pri & "')"
答案 2 :(得分:0)
密码是保留字,所以:
CurrentDb.Execute "INSERT INTO tblUser(User ID, Fullname, Username, [Password], Security) " _