All, working on an access 2003 database. I have this logon form called “frmLogon”. I am trying not to use a main switchboard and have users go to the correct form based on their dept name after the login form. This is the code:
Code:
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 tblEmployee to see if this matches value chosen in combo box
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployee", "[lngEmpID]=" & Me.cboEmployee.Value) Then
lngMyEmpID = Me.cboEmployee.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogon", acSaveNo
'DoCmd.OpenForm "frmHelpAbout"
Call Permission
'Call InitSplash
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 the admin.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Code:
Public Function Permissions() As String
Dim strDept As String
strDept = DLookup("Dept", "tblUsers", "strEmpName=" & Forms!frmLogon!cboEmployee)
Select Case strDept
Case " Dept 1"
DoCmd.OpenForm "frmMenu-Dept1"
Case " Dept2"
DoCmd.OpenForm "frmMenu- Dept2"
Case " Dept3"
DoCmd.OpenForm "frmMenu- Dept3"
Case " Dept4"
DoCmd.OpenForm "frmMenu- Dept4"
Case " Dept5"
DoCmd.OpenForm "frmMenu- Dept5"
Case Else
MsgBox "Unable to determine Department please try again"
End Select
End Function
I’m getting an error: “Can’t find the reference form frmLogon”. I thought I was referencing the form correct but don’t know why it doesn’t like my code. I looked of the dlookup code and my code seems like it correct. Can anyone help point out what’s wrong please. Thanks