I'm wanting to check group membership for a user and choose to display or not display various buttons on a form. I have found some code that works fine as long as you are an Admin; however, if you're not an Admin and open the program in Access 2000 or 2003, it will open fine the first time but then give an error the 2nd time and subsequent times.
Basically, does anyone know of any code that can be used to check if a user is a member of a particular group -- regardless of whether the user is an Admin or standard User?
(The code below is what I use and it works consistently but only if the logged in user is an Admin...
Dim ws As Workspace
Dim grp As Group
Dim strGroup
Dim strUser
strGroup = "Admins"
strGroup2 = "Users"
strUser = CurrentUser
Set ws = DBEngine.Workspaces(0)
Set grp = ws.Groups(strGroup)
On Error Resume Next
strUserName = ws.Groups(strGroup).Users(strUser).Name
IsAdmin = (Err = 0)
If IsAdmin = False Then
Me!Command41.Visible = False
Me!Label42.Visible = False
Else
Me!Command41.Visible = True
Me!Label42.Visible = True
End If
Basically, does anyone know of any code that can be used to check if a user is a member of a particular group -- regardless of whether the user is an Admin or standard User?
(The code below is what I use and it works consistently but only if the logged in user is an Admin...
Dim ws As Workspace
Dim grp As Group
Dim strGroup
Dim strUser
strGroup = "Admins"
strGroup2 = "Users"
strUser = CurrentUser
Set ws = DBEngine.Workspaces(0)
Set grp = ws.Groups(strGroup)
On Error Resume Next
strUserName = ws.Groups(strGroup).Users(strUser).Name
IsAdmin = (Err = 0)
If IsAdmin = False Then
Me!Command41.Visible = False
Me!Label42.Visible = False
Else
Me!Command41.Visible = True
Me!Label42.Visible = True
End If