Prev: francais
Next: Serial Port in VBA
From: Andrew on 5 May 2010 14:51 In VBA how do I determine the CurrentUser's Group they are assigned to in the Access WorkGroup file?
From: Dirk Goldgar on 5 May 2010 15:08 "Andrew" <Andrew(a)discussions.microsoft.com> wrote in message news:DAF2F577-3790-4A2C-A664-815A51CE939A(a)microsoft.com... > In VBA how do I determine the CurrentUser's Group they are assigned to in > the > Access WorkGroup file? A user may be in more than one group. You can, potentially, construct a list of all the groups to which the current user belongs, or you can find out whether a user belongs to a particular group in which you are interested. When I have been concerned with this, my need was to know whether the user was in the Admins group. Here's a function you can call to find out if the current user is in a given group: '------ start of code ------ Function fncUserIsInGroup(GroupName As String) As Boolean ' Returns True if the current user is a member of the specified ' security group; False if not, or if the group doesn't exist, or ' if an error occurs reading the groups. Dim ws As Workspace Set ws = DBEngine.Workspaces(0) On Error Resume Next fncUserIsInGroup = _ (ws.Users(CurrentUser).Groups(GroupName).Name = GroupName) Set ws = Nothing End Function '------ end of code ------ -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup)
From: Andrew on 6 May 2010 09:14 Thank-you Dirk. This responce was extremely helpful. I needed to know the CurrentUser's group with the highest level of user rights. What they can do in certain fields is governed by enabling or disabling controls on a form. "Admins" can do more things on some forms than "Officers" can. We have been using generic IDs and passwords for each group, but management wants to go to indivisdual IDs and passwords. "Dirk Goldgar" wrote: > "Andrew" <Andrew(a)discussions.microsoft.com> wrote in message > news:DAF2F577-3790-4A2C-A664-815A51CE939A(a)microsoft.com... > > In VBA how do I determine the CurrentUser's Group they are assigned to in > > the > > Access WorkGroup file? > > > A user may be in more than one group. You can, potentially, construct a > list of all the groups to which the current user belongs, or you can find > out whether a user belongs to a particular group in which you are > interested. When I have been concerned with this, my need was to know > whether the user was in the Admins group. > > Here's a function you can call to find out if the current user is in a given > group: > > '------ start of code ------ > Function fncUserIsInGroup(GroupName As String) As Boolean > > ' Returns True if the current user is a member of the specified > ' security group; False if not, or if the group doesn't exist, or > ' if an error occurs reading the groups. > > Dim ws As Workspace > > Set ws = DBEngine.Workspaces(0) > > On Error Resume Next > fncUserIsInGroup = _ > (ws.Users(CurrentUser).Groups(GroupName).Name = GroupName) > > Set ws = Nothing > > End Function > '------ end of code ------ > > -- > Dirk Goldgar, MS Access MVP > Access tips: www.datagnostics.com/tips.html > > (please reply to the newsgroup) >
|
Pages: 1 Prev: francais Next: Serial Port in VBA |