MS Access Login FormsLocked
I have a form which captures UserId and username from combo box and a ubound text box for password. Also i have a table which stores this details.
I have a module called globals where i declare my public variables. I initialise my public variables in the login form on open procedure
Private Sub Form_Open(Cancel As Integer)
My global module is listed below
Public Function Init_Globals()
WuserID = 0
Wuser = “”
Public Function Get_Global(gbl_parm)
Select Case gbl_parm
Get_Global = WuserID
In the login form i have login button which after successful login i store the username in the public variable wuser. Below is the code for capturing use name to wuser variable.
Private Sub cboEmployee_AfterUpdate()
WuserID = Me.cboEmployee
Wuser = Me.cboEmployee.Column(1)
Now i would like to use this public variable to control all other functions of the database.
Since I have a swithboard for example if i want to view/edit records for certain engineer, the form will just filter only records which belongs to that engineer.
I was able to achieve this when i was using currentuser() together with workground security table with the help of this code.
Public Sub Form_Current()
Dim User As String
Wuser = CurrentUser()
Wuser = UCase(Wuser)
If Wuser = “RN” Then
DoCmd.OpenForm “JobSystemcreation”, , , “projectcoordinator=’RN'”
ElseIf Wuser = “SM” Then
DoCmd.OpenForm “JobSystemcreation”, , , “projectcoordinator=’SM'”
ElseIf Wuser = “FI” Then
ElseIf Wuser = “SK” Then
Please also note i have tried to substitute the open form command with the below code on a startup form which i later close .
DoCmd.OpenForm “JobsystemCreation”, , , “[Projectcoordinator]= ‘” & Wuser & ” ‘”
Am sorry since i have made my question very long. It is because it has given me alot of headache.