F
fapa via AccessMonster.com
I've got a really simple question but i cant find the answer anywhere!
Ive just created a login form which checks the user's id and password to a
Login table. it works well however im not sure how to allow different users
to be directed to different pages. Eg. Admin is to be directed to Mangement
Switchboard when they type in their password and all the rest of the users
are to be directed to Staff Switchboard when they login.
here is the code i've writen so far (it directs everyone to the staff main
menu)
Private Sub cboEmployee_AfterUpdate()
'After selecting user name set focus to password field
Me.txtPassword.SetFocus
End Sub
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in Login Table to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("Password", "Login", "[UserID]=" & Me.
cboEmployee.Value) Then
UserID = Me.cboEmployee.Value
'Close login form and open Main Menu
DoCmd.Close acForm, "Login", acSaveNo
DoCmd.OpenForm "Staff Main Menu"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Also - i was hoping, and im not sure if this is possible - when management
enter another form which can be accessed by everyone, is there a way that
Management have 'management command buttons that directs them around the
system - without having these button's available to staff when a staff member
is logged in (p.s only one user can access the system at one time) p.s i hope
this question makes sense!
Ive just created a login form which checks the user's id and password to a
Login table. it works well however im not sure how to allow different users
to be directed to different pages. Eg. Admin is to be directed to Mangement
Switchboard when they type in their password and all the rest of the users
are to be directed to Staff Switchboard when they login.
here is the code i've writen so far (it directs everyone to the staff main
menu)
Private Sub cboEmployee_AfterUpdate()
'After selecting user name set focus to password field
Me.txtPassword.SetFocus
End Sub
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in Login Table to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("Password", "Login", "[UserID]=" & Me.
cboEmployee.Value) Then
UserID = Me.cboEmployee.Value
'Close login form and open Main Menu
DoCmd.Close acForm, "Login", acSaveNo
DoCmd.OpenForm "Staff Main Menu"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Also - i was hoping, and im not sure if this is possible - when management
enter another form which can be accessed by everyone, is there a way that
Management have 'management command buttons that directs them around the
system - without having these button's available to staff when a staff member
is logged in (p.s only one user can access the system at one time) p.s i hope
this question makes sense!