Hi
I am really struggling here. I am having trouble with a line of this code and have search dozens of post and variations on this for an answer but can't seem to find a response which solves it.
I used this guide to make the table and password form http://www.databasedev.co.uk/login.html
Then used the forum to search and modify it so that when you login in, a specific form will load depending on which user you are - a choice of two forms.
I have a table named tbleEmployees with fields IngEmpID strEmpName strEmpPassword strEmpForm
When I run the below code, i get an error 2471 with this part of the code highlighting this field [lngEmpID]
this field is highlighted:-
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _
"[lngEmpID]=" & Me.cboEmployee.Value) Then
This is the full code in the login button. I have incorporated a lookup for which form to load:-
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("strEmpPassword", "tblEmployees", _
"[lngEmpID]=" & Me.cboEmployee.Value) Then
lngMyEmpID = Me.cboEmployee.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogon", acSaveNo
MyForm = DLookup("strEmpForm", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value)
DoCmd.OpenForm MyForm
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
Can anyone advise what is wrong?
thanks, any help is much appreciated.
I am really struggling here. I am having trouble with a line of this code and have search dozens of post and variations on this for an answer but can't seem to find a response which solves it.
I used this guide to make the table and password form http://www.databasedev.co.uk/login.html
Then used the forum to search and modify it so that when you login in, a specific form will load depending on which user you are - a choice of two forms.
I have a table named tbleEmployees with fields IngEmpID strEmpName strEmpPassword strEmpForm
When I run the below code, i get an error 2471 with this part of the code highlighting this field [lngEmpID]
this field is highlighted:-
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _
"[lngEmpID]=" & Me.cboEmployee.Value) Then
This is the full code in the login button. I have incorporated a lookup for which form to load:-
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("strEmpPassword", "tblEmployees", _
"[lngEmpID]=" & Me.cboEmployee.Value) Then
lngMyEmpID = Me.cboEmployee.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogon", acSaveNo
MyForm = DLookup("strEmpForm", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value)
DoCmd.OpenForm MyForm
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
Can anyone advise what is wrong?
thanks, any help is much appreciated.