delete user group

teel73

Registered User.
Local time
Today, 10:51
Joined
Jun 26, 2007
Messages
205
I'm trying to delete or remove a group membership for a user. I get the following error when I execute my code. "Item not found in this collection." What am I doing wrong. Here's my code:

Code:
Dim dbs As Database
Dim frm As Form
Dim uName, upid As String
Dim ws As Workspace
Dim myUser As User
Dim myGroup As Group
Dim grpLoop As Group
Dim curGrp As Integer
Dim curGrpName As String
 
DBEngine.SystemDB = "T:\\[URL="file://\\ERS_SYSTEM_FILES\SCCERS_Security.mdw"]ERS_SYSTEM_FILES\SCCERS_Security.mdw[/URL]"
DBEngine.DefaultUser = "Admin"
DBEngine.DefaultPassword = ""

Set dbs = CurrentDb
Set ws = Workspaces(0)
Set frm = Form_frmManageUserGroupAccounts
uName = frm!cboSelectUsr.Value 'tlewis'
 
'Get the id of the group
curGrp = DLookup("MemberOf", "tblUsers", "[userName] = '" & uName & "'")
 
'Get the name of the group which is Admins
curGrpName = DLookup("GroupName", "tblUserGroups", "[grpId] = " & curGrp & "")

Set myUser = ws.Users(uName)
myUser.Groups.Delete (curGrpName)
 
It breaks on the following line:
Code:
myUser.Groups.Delete curGrpName
 

Users who are viewing this thread

Back
Top Bottom