How to UPDATE table records from a form.

Clayhead

Registered User.
Local time
Today, 02:56
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?
 
Try the below,(it is not tested).
Code:
CurrentDb.Execute ("UPDATE Users " _
        & "SET Password = '" & me.EnterNewPassword & "' " _
        & "WHERE Username = '" & me.EnterExistingUsername & "';"
 
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?
 
Ah was missing the ) at the end. Thanks for your help JHB :D
 
My bad, but good you found out the missing ).
You're welcome, good luck. :)
 

Users who are viewing this thread

Back
Top Bottom