Hi All, I'm trying to create a Login userform where a user may change his/her password in Access record, but it return Runtime Error -2147217900 (80040e14) - Syntax error in UPDATE statement. While the same update statement is working just fine if I try it directly in MS Access query.
My code as below :
Kindly help which of above code is wrong? I'm using MS Excel 2016 and MS Access 2016.
My code as below :
VBA Code:
Sub User_CP(user_id As String, Password As String)
Dim que As String
Dim con As New ADODB.Connection
Dim addData As New ADODB.Recordset
con.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\database\database.mdb"
If frm_CP.TextBox1.Value <> frm_CP.TextBox2.Value Then
MsgBox "Pw sama!!"
Else
Set addData = New ADODB.Recordset
que = "update [USER] set Password= '" & frm_CP.TextBox2.Value & "' WHERE User_Id = '" & Sheet4.Range("User_Id") & "'"
addData.Open que, con, adOpenDynamic, adLockOptimistic
addData.Update
End If
addData.Close
con.Close
End Sub
Kindly help which of above code is wrong? I'm using MS Excel 2016 and MS Access 2016.