remove user from group

teel73

Registered User.
Local time
Today, 14:19
Joined
Jun 26, 2007
Messages
205
I'm trying to remove users from a group. Can someone please tell me what I'm doing wrong here. I keep getting an error that the Item isn't in the collection. here's my code:

Code:
Dim ws As Workspace
Dim db As Database
Dim rst As Recordset
Dim NewUser As User
Dim grp, grpUsers, grpAdmins As Group
Dim uName, uPassword, uPID As String
Dim sql, grpName As String
 
DBEngine.SystemDB = "C:\Documents and Settings\e3utbl\Desktop\SCC_Dashboard\GuardOfficers\WackOfficers.mdw"
DBEngine.DefaultUser = "e3utbl"
DBEngine.DefaultPassword = "elmo1zoi"

sql = "SELECT Add_Delete_Users.UserID, Add_Delete_Users.FirstName, Add_Delete_Users.LastName, Add_Delete_Users.Group " _
    & "FROM Add_Delete_Users WITH OWNERACCESS OPTION;"
Set db = CurrentDb
Set ws = Workspaces(0)
Set rst = db.OpenRecordset(sql, dbOpenDynaset)

rst.MoveLast
rst.MoveFirst
Do
    grpName = rst!Group
    'Debug.Print rst!UserID
    uName = LCase(rst!UserId)
    'uPassword = frm!Password
    uPID = LCase(rst!UserId) & Format(Date, "mmyy")
    
    
    Set NewUser = ws.Users(uName)
    NewUser.Groups.Delete ("FullDataUsers")
Loop
 
Did you try manually doing it from within the database using the security workgroup menu option?
 
I have 45 users that need to be removed from one group and added to another. I have a program that creates the users and appends them to a group. I loop through a table. I just need to know the proper syntax. I don't know why its giving me the error that the item isn't found in the collection.
 

Users who are viewing this thread

Back
Top Bottom