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.