switchboard help!

rsbutterfly16

Registered User.
Local time
Today, 11:59
Joined
Jun 5, 2006
Messages
77
hi guys i am working in customizing my current switchboard and i was wondering if there is any way to hide a button according to a user.. i currently have a tblusers with the username, switchboardid and itemnumber i want as a default, but i would also like to have a certain itemnumber to be hidden, is that possible?

this is the code i have in my switchboad and it works fine:

Private Sub Form_Open(Cancel As Integer)
txtUser_Name = GetUserName()


Dim intItem As Integer
Dim intSwitchbd As Integer

intItem = Nz(DLookup("[ItemNumber]", "tblusers", "[Userid] = '" & Me!txtUser_Name & "'"), 0)
intSwitchbd = Nz(DLookup("[SwitchboardID]", "tblusers", "[Userid] = '" & Me!txtUser_Name & "'"), 0)

Forms!Switchboard.Filter = "[ItemNumber] = " & intItem & " And [SwitchboardID] = " & intSwitchbd
Forms!Switchboard.Refresh
Me.FilterOn = True



any help will be apreciate it!!!
 
If your security can be defined hierarchially, add a new column to the [Switchboard Items] table to hold securityLevel.

You will also need to create a table that defines a user's securityLevel. The users would need to log in so you can get their securityLevel from the User table. Then join the user record to the switchboard table on securityLevel. Then switch to SQL view. Change the = in the join to <=. You will not be able to switch the query back to QBE view since the QBE view only displays equi-joins and you have just created a non-equi-join.

Set the new column in the Switchboard Items table to default to 1 which will be the lowest security level. Each succeeding level includes all items defined in lower levels.

There are more complex methods but this is the simplest which allows you to stick with the built-in switchboard and it doesn't require any code.
 
A bit long winded but...

if you use workgroup security...

create a module and copy the following into it: (saved mine as mdlUserFunctions)

(i have set the controls to be disabled by default on form load and then they are enabled as required - can also set controls to be invisible so the users dont even know they are there unless you want them to see)

Code:
Option Compare Database
Option Explicit


'Change the tcvalues to suit your workgroups
'also check code to bottom of module where you will need to alter to
'your workgroup names

'Do not UnComment line below unless basic user rights are required
'you will then will need next number in binary series

'Public Const tcUsers As Integer = 1
Public Const tcReadOnly As Integer = 1
Public Const tcFullData As Integer = 2
Public Const tcFullPermission As Integer = 4
Public Const tcAdmins As Integer = 8

Function tfIsMemberOfGroup(strworkspace As String, strUser As String, strGroup As String) As Boolean
    Dim varTemp As Variant
    Dim wrkTemp As Workspace
    
        On Error GoTo PROC_ERR
    
    If strworkspace = "" Then
        Set wrkTemp = DBEngine.Workspaces(0)
    Else
        Set wrkTemp = DBEngine.Workspaces(strworkspace)
    End If

varTemp = wrkTemp.Users(strUser).Groups(strGroup).Name
tfIsMemberOfGroup = True

PROC_EXIT:
    Exit Function

PROC_ERR:
    tfIsMemberOfGroup = False
    Resume PROC_EXIT

End Function

Function tfGroupsToArray(strworkspace As String, arrin() As String) As Integer
Dim wrkTemp As Workspace
Dim intCount As Integer
Dim intcounter As Integer

    On Error GoTo PROC_ERR
    
  If strworkspace = "" Then
        Set wrkTemp = DBEngine.Workspaces(0)
    Else
        Set wrkTemp = DBEngine.Workspaces(strworkspace)
    End If

intCount = wrkTemp.Groups.count
ReDim arrin(0 To intCount - 1)
For intcounter = 0 To intCount - 1
    arrin(intcounter) = wrkTemp.Groups(intcounter).Name
    Next intcounter
    
tfGroupsToArray = intCount

PROC_EXIT:
    Exit Function

PROC_ERR:
    tfGroupsToArray = 0
    Resume PROC_EXIT

End Function

Public Function tfUserLevel() As Integer
    Dim UserLevel As Integer
    'If CurrentUser = "Ian Ward" Then
    'UserLevel = 255
    'else
    'If tfIsMemberOfGroup("", CurrentUser, "Users") Then UserLevel = UserLevel + tcUsers
    If tfIsMemberOfGroup("", CurrentUser, "ReadOnly") Then UserLevel = UserLevel + tcReadOnly
    If tfIsMemberOfGroup("", CurrentUser, "FullData") Then UserLevel = UserLevel + tcFullData
    If tfIsMemberOfGroup("", CurrentUser, "FullPermission") Then UserLevel = UserLevel + tcFullPermission
    If tfIsMemberOfGroup("", CurrentUser, "Admins") Then UserLevel = UserLevel + tcAdmins

'End If
tfUserLevel = UserLevel

    
End Function

then in the on load event of the switchboard or any other form you can set the properties for your items

Code:
Dim ultemp As Integer
ultemp = tfUserLevel

If ultemp And tcReadOnly Then
Me.btnBreachReports.Enabled = True
Me.btnChangePassword.Enabled = True
Me.btnAmbulanceReports.Enabled = True
Me.btnOOHReports.Enabled = True
Me.btnUCNContactDatabase.Enabled = True
End If


If ultemp And tcAdmins Then

Me.btnUserSummary.Enabled = True
Me.btnUCNContactDatabase.Enabled = True

OR - for specific users:

Code:
If CurrentUser() = "User Name" Then
Me.btnBreachReports.Enabled = True
Me.btnChangePassword.Enabled = True
Me.btnAmbulanceReports.Enabled = True
Me.btnOOHReports.Enabled = True
Me.btnUCNContactDatabase.Enabled = True
End If

I think this would give you the same options / results as Pat mentioned in his previous post, this is just another option...

Regards - Ian
 
Thank you, i don't have workgroups, my security is based on my backend sql server . what columns do i need in my table for the user's security level? i already added the column with the accesslevel names in my switchboard items table and i already have a tblusers which i use for the default switchboard to open according to the users, this table has a username, switchboardid, itemnumber.

Please tell me the next steps.... thanks!!!!

:confused:
 

Users who are viewing this thread

Back
Top Bottom