Remove user from group

  • Thread starter Scott Whetsell, A.S. - WVSP
  • Start date
S

Scott Whetsell, A.S. - WVSP

I am trying to build a form that will allow those in supervisory positions to
be able to assign other users to different levels of access according to
group policy. I can get the Groups.Users.Append to work fine, but when I use
Groups.Users.Delete I get a 'Type Mismatch' error on the .Delete.

Here is a sniplet of the code I am using.

============START SNIPLET============
Dim CurrLvl As String ' Current Access Group
Dim NewLvl As String ' New Access Group
CurrLvl = Me.CurrAccLvl
NewLvl = Me.NewAccLvl
strUID = Me.txtCPWUserName
Set wrk = DBEngine.Workspaces(0)
With wrk
If CurrLvl = "View Only" Then
Set grpUsers = wrk.Groups("View Only")
Set usr = grpUsers.CreateUser(strUID)
grpUsers.Users.Delete usr
grpUsers.Users.Refresh
If (NewLvl = "Admins") Or (NewLvl = "Supervisors") Then
Set grpUsers = wrk.Groups("Admins")
Set usr = grpUsers.CreateUser(strUID)
grpUsers.Users.Append usr
grpUsers.Users.Refresh
If NewLvl = "Supervisors" Then
Set grpUsers = wrk.Groups("Supervisors")
Set usr = grpUsers.CreateUser(strUID)
grpUsers.Users.Append usr
grpUsers.Users.Refresh
End If
End If
============END SNIPLET============

My current user groups are Admins, Supervisors, Users, and View Only.
Admins and Users are the standard built in accounts.
Supervisors are also in the Admins group so they can add/change users, but
restricted from other Admin privledges.
View Only users are just that, they have read permissions only.




Thanks in advance.
 
J

Joan Wild

You don't need the .CreateUser() to delete them
Try simply

If CurrLvl = "View Only" Then
Set usr = wrk.Users(strUID)
usr.Groups.Delete "ViewOnly"
....
 
S

Scott Whetsell, A.S. - WVSP

Joan,

Thanks for pointing me in the painfully obvious direction again! :)

Take care.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top