IT Employment

Our forums are currently in maintenance mode and the ability to post is disabled. We will be back up and running as soon as possible. Thanks for your patience!

Question

Locked

MS Access Login Forms

By njoroge ·
Dear friends,
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

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Related Discussions

Related Forums