Oliver Van Dyk
Oliver Van Dyk

Reputation: 1

Visual Basic Access - recording information from Textboxes

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

Answers (3)

Gustav
Gustav

Reputation: 55806

Password is a reserved word, so:

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

Upvotes: 0

Han
Han

Reputation: 3072

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

Upvotes: 1

L42
L42

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

Related Questions