I am hoping someone can help me. I am attempting to set up security and access levels within a database. I have successfully created frmLogin (which has the following vba). The intent is to have a Navigation form with limited access depending on their UserSecurity. (Some of the tabs will be disabled) so far, successful. Then based on their UserAccessLevel, I would like for them to just see their employees. This is where I am stuck. My Navigation form is automatically populated with the Security and AccessLevel in unbound fields based on initial information in the login.
Code:
Private Sub cmdOK_Click()
Dim UserName As String
Dim TempLogInID As String
Dim UserAccessLevel As Integer
Dim UserSecurity As Integer
If IsNull(Me.txtUserLogin) Then
MsgBox "Please Enter User ID", vbInformation, "User ID Required"
Me.txtUserLogin.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please Enter Password", vbInformation, "Password Required"
Me.txtPassword.SetFocus
Else
'process the job
If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin ='" & Me.txtUserLogin.Value & "'"))) Or (IsNull(DLookup("Password", "tblUser", "Password ='" & Me.txtPassword.Value & "'"))) Then
MsgBox "Incorrect Login ID or Password"
Else
TempLogInID = Me.txtUserLogin.Value
UserName = DLookup("UserName", "tblUser", "UserLogin = '" & Me.txtUserLogin.Value & "'")
UserSecurity = DLookup("UserSecurity", "tblUser", "UserLogin = '" & Me.txtUserLogin.Value & "'")
UserAccessLevel = DLookup("UserAccessLevel", "tblUser", "UserLogin = '" & Me.txtUserLogin.Value & "'")
DoCmd.Close
DoCmd.OpenForm "frmNavigation"
'Open different form according to user security level
If UserSecurity = 1 Then 'Level 1 is Director
Forms![frmNavigation]![txtUserName] = UserName
Forms![frmNavigation]![txtUserAccessLevel] = UserAccessLevel
Forms![frmNavigation]![txtUserSecurity] = UserSecurity
Forms![frmNavigation]![txtUserLogin] = TempLogInID
Call Security(SecurityLevel, AccessLevelID)
End If
End If
End If
End Sub
Sub Security(SecurityID As Integer, AccessLevel As Integer)
Select Case UserAccessLevel
Case1 'Director_No Restrictions
Case2 'Manager1_CCST_IR_VAT_MRI_CPRehab
Case3 'Manager2_CDL
Case4 'Manager3_CVL
Case5 'Manager4
Case6 'Educator1_CCST_IR_VAT_MRI
Case7 'Educator2
Case8 'Educator3
End Select
End Sub
I am having a very hard time getting past Call Security(SecurityLevel, AccessLevelID) as I am getting a ByRef argument type mismatch. I am fairly inexperienced in writing vba and am self taught. Can anyone help me? Very frustrated!!!