PDA

View Full Version : Code to change user login password?



bunty
07-16-2010, 02:00 PM
hi all,
I have one table which contain multiple user records.I wanted to provide change password option to the user.
In Suppose I have enter username , password in login page and when i click on change password button the new screen will be open which contain User name,old password,new password and confirm password.
I user name textbox login user name should be display in a readable mode .so,user can only enter old,and new password and click update.that new password will update in a database.I have some code but its not functioning properly.
If any one have some code please share with me.

thanks.

HiTechCoach
07-16-2010, 03:30 PM
hi all,
I have one table which contain multiple user records.I wanted to provide change password option to the user.
In Suppose I have enter username , password in login page and when i click on change password button the new screen will be open which contain User name,old password,new password and confirm password.
I user name textbox login user name should be display in a readable mode .so,user can only enter old,and new password and click update.that new password will update in a database.I have some code but its not functioning properly.
If any one have some code please share with me.

thanks.

I would use an Append query to update the data.

If you have created you own Security system, then my code or anyone else's custom code will not work with yours unless you design yours to be identical.

Are you experienced/expert enough with VBA that you can figure out VBA code without any help? If so, I can post some code snippets for you to analysis and figure out so that you can write your own code.

If you do not feel like you are experienced/expert enough to understand VBA code written by others, I would recommend that you post the VBA code you are using so we can help you debug it.

bunty
07-17-2010, 12:58 AM
Hi HiTech..
First thanks for your response.yes I am not an expert in Vba.I just started to work on that.
I wanted to shere my file with you but the size big.Here I am posting you my login page code.what i wrote AND User table field name User_Id,Last_name,First_name,Email_Id,Password,status,User_Type.
Option Compare Database
Private intLogonAttempts As Integer

Private Sub cmdCancel_Click()
Form_frmLogon.Visible = False
'Unload Form_frmLogon
End Sub

Private Sub cmdChangePassword_Click()
If Me.txtPassword.Value = DLookup("User_ID", "User", "[User_Id]='" & Me.txtUserId.Value & "'") Then

User_Id = Me.txtUserId.Value

'Close logon form and open change password screen

DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "ChangePassword"

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If
End Sub




Private Sub cmdOK_Enter()

End Sub

Private Sub Form_Open(Cancel As Integer)
'On open set focus to combo box
Me.txtUserId.SetFocus
End Sub

Private Sub txtUser_Id_AfterUpdate()
'After selecting user name set focus to password field
Me.txtPassword.SetFocus
End Sub

Private Sub cmdOK_Click()

'Select Case Me.Frame30
'Case 1
' Form_Search.Visible = True
'Case 2
' Form_Admin.Visible = True
'End Select

'End If
'Check to see if data is entered into the UserName combo box

If IsNull(Me.txtUserId) Or Me.txtUserId = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.txtUserId.SetFocus
Exit Sub
End If

'Check to see if data is entered into the password box

If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If

'Check value of password in tblEmployees to see if this matches value chosen in combo box
'----------------12/07/10-------------------------
' If Me.rdNormalUser.Section = True Then


If Me.txtPassword.Value = DLookup("Password", "User", "[User_Id]='" & Me.txtUserId.Value & "'") Then

User_Id = Me.txtUserId.Value

'If Me.rdNormalUser.Section = True Then
If Me.rdNormalUser.Section = True Then


'Close logon form and open search screen

DoCmd.Close acForm, "frmLogon", acSaveNo
'DoCmd.OpenForm "Search"
Else
' If Me.rdAdmin. Then
' DoCmd.Close acForm, "frmLogon", acSaveNo
' DoCmd.OpenForm "Admin"

' Else
'MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
' End If
'End If
End If
Select Case Me.Frame30
Case 1
Form_Search.Visible = True
Case 2
Form_Search.Visible = False
Form_Admin.Visible = True
End Select


'----------------12/07/10-------------------------

'If User Enters incorrect password 3 times database will shutdown

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If
End If

End Sub

Private Sub cmdReset_Click()
On Error GoTo Err_cmdReset_Click


Screen.PreviousControl.SetFocus
DoCmd.FindNext

Exit_cmdReset_Click:
Exit Sub

Err_cmdReset_Click:
MsgBox Err.Description
Resume Exit_cmdReset_Click

End Sub


Please find the attachment screenshot of change password form and login page.

Thanks..