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)
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()
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.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Back to IT Employment Forum
2 total posts (Page 1 of 1)  

General Discussion Forums