Thanks for your help so far, I appreciate it. On reflection I should have posted my own code and table definitions to help work out the solution so I've added this below to see where I may be going wrong.
Code:
tblEmployee
empID AUTONUMBER
manID NUMBER
deptID NUMBER
foreName TEXT
surname TEXT
jobTitle TEXT
startDate DATE/TIME
managerRole TES/NO
password TEXT
Currently the below code opens the frmEmployee directly into the record of the user who logins in, however it only displays their record, not all employees from that department, which is what I'm trying to achieve.
Code:
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboUsername) Or Me.cboUsername = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboUsername.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", "tblEmployee", "[empID]=" & Me.cboUsername.Value) Then
empID = Me.cboUsername.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "tblEmployee", , , "empID=" & empID
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 your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Thanks.