Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
This masterclass is designed to make you proficient in both accounting terminologies and MS Access programming (including tables, queries, forms, reports, and essential VBA coding and modules).
The completed system features a comprehensive suite of tools to run a modern business:
Deep Dive: The Multi-User Security Framework The framework focuses on robust security:
tbl_user) with Username, Password, and Status, and the Profile Table (tbl_profile) containing fields for every navigation button (e.g., Sales, Accounts).tbl_userand tbl_profile. VBA code retrieves the user’s Profile_ID upon successful login, which is then used to dynamically enable or disable the corresponding navigation buttons on the dashboard.This first part of the masterclass focuses on building the foundational structure of our accounting solution: a robust, multi-user login system and a dynamic main dashboard using Microsoft Access VBA programming.
The goal of this comprehensive project is to build a complete business solution—from ledger entries and stock management to payroll—while simultaneously mastering advanced MS Access features like VBA coding, Tables, Queries, Forms, and Reports. This initial setup is critical as it implements the comprehensive multi-user login and profiling system, which controls who can access what features across the entire database.
MainDashboard)The main dashboard is the navigation hub of the entire application and must be designed for both usability and dynamic control.
MainDashbaord).
The access rights are managed through a relationship between two crucial tables.
tbl_user)| Field Name | Data Type | Purpose |
|---|---|---|
uID | AutoNumber (Primary Key) | Unique identifier for each user. |
prfID | Number | Crucial: Links the user to a specific profile in the tbl_profile. |
uName | Text | Username |
uPhone | Text | Phone Number (Optional) |
uDate | Date/Time | Date of user creation (Optional) |
uGender | Text | Gender of the user (Optional) |
uAge | Number | Age of the user (Optional) |
uUsername | Text | The login identifier. |
uPassword | Text | The login credential. |
uStatus | Text | To enable or disable an account (e.g., Active/Disabled). |
tbl_profile)A dedicated field for each dashboard button (e.g., Sales, Accounts). -1 is set for Enabled (True), and 0 for Disabled (False).
| Field Name | Data Type | Purpose |
|---|---|---|
prfID | AutoNumber (Primary Key) | Unique identifier for each profile. |
prfName | Text | The profile name (e.g., ‘Admin’, ‘Sales Team’). |
prfDashboard | Number | A dedicated field to enable of disable the Dashboard Navigation |
prfAnalysis | Number | A dedicated field to enable of disable the Analysis Navigation |
prfSales | Number | A dedicated field to enable of disable the Sales Navigation |
prfPurchase | Number | A dedicated field to enable of disable the Purchase Navigation |
prfProducts | Number | A dedicated field to enable of disable the Products Navigation |
prfStock | Number | A dedicated field to enable of disable the Stock Navigation |
prfEmployees | Number | A dedicated field to enable of disable the Employees Navigation |
prfAccounts | Number | A dedicated field to enable of disable the Accounts Navigation |
prfPreferences | Number | A dedicated field to enable of disable the Preferences Navigation |
LoginForm)
AddUser)tbl_profile names. This allows the admin to select an appropriate access level when creating the account, which populates the Profile_ID field in the tbl_user.
This is the most critical part, controlling the security and dynamic user interface.
The code behind the Login button executes three primary tasks:
tbl_userto find a record where the Username, Password, AND the Status are correct/active.Profile_ID and stores it.Private Sub cmdLogin_Click()
'First check the null textboxes and return a msg
If IsNull(Me.txtUsername) = True Or IsNull(Me.txtPassword) = True Then
MsgBox "Please enter Username and Password...", vbExclamation, "|Username or Password Blank|"
Exit Sub
Else
'Find the record in user table based on both username and password
ufound = DCount("uUsername", "tbl_user", "uUsername = '" & Me.txtUsername _
& "' and uPassword = '" & Me.txtPassword & "' and uStatus = 'Active'")
'Record not found
If ufound = 0 Then
Me.LblNotFound.Visible = True
Exit Sub
'Record found
Else
'user ID (It must be defined as Public Variable)
uI = DLookup("uID", "tbl_user", "uUsername= '" & Me.txtUsername & "'")
uN = Me.txtUsername
'///logs
Set ulog = CurrentDb.OpenRecordset("tbl_logs", dbOpenDynaset, dbSeeChanges)
With ulog
.AddNew
.Fields("logDate") = Date
.Fields("logTime") = Now()
.Fields("logActivity") = "Logged in"
.Fields("logDetail") = Me.txtUsername & " logged in"
.Fields("uID") = uI
.Update
End With
Set ulog = Nothing
'Active prodile ID (Which declared as public variable)
aprofile = DLookup("prfID", "tbl_user", "uUsername = '" & Me.txtUsername & "'")
'Open Main Dashboard form
DoCmd.OpenForm "MainDashboard"
'Update the Username textbox in the Main form
Forms!MainDashboard.txtActiveUser.Value = Me.txtUsername
'Update the profile ID in the main form
Forms!MainDashboard.txtActiveProfile.Value = aprofile
'Close the login form
DoCmd.Close acForm, "LoginForm"
End If
End If
End Subaprofile) is declared in a standard module, making the logged-in user’s profile ID globally accessible.On Load Event: The code within the MainDashboard‘s On Load event uses the aprofile ID to look up the corresponding record in the tbl_profile. It then iterates through each navigation field: if the field value is -1 (True), the corresponding navigation button on the form is set to Enabled; if 0 (False), it is Disabled.