Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124

Part 2 implements a professional User Management Interface and a crucial Event Logging System.
1. Designing the Preferences Tab Control:
2. Building the User Management Interface:
UserManagement) is created as a Continuous Subform bound to tbl_user.AddUser) is made an Unbound Form for strict validation.(EditUser) is created as a Bound Form but excludes password fields.3. Implementing the Event Log System:
tbl_logs is created to record User_ID, Date_Time, Activity, and Detail.(UserID) and (Username) are declared and updated during login.
This part focuses on building a professional user interface for administration and implementing an indispensable auditing feature: the Event Logging System.
UserManagement)UserManagementSub) is created as a Continuous Subform bound to the tbl_user.AddUser)On Click event to toggle the PasswordChar property of the password text box between * (masked) and an empty string (unmasked).tbl_user if all validations pass.Me.Parent.Parent.NavigationSubForm...Requery) is used to force the nested User List subform to refresh after a new user is submitted.Private Sub cmdUserSubmit_Click()
If IsNull(Me.txtAccountName) = True Or IsNull(Me.txtProfile) = True Or IsNull(Me.txtAccountUsername) = True Or IsNull(Me.txtAccountPassword) = True Or IsNull(Me.txtAccountConfirmPassword) = True Then
MsgBox "Please fill all fields.", vbExclamation, "|Empty Data|"
Exit Sub
'First check both Passwords matched
ElseIf Me.txtAccountPassword <> Me.txtAccountConfirmPassword Then
MsgBox "Passwords do not match.", vbCritical, "Password not match"
Exit Sub
'Second check the 8 characters length
ElseIf Len(Me.txtAccountPassword) > 8 Then
MsgBox "Password character length must be 8 or less.", vbCritical, "Password length exceed"
Exit Sub
Else
'Proceeding to enter data into User table
'We will add Employee selection fields later on after Employee table from here
Set adduser = CurrentDb.OpenRecordset("tbl_user", dbOpenDynaset, dbSeeChanges)
With adduser
.AddNew
.Fields("uName") = Me.txtAccountName
'Other fields will be added later on from the Employees table
.Fields("prfID") = Me.txtProfile
.Fields("uDate") = Date
.Fields("uUsername") = Me.txtAccountUsername
.Fields("uPassword") = Me.txtAccountPassword
.Fields("uStatus") = "Active"
.Update
End With
Set adduser = Nothing
'///logs
Set ulog = CurrentDb.OpenRecordset("tbl_logs", dbOpenDynaset, dbSeeChanges)
With ulog
.AddNew
.Fields("logDate") = Date
.Fields("logTime") = Now()
.Fields("logActivity") = "Add User"
.Fields("logDetail") = uN & " New User Added"
.Fields("uID") = uI
.Update
End With
Set ulog = Nothing
'Close form after submission
DoCmd.Close acForm, "AddUser", acSaveYes
'Refresh the data of Main Dashboar form (This is complex and tricky)
'So we need to refresh the Subform while UserManagement is the main Userform
Forms!MainDashboard![NavigationSubform]!UserManagement!UserManagementSub.Form.Requery
'Working fine greate
End If
End Subtbl_logs)| Field Name | Data Type | Purpose |
|---|---|---|
logID | AutoNumber (Primary Key) | Unique ID for the log entry. |
logDate | Date/Time | The date of the event occurred. |
logTime | Date/Time | The time of the event occurred. |
logActivity | Text | The type of action (e.g., ‘LOGIN’, ‘NEW USER’). |
logDetail | Text | A descriptive summary of the action. |
uID | Number (Foreign Key) | Links to the user who performed the action. |
Public uI As Integer, Public uN As String) are declared in a standard module.A simple, reusable logging function is created. This function accepts the Activity and Detail as arguments and uses the globally available User ID uI and Username uN to automatically populate the tbl_logs with the user’s identity and action details. This function is called immediately after a successful login and inside the submit code for creating a new user.
'///logs
Set ulog = CurrentDb.OpenRecordset("tbl_logs", dbOpenDynaset, dbSeeChanges)
With ulog
.AddNew
.Fields("logDate") = Date
.Fields("logTime") = Now()
.Fields("logActivity") = "Add User"
.Fields("logDetail") = uN & " New User Added"
.Fields("uID") = uI
.Update
End With
Set ulog = Nothing