Reputation: 1
I'm trying to create a form that allows you to register users. I've looked up tutorials and none of them seem to work. This is the code I am stuck with currently:
CurrentDb.Execute "INSERT INTO tblUser(User ID, Fullname, Username, Password, Security) " _
& VALUES & " (" & Me.ID & ",'" & Me.Fullname & "','" & Me.Uname & "','" & _
Me.uPass & "','" & Me.Pri & "')"
When I run the code I get:
Runtime error '3134': Syntax error in INSERT INTO statement.
Upvotes: 0
Views: 58
Reputation: 55806
Password is a reserved word, so:
CurrentDb.Execute "INSERT INTO tblUser(User ID, Fullname, Username, [Password], Security) " _
Upvotes: 0
Reputation: 3072
Two errors:
You have space in one of your field. Use brackets if you have space or if you use reserved words.
VALUES must be included in the string, not as a varible.
Correction:
CurrentDb.Execute "INSERT INTO tblUser([User ID], Fullname, Username, Password, Security) " & _
"VALUES (" & Me.ID & ",'" & Me.Fullname & "','" & Me.Uname & "','" & _
Me.uPass & "','" & Me.Pri & "')"
Upvotes: 1
Reputation: 19727
From my comment, try below:
CurrentDb.Execute "INSERT INTO tblUser(User ID, Fullname, Username, Password, Security) " _
& "VALUES(" & Me.ID & ",'" & Me.Fullname & "','" & Me.Uname & "','" & _
Me.uPass & "','" & Me.Pri & "')"
Upvotes: 0