Microsoft Access is widely known for its ease of use in building small to medium-scale database applications. While it's often used for data entry and reporting, you can also create interactive features like login and sign-up systems to secure your Access applications.
In this blog post, I'll walk you through how to build a basic Login and Sign-Up system in MS Access, step-by-step.
Why Add Login/Sign-Up to Your Access App?
Adding a login and sign-up system helps:
• Protect sensitive data.
• Control user access based on roles (e.g., admin, regular user).
• Track user activities.
• Create a personalized experience.
Step 1: Create the User Table
Open your MS Access database and create a new table with the following fields:
Table Name: tblUsers.
Save the table as tblUsers.
Step 2: Create the Login Form
• Create a new form in Design View.
• Add two text boxes: 1. txtUsername 2. txtPassword
• Add a button and set its name to btnLogin and caption to Login.
|
|
|
Private Sub btnLogin_Click()
Dim rs As DAO.Recordset
Dim strUsername As String
Dim strPassword As String
strUsername = Me.txtUsername.Value
strPassword = Me.txtPassword.Value
Set rs = CurrentDb.OpenRecordset("SELECT * FROM tblUsers WHERE Username='" & strUsername & "' AND Password='" & strPassword & "'")
If rs.EOF Then
MsgBox "Invalid username or password", vbCritical
Else
MsgBox "Login successful! Welcome " & rs!Username, vbInformation
' You can open another form here:
' DoCmd.OpenForm "frmDashboard"
' DoCmd.Close acForm, "frmLogin"
End If
rs.Close
Set rs = Nothing
End Sub
Step 3: Create the Sign-Up Form
1. Create a new form named frmSignUp.
2. Add three text boxes:
• txtNewUsername
• txtNewPassword
• txtConfirmPassword
3. Add a button named btnSignUp with caption Sign Up.
In the button’s On Click event, use this VBA code:
Step 3: Create the Sign-Up Form
1. Create a new form named frmSignUp.
2. Add three text boxes:
• txtNewUsername
• txtNewPassword
• txtConfirmPassword
3. Add a button named btnSignUp with caption Sign Up.
In the button’s On Click event, use this VBA code:
|
|
Private Sub btnSignUp_Click()
Dim rs As DAO.Recordset
If Me.txtNewPassword.Value <> Me.txtConfirmPassword.Value Then
MsgBox "Passwords do not match!", vbExclamation
Exit Sub
End If
' Check if username exists
Set rs = CurrentDb.OpenRecordset("SELECT * FROM tblUsers WHERE Username='" & Me.txtNewUsername.Value & "'")
If Not rs.EOF Then
MsgBox "Username already exists!", vbCritical
rs.Close
Exit Sub
End If
' Add new user
CurrentDb.Execute "INSERT INTO tblUsers (Username, [Password], CreatedDate) VALUES ('" & Me.txtNewUsername.Value & "', '" & Me.txtNewPassword.Value & "', Now())"
MsgBox "Account created successfully!", vbInformation
DoCmd.Close acForm, Me.Name
' Optionally, open login form again
' DoCmd.OpenForm "frmLogin"
End Sub
Conclusion
Building
a Login and Sign-Up System in Microsoft Access is easier than you might
think—and it's a huge step forward in protecting your data and creating
professional-quality applications.
Whether
you're creating a school management system, point of sale database,
or student report tracker, adding a login screen elevates your MS Access
project.
Want
a Free Template?
Let
me know if you'd like a downloadable version of this login and registration
system in MS Access including forms, tables, and VBA. I’ll be happy to share it
with you!
Contact Us Click here
Conclusion
Building
a Login and Sign-Up System in Microsoft Access is easier than you might
think—and it's a huge step forward in protecting your data and creating
professional-quality applications.
Whether you're creating a school management system, point of sale database, or student report tracker, adding a login screen elevates your MS Access project.
Want
a Free Template?
Let
me know if you'd like a downloadable version of this login and registration
system in MS Access including forms, tables, and VBA. I’ll be happy to share it
with you!





0 Comments