Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Form - Employee Only See Accounts Assigned 3

Status
Not open for further replies.
Mar 2, 2005
171
0
0
US
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

 

Step 2 was done to put all of the controls that are on the main form onto the subform that is on the tab titled "Review Accounts."

The main form appears when the administrator clicks on the command button titled "Assign Accounts." Therefore, I wanted all of the controls that are on the main form to also be on the tab titled "Review Accounts.

Initially, I did not have a subform on the tab titled "Review Accounts."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top