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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a switchboard form exclusive to user based on security level

Status
Not open for further replies.

4656rp

Technical User
Feb 25, 2003
20
US
I think a figured out a way around a previous problems I had with different levels of security. Now I want to create a switchboard form(s) that will open depending on the user's security level. For example, the switchboard for the user with view only security would not see the report options whereas the 'userplus' would be able to see the reports options. I appreciate any direction you can provide.

Many thanks,
 
I had a teacher once tell me not to mess with the options in Switchboard, so I create my own startup forms for personalized menus.
 
You read my mind, I intended to also ask about modifying the switchboard form to include tabs for data entry, reports, etc..., but decided to work on that myself. Thanks for the hint, though!
I still don't understand how to create a 'customized' switchboard form per group. For example, if a member of Group A opens the db I don't want them to be able to run reports that only Group B can run. Does that make sense or am I out in left field somewhere?

Many thanks,
 
If you can find some way to identify the user or their group upon opening the database then you can restrict which form they open.

This is usually what I do. I run code to obtain their network login, then based on their job title (in a SQL table), I have the database open up different forms.

e.g.
frm_Menu_Manager
frm_Menu_Supervisor
frm_Menu_Main (anyone who isn't a supervisor or manager)

I put all my code in a function and call it in the AutoExec macro.

I'm sure there are other ways of doing this, this is just what works for me.
 
I do the same thing as Onyxpurr. I use
Code:
 environ("Username")
to get the user's logon ID, and maintain a table of user ID's with either one column "Mgr", "Lead", "Browser", or a series of yes/no boxes of the same kind of titles. In order to reduce the irritation on my end of maintaining such a table, when a user who's ID is not in the table first opens the db, their ID gets added to the table as a "Browser" or whatever the lowest level of permissions is. Other types of users ("Lead" or "Mgr") have access to a form based on the "USER" table, so they can go in there and designate other users as "LEAD" or "MGR" if they want to. This way I don't have to mess with it, and the users don't have to count on me to be here :))

Good luck--g
 
Hello, this may help you out. We modified the switchboard to incorporate a security level.There is also a user table in which we assign security. The switchboard buttons are visible or not, depending on the user's security level. It works well.



Private Sub FillOptions()
' Fill in the options for this switchboard page.

' The number of buttons on the form.
Const conNumButtons = 15

Dim con As Object
Dim rs As Object
Dim StSql As String
Dim intOption As Integer
Dim mUserDept As Integer
Dim mSecurity As Integer

' Set the focus to the first button on the form,
' and then hide all of the buttons on the form
' but the first. You can't hide the field with the focus.
' Me![Option1].SetFocus
For intOption = 1 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Next intOption

' Open the table of Switchboard Items, and find
' the first item for this Switchboard Page.
Set con = Application.CurrentProject.Connection

StSql = "SELECT * FROM [Switchboard Items] " & _
"WHERE [ItemNumber] > 0 AND [SwitchboardID]= " & Me![SwitchboardID] & _
" ORDER BY [ItemNumber]; "

Set rs = CreateObject("ADODB.Recordset")
rs.Open StSql, con, 1 ' 1 = adOpenKeyset

' If there are no options for this Switchboard Page,
' display a message. Otherwise, fill the page with the items.

mUserDept = Me.txtDeptID
mSecurity = Me.txtSecurity
If (rs.EOF) Then
Me![OptionLabel1].Caption = "There are no items for this switchboard page"
Else

Select Case mUserDept

Case 6 ' Administrater
While (Not (rs.EOF))
Select Case Nz(rs![Security])
Case Is <= mSecurity
Me("Option" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Caption = rs![ItemText]
End Select
rs.MoveNext
Wend
Case 7 ' Programer
While (Not (rs.EOF))
Me("Option" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Caption = rs![ItemText]
rs.MoveNext
Wend


Case Else
While (Not (rs.EOF))
Select Case Nz(rs![DeptID])
Case mUserDept, 15
Select Case Nz(rs![Security])
Case Is <= mSecurity
Me("Option" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Caption = rs![ItemText]


End Select
End Select
rs.MoveNext
Wend
End Select
End If

' Close the recordset and the database.
rs.Close
Set rs = Nothing
Set con = Nothing

End Sub

Another option we've used is simpler. The form looks at the user type - admin, classType, and so on, and locks or unlocks the form depending on the situation. This is useful for people who insist on seeing everything. That is fine, but they may not necessarily be able to use everything:

Private Sub Form_Load()


Select Case Forms!switchboard.txtUser 'Lock or Unlock Form for Editing

Case Is = 0

Select Case Forms!switchboard.txtClass

Case Is = 10

Me.AllowEdits = True

Case Is <> 10

Me.cmdClose.SetFocus
Me.CmdUpdateData.Enabled = False
Me.AllowEdits = False


End Select

Case Is = -1

Me.cmdDetailExpl.SetFocus
Me.CmdUpdateData.Enabled = False
Me.AllowEdits = False


End Select

End Sub

Hope that helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top