How to UPDATE table records from a form. (1 Viewer)

Clayhead

Registered User.
Local time
Today, 20:20
Joined
Jan 3, 2016
Messages
13
Hi. I am new to access and have joined as i need help.

I have multiple IFs statements in my VBA when a button is clicked. They are working fine but i need the end result which would be to:

Lookup the Username on the form "Me.EnterExistingUsername" in Table "Users"

Then i need it to replace the Users password from "Me.EnterNewPassword" on the form to "password" field in the table Users.

I currently have:

Dim UpdateSQL As String

UpdateSQL = "UPDATE Users " _
& "SET Users.Password = me.EnterNewPassword " _
& "WHERE Users.Username = me.EnterExistingUsername;"

It does not return any error but also does not update the password. Can anybody please help?
 

JHB

Have been here a while
Local time
Today, 21:20
Joined
Jun 17, 2012
Messages
7,732
Try the below,(it is not tested).
Code:
CurrentDb.Execute ("UPDATE Users " _
        & "SET Password = '" & me.EnterNewPassword & "' " _
        & "WHERE Username = '" & me.EnterExistingUsername & "';"
 

Clayhead

Registered User.
Local time
Today, 20:20
Joined
Jan 3, 2016
Messages
13
It returns a sytax error.

It may be worth mentioning this is inside a VBA private sub. Would it help if i shared the whole code?
 

Clayhead

Registered User.
Local time
Today, 20:20
Joined
Jan 3, 2016
Messages
13
Ah was missing the ) at the end. Thanks for your help JHB :D
 

JHB

Have been here a while
Local time
Today, 21:20
Joined
Jun 17, 2012
Messages
7,732
My bad, but good you found out the missing ).
You're welcome, good luck. :)
 

Users who are viewing this thread

Top Bottom