I have 2 issues with my login form
Issue 1. In the onClick event of the login button this is the code which is executed:
Private Sub btnLogin_Click()
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
MsgBox (Me.txtPassword.Value)
MsgBox (Me.cboEmployee.Value)
If Me.txtPassword.Value = DLookup("strEmpPassword", "Login", "[lngEmpID]=" & Me.cboEmployee.Value) Then
lngMyEmpID = Me.cboEmployee.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "F_Login", acSaveNo
DoCmd.OpenForm "F_Products"
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
The problem is when I click login, I get the error: "The expression you entered as a query parameter produced this error"
Any idea why??
Issue 2: I want the other forms and tables to be hidden until the user logs in. Right now, all the tables and forms are visible even before the user can log in.