Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
A strong password system is crucial to keep any system secure. But what if we forget our passwords? This is where “Forgot Password System” comes in handy. They are a lifesaver for those who are forgetful or concerned about security, especially when dealing with platforms such as Microsoft Access.
In this section, you will learn, how to make a functional User Registration form and Forgot Password system in the Access Database Step by Step.
Imagine a scenario where a user has been assigned tasks related to sales and stock maintenance in a business database. However, due to a sudden mental blank or a change in personnel, the user is unable to remember the password and is stuck at the login screen. But, there is no need to worry as the Forgot Password System is here to come to the rescue.
Let’s have a look, at how it will work.
Before proceeding to the Forgot Password System, the user account must be verified whether it exists or not. There can be several methods to verify a user account, these methods refer to some other security measures other than the password.
To recover an account, there can be several methods to reset the password for a local database, these are some of the common options:
You can use any of these options but we are going to use the last 5 digits of the phone number as a recovery method in this project.
There are more advanced account recovery methods like:
SMS or OTP code verification
Email code verification
Security key, usually stored in a USB drive
The process of password policy will remain the same as described in “Part-3 Change Password System“.
Create a New User Register form based on the User table described in Part 2 of the Ultimate Login System
All text boxes and a combo box of the form will be unbound.
Add a field in the User Table for the last 5 digits of the user’s phone number to verify the user before proceeding to change the password. The data type of the field should be “Short Text”.
Mandatory Fields: Before inserting the user input data into the table, mandatory fields must be filled as mentioned with the asterisk sign.
Phone Criteria: An error message will appear if the phone’s digits length is more than 5.
Password Match: If the “password” and “verify password” do not match, the error message will appear.
Enter Data: Proceed to enter data into the table if no error is found.
Private Sub Command17_Click()
If IsNull(Me.r_name) = True Or IsNull(Me.r_phone) = True Or IsNull(Me.r_username) = True Or IsNull(Me.r_password) = True Or IsNull(Me.r_vpassword) = True Then
MsgBox ("Mandatory fields must be filled !"), , "| Dara Required |"
Exit Sub
Else
If Len(Me.r_phone) > 5 Then
MsgBox "The phone digits must be at least 5 numbers", , "| Phone Digits limits exceed |"
Exit Sub
Else
If Me.r_password <> Me.r_vpassword Then
MsgBox "Password do not match...", , "| Password must be matched |"
Exit Sub
Else
Set rst = CurrentDb.OpenRecordset("UserTable", dbOpenDynaset, dbSeeChanges)
With rst
.AddNew
.Fields("uname") = Me.r_name
.Fields("uphone") = Me.r_phone
.Fields("udate") = Date
.Fields("ugender") = Me.r_gender
.Fields("uage") = Me.r_age
.Fields("uusername") = Me.r_username
.Fields("upassword") = Me.r_password
.Fields("ustatus") = "User"
.Update
End With
Set rst = Nothing
DoCmd.Close acForm, "RegisterUser", acSavePrompt
End If
End If
End If
End Sub
As you know the purpose of the user’s 5-digit last phone number is to validate the user to change his password so, the “New Password” and “Verify Password” text boxes should appear only after clicking the “Check Validity” button.
Apply the Password mask to both Password text boxes.
Hide both the “New Password” and “Verify Password” text boxes by default.
Check the user input of “Authentication 5 digit” from the user table based on the criteria of the Username.
If both the Username and the 5-digit code match, both password-related text boxes will be unhide.
Here is the “Check Validity” button code:
Private Sub Command7_Click()
If IsNull(Me.f_username) = True Or IsNull(Me.f_phone) = True Then
MsgBox "Please fill both Username and Authentication code.", , "| Empty data |"
Exit Sub
Else
If DCount("*", "UserTable", "uphone = '" & Me.f_phone & "' and uusername = '" & Me.f_username & "'") = 1 Then
Me.f_password.Visible = True
Me.f_vpassword.Visible = True
Me.f_password.SetFocus
Me.f_username.Enabled = False
Me.f_phone.Enabled = False
Exit Sub
Else
MsgBox "Something wrong with the data entered.", , "| Error |"
Exit Sub
End If
End If
End Sub
Mandatory Fields: Before proceeding to edit the user input data into the table, mandatory fields must be filled (All fields are mandatory in this case).
Password Match Criteria: An error message will appear if both passwords do not match.
Update Table: Proceed to update data in the table if no error is found.
Private Sub Command8_Click()
If IsNull(Me.f_password) = True Or IsNull(Me.f_vpassword) = True Then
MsgBox "Please fill both Username and Authentication code.", , "| Empty data |"
Exit Sub
Else
If Me.f_password <> Me.f_vpassword Then
MsgBox "Password not matched"
Exit Sub
Else
'Find record ID to update the record of in the table
fid = DLookup("uid", "UserTable", "uphone = '" & Me.f_phone & "' and uusername = '" & Me.f_username & "'")
'ID has been stored in fid
Dim recf As Recordset
Set recf = CurrentDb.OpenRecordset("UserTable", dbOpenDynaset, dbSeeChanges)
With recf
.FindFirst "uid = " & fid
.Edit
.Fields("upassword") = Me.f_password
.Update
End With
Set recf = Nothing
DoCmd.Close acForm, "ForgotPassword", acSavePrompt
End If
End If
End Sub