Fireman1143
IS-IT--Management
I am setting up an initial login screen which will have NO security function other than make someone relaize they shouldn't be trying to get into this particular database. All I want is to ask for the Username and then the Password and if both are supplied correctly it will open the main Switchboard. The fields in the tblEmployees are [strUn] for Username and [strEmpPw] for password.
Whne I enter a correct username and password I get a message "Runtime error 2001 You cancelled the previous operations" with this line highlighted.
If Me.txtPassword.Value = DLookup("[strEmpPw]", "tblEmployees", "[strUn]=" & Me.cboEmployee.Value) Then
-----------------------------------------------------------
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 tblEmployees to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("[strEmpPw]", "tblEmployees", "[strUn]=" & Me.cboEmployee.Value) Then
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "Switchboard"
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
Whne I enter a correct username and password I get a message "Runtime error 2001 You cancelled the previous operations" with this line highlighted.
If Me.txtPassword.Value = DLookup("[strEmpPw]", "tblEmployees", "[strUn]=" & Me.cboEmployee.Value) Then
-----------------------------------------------------------
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 tblEmployees to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("[strEmpPw]", "tblEmployees", "[strUn]=" & Me.cboEmployee.Value) Then
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "Switchboard"
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