Question
Thread display: Collapse - |
All Answers
Start or search
Create a new discussion
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
MS Access Login Forms
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.
lngEmpID Autonumber
strEmpName text
strEmpPassword text
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)
Me.cboEmployee.SetFocus
Init_Globals
End Sub
My global module is listed below
Public Function Init_Globals()
WuserID = 0
Wuser = ""
End Function
Public Function Get_Global(gbl_parm)
Select Case gbl_parm
Case "WuserID"
Get_Global = WuserID
End Select
End Function
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()
Me.txtPassword.SetFocus
WuserID = Me.cboEmployee
Wuser = Me.cboEmployee.Column(1)
End Sub
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
DoCmd.OpenForm "JobSystemcreation"
ElseIf Wuser = "SK" Then
DoCmd.OpenForm "JobSystemcreation"
End If
End Sub
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.
With Regards,
J. Njoroge