PC Review


Reply
Thread Tools Rate Thread

Determine if user is a member of a group in Access security

 
 
LDMueller
Guest
Posts: n/a
 
      5th Feb 2008
I need to be able to determine if a user is a member of the "Update Data
Users" Access security group and if they are then I'll allow them to see more
command buttons on my form.

The code would be something like the following:

If current user is in "Update Data Users" group then
Me.cmdEditRecord.Visible = True
else
Me.cmdEditRecord.Visible = False
end if

Any help would be greatly appreciated.

Thanks,

LDMueller


 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      5th Feb 2008
Function IsUserInGroup(strUser As String, strGroup As String) As Boolean
Dim varDummy As Variant
On Error Resume Next
varDummy = DBEngine(0).Users(strUser).Groups(strGroup).Name
IsUserInGroup = (Err.Number = 0)
End Function

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"LDMueller" <(E-Mail Removed)> wrote in message
news:8B58F3A9-E963-4E9F-9DA0-(E-Mail Removed)...
>I need to be able to determine if a user is a member of the "Update Data
> Users" Access security group and if they are then I'll allow them to see
> more
> command buttons on my form.
>
> The code would be something like the following:
>
> If current user is in "Update Data Users" group then
> Me.cmdEditRecord.Visible = True
> else
> Me.cmdEditRecord.Visible = False
> end if
>
> Any help would be greatly appreciated.


 
Reply With Quote
 
 
 
 
LDMueller
Guest
Posts: n/a
 
      5th Feb 2008
Hi Allen,

First of all, thank you so much for your quick response and for your
assistance.

I'm pretty limited in what I know this this stuff so other than copying the
function you provided into my code, I still don't know what to do.

Sorry... Could you possibly direct me further?

Thanks,

LDMueller

"Allen Browne" wrote:

> Function IsUserInGroup(strUser As String, strGroup As String) As Boolean
> Dim varDummy As Variant
> On Error Resume Next
> varDummy = DBEngine(0).Users(strUser).Groups(strGroup).Name
> IsUserInGroup = (Err.Number = 0)
> End Function
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "LDMueller" <(E-Mail Removed)> wrote in message
> news:8B58F3A9-E963-4E9F-9DA0-(E-Mail Removed)...
> >I need to be able to determine if a user is a member of the "Update Data
> > Users" Access security group and if they are then I'll allow them to see
> > more
> > command buttons on my form.
> >
> > The code would be something like the following:
> >
> > If current user is in "Update Data Users" group then
> > Me.cmdEditRecord.Visible = True
> > else
> > Me.cmdEditRecord.Visible = False
> > end if
> >
> > Any help would be greatly appreciated.

>
>

 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      5th Feb 2008
1. Click the Modules tab of the Database window.

2. Click New.
Access opens a new module.

3. Paste the code in.

4. Check Access understands it: choose Debug on Compile menu.

5. Save the module with a name such as Module1.

6. Change the first line of your code like this:
If IsUserInGroup(CurrentUser(), "Update Data Users") Then

Since you are talking about users and groups, I assume you do have Access
security (mdw) set up.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"LDMueller" <(E-Mail Removed)> wrote in message
news:3C87531F-D99D-4B1F-8DCE-(E-Mail Removed)...
> Hi Allen,
>
> First of all, thank you so much for your quick response and for your
> assistance.
>
> I'm pretty limited in what I know this this stuff so other than copying
> the
> function you provided into my code, I still don't know what to do.
>
> Sorry... Could you possibly direct me further?
>
> Thanks,
>
> LDMueller
>
> "Allen Browne" wrote:
>
>> Function IsUserInGroup(strUser As String, strGroup As String) As Boolean
>> Dim varDummy As Variant
>> On Error Resume Next
>> varDummy = DBEngine(0).Users(strUser).Groups(strGroup).Name
>> IsUserInGroup = (Err.Number = 0)
>> End Function
>>
>> "LDMueller" <(E-Mail Removed)> wrote in message
>> news:8B58F3A9-E963-4E9F-9DA0-(E-Mail Removed)...
>> >I need to be able to determine if a user is a member of the "Update Data
>> > Users" Access security group and if they are then I'll allow them to
>> > see
>> > more
>> > command buttons on my form.
>> >
>> > The code would be something like the following:
>> >
>> > If current user is in "Update Data Users" group then
>> > Me.cmdEditRecord.Visible = True
>> > else
>> > Me.cmdEditRecord.Visible = False
>> > end if
>> >
>> > Any help would be greatly appreciated.


 
Reply With Quote
 
LDMueller
Guest
Posts: n/a
 
      6th Feb 2008
Allen,

Thank you so much! This was exactly what I needed.

Take care!

LDMueller

"Allen Browne" wrote:

> 1. Click the Modules tab of the Database window.
>
> 2. Click New.
> Access opens a new module.
>
> 3. Paste the code in.
>
> 4. Check Access understands it: choose Debug on Compile menu.
>
> 5. Save the module with a name such as Module1.
>
> 6. Change the first line of your code like this:
> If IsUserInGroup(CurrentUser(), "Update Data Users") Then
>
> Since you are talking about users and groups, I assume you do have Access
> security (mdw) set up.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "LDMueller" <(E-Mail Removed)> wrote in message
> news:3C87531F-D99D-4B1F-8DCE-(E-Mail Removed)...
> > Hi Allen,
> >
> > First of all, thank you so much for your quick response and for your
> > assistance.
> >
> > I'm pretty limited in what I know this this stuff so other than copying
> > the
> > function you provided into my code, I still don't know what to do.
> >
> > Sorry... Could you possibly direct me further?
> >
> > Thanks,
> >
> > LDMueller
> >
> > "Allen Browne" wrote:
> >
> >> Function IsUserInGroup(strUser As String, strGroup As String) As Boolean
> >> Dim varDummy As Variant
> >> On Error Resume Next
> >> varDummy = DBEngine(0).Users(strUser).Groups(strGroup).Name
> >> IsUserInGroup = (Err.Number = 0)
> >> End Function
> >>
> >> "LDMueller" <(E-Mail Removed)> wrote in message
> >> news:8B58F3A9-E963-4E9F-9DA0-(E-Mail Removed)...
> >> >I need to be able to determine if a user is a member of the "Update Data
> >> > Users" Access security group and if they are then I'll allow them to
> >> > see
> >> > more
> >> > command buttons on my form.
> >> >
> >> > The code would be something like the following:
> >> >
> >> > If current user is in "Update Data Users" group then
> >> > Me.cmdEditRecord.Visible = True
> >> > else
> >> > Me.cmdEditRecord.Visible = False
> >> > end if
> >> >
> >> > Any help would be greatly appreciated.

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access of shared member, constant member, enum member or nested type through an instance Jeffrey Grantz Microsoft VB .NET 3 7th Sep 2006 04:09 PM
Using Net Group or GPO to add member to Power User Group OJ Microsoft Windows 2000 Active Directory 2 24th Sep 2004 05:39 PM
pointer to member conversion to a pointer to member that is a member's base class Vladimir_petter Microsoft VC .NET 12 19th Aug 2004 06:20 PM
How to use DirectoryServices to determine if a user if a member of a group Brad Mann Microsoft Dot NET Framework 4 7th Feb 2004 12:18 PM
struct member initialization - member by member?! emma middlebrook Microsoft C# .NET 10 28th Jul 2003 08:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:19 AM.