SBBmaster09
Registered User.
- Local time
- Today, 16:40
- Joined
- Apr 26, 2013
- Messages
- 92
Hi I am having a problem with my codes.. :banghead:
I have a login button in which if the username has an empty password or the user is his/her first time to login, another form will appear which is the Set New Password. How can I change the password of that current user, my Set New Password Form has two fields which is 'txtSetPassword1' and 'txtSetPassword2' and an OK button.
The user must enter a new password and a verification password, if the 2 fields matched, the new password entered will change the password in the table. The table name is 'tbl_UsernamesQry'.
I have done it but the main problem is, it changes the other's users password not the current user.
Here is my code for the OK button of that form Set New Password:
Private Sub btnSetOk_Click()
If Me.txtSetPassword1.Value = Me.txtSetPassword2.Value Then
Me.txtSetPassword1.SetFocus
Set db = CurrentDb
strSQL = "SELECT strUsername " & _
"FROM tbl_UsernamesQry " & _
"WHERE [Enterprise ID]=strUsername & "
Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
With rst
.Edit
rst("Password") = txtSetPassword1.Value
.Update
.Close
End With
db.Close
DoCmd.Close acForm, "frmSetPassword", acSaveNo
Else
MsgBox "Password did not match. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtSetPassword1.SetFocus
End If
End Sub
Thanks for anyone who can help.
I have a login button in which if the username has an empty password or the user is his/her first time to login, another form will appear which is the Set New Password. How can I change the password of that current user, my Set New Password Form has two fields which is 'txtSetPassword1' and 'txtSetPassword2' and an OK button.
The user must enter a new password and a verification password, if the 2 fields matched, the new password entered will change the password in the table. The table name is 'tbl_UsernamesQry'.
I have done it but the main problem is, it changes the other's users password not the current user.
Here is my code for the OK button of that form Set New Password:
Private Sub btnSetOk_Click()
If Me.txtSetPassword1.Value = Me.txtSetPassword2.Value Then
Me.txtSetPassword1.SetFocus
Set db = CurrentDb
strSQL = "SELECT strUsername " & _
"FROM tbl_UsernamesQry " & _
"WHERE [Enterprise ID]=strUsername & "
Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
With rst
.Edit
rst("Password") = txtSetPassword1.Value
.Update
.Close
End With
db.Close
DoCmd.Close acForm, "frmSetPassword", acSaveNo
Else
MsgBox "Password did not match. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtSetPassword1.SetFocus
End If
End Sub
Thanks for anyone who can help.