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

  • Thread starter Thread starter LDMueller
  • Start date Start date
L

LDMueller

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
 
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
 
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
 
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.
 
Back
Top