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)