0

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.

2
  • 1
    Instead of executing the statement, print it out and make sure it's valid SQL. That being said...better to use parameterized queries. stackoverflow.com/questions/17678856/… Commented Aug 4, 2018 at 1:28
  • VALUE there should be a string ("VALUE"), not unless it is a variable containing the string "VALUE". Commented Aug 4, 2018 at 1:59

3 Answers 3

1

Two errors:

  1. You have space in one of your field. Use brackets if you have space or if you use reserved words.

  2. 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 & "')" 
Sign up to request clarification or add additional context in comments.

Comments

0

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 & "')" 

Comments

0

Password is a reserved word, so:

CurrentDb.Execute "INSERT INTO tblUser(User ID, Fullname, Username, [Password], Security) " _ 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.