Hello Everyone.
I have set up a Mutli-User Logon for one of my databases, the code for it now is as follows:
Code:
Option Compare Database
Private intLogonAttempts As Integer
Private Sub buttonlogin_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 tblEmployees to see if this matches value chosen in combo box
If Me.txtPassword.Value = DLookup("Password", "users", "ID=" & Me.cboEmployee.Value) Then
MyEmpID = Me.cboEmployee.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "login", acSaveNo
DoCmd.OpenForm "user_cp"
Else
MsgBox "Password Invalid. Please Try Again", vbCritical + 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 your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Which works Great!
I have added a colum to the "user" table with a check box in it, and added a check box to the "login" form called "admincheck". If it is checked I would like it to open "admin_cp" on login rather then "user_cp".
What is the best way to do this? Code would be greatly appreciated!
Thanks!