form to reset a password

mcgraw

Registered User.
Local time
Today, 10:54
Joined
Nov 13, 2009
Messages
77
Ok, I will say up front that I have no idea what I am doing. :D I would like to create a form that users can use to reset their access 2007 database password.

I have a query that is the row source for a combo box that will only return the current user logged in, and have 2 unbound text boxes, one for old password, and one for new password.

I'm not sure how to program it so that 1: it verifies that the old password is correct, and then 2: updates the password field to the new password.

The two unbound text fileds are called txtOldPwd and txtNewPwd.

Any help would be appreciated!
 
On the logon form here at work, I have a button that allows a user to change their password. I have a bound field to the actual password (Visible Property = false) and an unbound field for the new field (Visible Property = false). When the button is clicked, the following code fires:

Code:
Private Sub cmdChangePwd_Click()
Dim intConfirm As Integer
intConfirm = MsgBox("Do you wish to change your password?", vbYesNo, "Change Password")
 
If intConfirm = 7 Then
    Exit Sub
End If
If IsNull(Me.cboEmployee) Then
    MsgBox "Please select your initials before proceeding", vbInformation, "No Username Selected"
    Exit Sub
End If
 
Me.lblNewPwd.Visible = True
Me.lblOldPwd.Visible = True
Me.txtNewPwd.Visible = True
Me.txtNewPwd = ""
Me.txtOldPwd.Visible = True
Me.txtOldPwd = ""
DoCmd.GoToControl ("txtoldpwd")

On the after update event of the New Password field, I have the following code:

Code:
Dim stNewPwd As String
Dim stUpdateSql As String
stNewPwd = Me.txtNewPwd
 
if me.txtnewpwd = me.cboEmployee.column(3) then
  stUpdateSql = "UPDATE TblEmployees SET TblEmployees.strEmpPassword = """ &     stNewPwd & """"
  stUpdateSql = stUpdateSql & " WHERE (((TblEmployees.lngEmpID)=" &   Me.cboEmployee & "));"
else
 Msgbox "Old password does not match. Please try again"
 exit sub
end if
 
 
CurrentDb.Execute stUpdateSql
DoCmd.GoToControl ("cboMenuChoice")
Me.lblNewPwd.Visible = False
Me.lblOldPwd.Visible = False
Me.txtNewPwd.Visible = False
Me.txtOldPwd.Visible = False
MsgBox "Password Successfully Changed", , "Password Changed"
 
Here is how I did it. I have a form with five objects. EmployeeID and password of employee currently logged in (visible = no). Then unbound text boxes old password, new password, new password 2, and submit button. On click of submit, is the following code.

Code:
Option Compare Database
Option Explicit

Public lngLogAttempts As Long
Const Mssg1 = "  Please Enter User Name and Password.   "
Const Mssg2 = "Please enter your old password correctly.    "
Const Title1 = " Logon Error"
Const Mssg3 = " Password cannot be 'changeme'."
Const Mssg4 = "Password is not typed correctly."
Const mssg5 = "Password cannot be left blank."


Private Sub cmdSubmit_Click()
If IsNull(Me.txtOldPassword) Then
MsgBox Mssg2, vbCritical, Title1
Else
If IsNull(Me.txtNewPassword) Then
MsgBox mssg5, vbCritical, Title1
Else
If Me.txtOldPassword.value <> Me.txtPassword Then
MsgBox Mssg2, vbCritical, Title1
Else
If Me.txtNewPassword.value <> Me.txtRetypePassword Then
MsgBox Mssg4, vbCritical, Title1
Else
If Me.txtNewPassword.value = "changeme" Then
MsgBox Mssg3, vbCritical, Title1
Else
Me.txtPassword.value = Me.txtNewPassword
DoCmd.Close acForm, "frmchangepassworduser", acSaveYes
End If
End If
End If
End If
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom