LevelThought
MIS
Hopefully, someone can help with this problem.
I have a multi-tabbed form that is used by Employees and Manager. The Manager assigns accounts for the 6 employees to review. Each employee should only be able to see the accounts that are assigned to him/her.
Currently, upon entering one's name into the login area, the caption of the 1st tab displays the employee name correctly. However, the desired tab doesn't show! The error received is "unexpected error - Object required."
Any idea as to what is the problem and a resolution?
Thank you.
Displayed below is the code on the login button:
Option Compare Database
Private Sub cmdLogin_Click()
'************************ login sequence
On Error GoTo local_err
DoCmd.RunCommand acCmdSaveRecord
'
GBL_Access_Level = "X"
GBL_Access_Level = Nz(DLookup("Access_Level", "L_Employees", "Username='" & Nz(Me.UserName, " ") & "' and password='" & Nz(Me.Password, " ") & "'"), "X")
'
If GBL_Access_Level = "X" Then
MsgBox "Invalid Username or Password... try again."
Exit Sub
End If
'
GBL_Employee_ID = Nz(DLookup("Employee_ID", "L_Employees", "Username='" & Nz(Me.UserName, " ") & "' and password='" & Nz(Me.Password, " ") & "'"), "X")
'
Me.TabCtl0.Pages.Item(0).Caption = "Welcome " & Nz(DLookup("Username", "L_Employees", "Employee_ID=" & get_global("Employee_ID")), "Invalid Login")
' setup privs based on employee or manager
frmTabbed.Requery
'
' call subroutine to set access to forms
'
Call set_privs
'
' reset login screen fields
'
frmTabbed.Requery
Me.UserName = ""
Me.Password = ""
Me.TabCtl0.Pages.Item(1).SetFocus
Exit Sub
'
local_err:
MsgBox "unexpected error= " & Err.Description
Resume ok_exit
ok_exit:
Exit Sub
End Sub
Public Sub set_privs()
frmTabbed.Form.AllowAdditions = False
frmTabbed.Form.AllowDeletions = False
frmTabbed.Form.AllowEdits = False
frmTabbed.Form.AllowFilters = False
'
Select Case GBL_Access_Level
Case "M" ' manager
Me.TabCtl0.Pages.Item(1).Visible = True
Me.TabCtl0.Pages.Item(2).Visible = True
Me.TabCtl0.Pages.Item(3).Visible = True
Me.TabCtl0.Pages.Item(4).Visible = True
Me.TabCtl0.Pages.Item(5).Visible = True
frmTabbed.Form.AllowEdits = True
frmTabbed.Form.AllowAdditions = True
frmTabbed.Form.AllowDeletions = True
frmTabbed.Requery
Case "E" ' employee
Me.TabCtl0.Pages.Item(2).Visible = True
frmTabbed.Requery
End Select
Private Sub Form_Open(Cancel As Integer)
Call set_globals
'Hide tabs
Me.TabCtl0.Pages.Item(0).Caption = "Welcome"
Me.TabCtl0.Pages.Item(1).Visible = False
Me.TabCtl0.Pages.Item(2).Visible = False
Me.TabCtl0.Pages.Item(3).Visible = False
Me.TabCtl0.Pages.Item(4).Visible = False
Me.TabCtl0.Pages.Item(5).Visible = True
End Sub
I have a multi-tabbed form that is used by Employees and Manager. The Manager assigns accounts for the 6 employees to review. Each employee should only be able to see the accounts that are assigned to him/her.
Currently, upon entering one's name into the login area, the caption of the 1st tab displays the employee name correctly. However, the desired tab doesn't show! The error received is "unexpected error - Object required."
Any idea as to what is the problem and a resolution?
Thank you.
Displayed below is the code on the login button:
Option Compare Database
Private Sub cmdLogin_Click()
'************************ login sequence
On Error GoTo local_err
DoCmd.RunCommand acCmdSaveRecord
'
GBL_Access_Level = "X"
GBL_Access_Level = Nz(DLookup("Access_Level", "L_Employees", "Username='" & Nz(Me.UserName, " ") & "' and password='" & Nz(Me.Password, " ") & "'"), "X")
'
If GBL_Access_Level = "X" Then
MsgBox "Invalid Username or Password... try again."
Exit Sub
End If
'
GBL_Employee_ID = Nz(DLookup("Employee_ID", "L_Employees", "Username='" & Nz(Me.UserName, " ") & "' and password='" & Nz(Me.Password, " ") & "'"), "X")
'
Me.TabCtl0.Pages.Item(0).Caption = "Welcome " & Nz(DLookup("Username", "L_Employees", "Employee_ID=" & get_global("Employee_ID")), "Invalid Login")
' setup privs based on employee or manager
frmTabbed.Requery
'
' call subroutine to set access to forms
'
Call set_privs
'
' reset login screen fields
'
frmTabbed.Requery
Me.UserName = ""
Me.Password = ""
Me.TabCtl0.Pages.Item(1).SetFocus
Exit Sub
'
local_err:
MsgBox "unexpected error= " & Err.Description
Resume ok_exit
ok_exit:
Exit Sub
End Sub
Public Sub set_privs()
frmTabbed.Form.AllowAdditions = False
frmTabbed.Form.AllowDeletions = False
frmTabbed.Form.AllowEdits = False
frmTabbed.Form.AllowFilters = False
'
Select Case GBL_Access_Level
Case "M" ' manager
Me.TabCtl0.Pages.Item(1).Visible = True
Me.TabCtl0.Pages.Item(2).Visible = True
Me.TabCtl0.Pages.Item(3).Visible = True
Me.TabCtl0.Pages.Item(4).Visible = True
Me.TabCtl0.Pages.Item(5).Visible = True
frmTabbed.Form.AllowEdits = True
frmTabbed.Form.AllowAdditions = True
frmTabbed.Form.AllowDeletions = True
frmTabbed.Requery
Case "E" ' employee
Me.TabCtl0.Pages.Item(2).Visible = True
frmTabbed.Requery
End Select
Private Sub Form_Open(Cancel As Integer)
Call set_globals
'Hide tabs
Me.TabCtl0.Pages.Item(0).Caption = "Welcome"
Me.TabCtl0.Pages.Item(1).Visible = False
Me.TabCtl0.Pages.Item(2).Visible = False
Me.TabCtl0.Pages.Item(3).Visible = False
Me.TabCtl0.Pages.Item(4).Visible = False
Me.TabCtl0.Pages.Item(5).Visible = True
End Sub