G'day,
I have a silly and simple problem that I need some guidance with.
Due to the way our network is set up, I am unable to use the group permissions for Access and have had to implement log in procedures via a log in table within the database. This works fine. I have now expanded this table to include further data about the authorised user – Power User, Team Leader, & Facilitator.
Depending on the user’s status as to which one of these they are (or as the default status as a regular user) I want to display a form specific for that user’s status, e.g. If the user is true in the log in table as a Power user, I want a “power user” form to be displayed. Sometimes we will have team leaders who are also facilitators so I need to check both Team Leader and Facilitator status - thus I have four situations (forms) to load up. 1. If Power user = true then load Power user form; 2. if team leader = true then load Team leader form; 3. if facilitator = true then load facilitator form; and 4. if both team leader and facilitator = true then load team facilitator form.
The log in table consists of:
lngEmpID – Autonumber (PK)
txtUserID – txt
txtpword - txt
txtfirstname – txt
Team Leader – Boolean (Y/N)
Facilitator – Boolean (Y/N)
Power – Boolean (Y/N)
I have the following forms:
frmLogOn
Start Facilitator
Start Team Facilitator
Start Power
Start Team Leader
This is the code I have that works fine for the log in part of the process:
Class
Module
****I wasn’t sure if the above needed to be in a class or a module so I created the same in each – could anyone shed some light on which I should have used – class or module?
Code for LogOn
The last block from ‘Close LogOn form and open the start form is the part I want to change and have had several unsuccessful attempts. At this stage the code is only at the point of trying to get the power user (“Start Power”) form to load, the rest of the forms I will do once I get this worked out.
The amended code just doesn’t want to load the form – I’ve tried putting the Call frmLoader sub in at various places without success. I’ve also tried to Dim Power as both string and Boolean without success.
Amended Code
Can anyone tell me where I’m going wrong – I know this is simple but I’ve been at this for the last few hours and am well and truly frustrated =(
Thanks for any help - all help is greatly appreciated!
I have a silly and simple problem that I need some guidance with.
Due to the way our network is set up, I am unable to use the group permissions for Access and have had to implement log in procedures via a log in table within the database. This works fine. I have now expanded this table to include further data about the authorised user – Power User, Team Leader, & Facilitator.
Depending on the user’s status as to which one of these they are (or as the default status as a regular user) I want to display a form specific for that user’s status, e.g. If the user is true in the log in table as a Power user, I want a “power user” form to be displayed. Sometimes we will have team leaders who are also facilitators so I need to check both Team Leader and Facilitator status - thus I have four situations (forms) to load up. 1. If Power user = true then load Power user form; 2. if team leader = true then load Team leader form; 3. if facilitator = true then load facilitator form; and 4. if both team leader and facilitator = true then load team facilitator form.
The log in table consists of:
lngEmpID – Autonumber (PK)
txtUserID – txt
txtpword - txt
txtfirstname – txt
Team Leader – Boolean (Y/N)
Facilitator – Boolean (Y/N)
Power – Boolean (Y/N)
I have the following forms:
frmLogOn
Start Facilitator
Start Team Facilitator
Start Power
Start Team Leader
This is the code I have that works fine for the log in part of the process:
Class
Code:
Option Compare Database Public LoggedInUser As String Public Function GetLoggedInUser() As String GetLoggedInUser = LoggedInUser End Function Public Function SetLoggedInUser(sUserID As String) LoggedInUser = sUserID End Function
Code:
Option Compare Database Public LoggedInUser As String Public Function GetLoggedInUser() As String GetLoggedInUser = LoggedInUser End Function Public Function SetLoggedInUser(sUserID As String) LoggedInUser = sUserID End Function
Code for LogOn
Code:
Option Compare Database
Dim intLogins As Integer
Private Sub cboUserID_AfterUpdate()
'After selecting user name set focus to textbox
Forms!frmLogOn!txtPass.SetFocus
End Sub
Private Sub LogIn()
'Sets the number of attempts to log in at 3, and will kick user if exceeded
intLogins = intLogins + 1
If intLogins > 2 Then
MsgBox "You are not authorised to access this database.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Private Sub cmdLogOn_Click()
'Set the variable for the password entry = sPswd
Dim sPswd As String
'Count logins and step
Call LogIn
'User ID and Password cannot contain a null value
If IsNull(Me!cboUserID) = True Or IsNull(Me!txtPass) = True Then
MsgBox "please enter a valid userid and password"
Exit Sub
End If
'Lookup the value of variable in table LogIn
sPswd = Nz(DLookup("txtpword", "tblLogIn", "txtUserID='" & Me!cboUserID & " ' "), "")
'Check to see of passwords match
If Me!txtPass <> sPswd Then
MsgBox "Invalid UserID/Password", vbOKOnly, "Try Again"
Exit Sub
End If
Call SetLoggedInUser(Me.cboUserID)
'Close the LogOn form and open the Start form
DoCmd.Close acForm, "frmLogOn", acSaveNo
DoCmd.OpenForm ("Start Form CL&D")
End Sub
The amended code just doesn’t want to load the form – I’ve tried putting the Call frmLoader sub in at various places without success. I’ve also tried to Dim Power as both string and Boolean without success.
Amended Code
Code:
Option Compare Database
Dim intLogins As Integer
[B]Dim Power As Boolean[/B]
Private Sub cboUserID_AfterUpdate()
'After selecting user name set focus to textbox
Forms!frmLogOn!txtPass.SetFocus
End Sub
Private Sub LogIn()
'Sets the number of attempts to log in at 3, and will kick user if exceeded
intLogins = intLogins + 1
If intLogins > 2 Then
MsgBox "You are not authorised to access this database.", vbCritical, "Restricted Access!"
'Application.Quit
End If
End Sub
[B]Private Sub FrmLoader()
Power = DLookup("Power", "tblLogIn", "txtUserID=' " & Me!cboUserID & " ' ")
If Power = True Then DoCmd.Close acForm, "FrmLogOn", acSaveNo
DoCmd.OpenForm ("Start Power")
End If
End Sub[/B]
Private Sub cmdLogOn_Click()
'Set the variable for the password entry = sPswd
Dim sPswd As String
'Count logins and step
Call LogIn
'User ID and Password cannot contain a null value
If IsNull(Me!cboUserID) = True Or IsNull(Me!txtPass) = True Then
MsgBox "please enter a valid userid and password"
Exit Sub
End If
'Lookup the value of variable in table LogIn
sPswd = Nz(DLookup("txtpword", "tblLogIn", "txtUserID='" & Me!cboUserID & " ' "), "")
'Check to see of passwords match
If Me!txtPass <> sPswd Then
MsgBox "Invalid UserID/Password", vbOKOnly, "Try Again"
Exit Sub
End If
[B]Call FrmLoader[/B]
Call SetLoggedInUser(Me.cboUserID)
End Sub
Can anyone tell me where I’m going wrong – I know this is simple but I’ve been at this for the last few hours and am well and truly frustrated =(
Thanks for any help - all help is greatly appreciated!
Comment