I am Create login form then change password form.. Heres my code
i dont get it what is the problem of my code, VB 6 Say: Syntax Error Upadate Statement
Private Sub cmdOk_Click()
Dim rs As New ADODB.Recordset
Dim change As String
If txtOld.Text = Login.txtPassword.Text Then
rs.Open "Select Password From tblUser where UserID = '" & MDIForm1.id.Caption & "'", acd, adOpenForwardOnly
change = "UPDATE tblUser SET Password ='" & txtNew.Text & "' where UserID = '" & MDIForm1.id.Caption & "'"
MsgBox "Invalid Old Password"
The only thing that jumps out at me in that line is that you are using Password as a field name which is something you should not be doing, Password is a reserved word. You should as a general rule avoid using any reserved words, spaces or special characters in field names. Of course sometimes the design of the tables is out of our control in which cases you need to use the trusty little [ ] trick
change = "UPDATE tblUser SET [Password] ='" & txtNew.Text & "' where UserID = '" & MDIForm1.id.Caption & "'"
Is there a reason that you are using a select statement before the update there? I can't see any reason why you would do this in that piece of code. You are not doing anythign with it and then you are changing it 2 lines later so whatever is in that recordset would not be what is now in the database...