Noting user account as member of group as false

C

Casey

I have some code I am using to delete a user from a
group. I have that happen, then I run this code beneath
it to try to message that the deletion was successfully
done. In the coding below ws has been dimmed as workspace,
[name1] is the text box entry of the user name on a form
(one that has been deleted).



If ws.Users([Name1]).Groups.Count = False Then
MsgBox "User has successfully deleted from group."
Endif

I think that the False iteration is not effective,
because the [name1] text box entry is really deleted and
no longer exists as an object in the group it has been
deleted from. But what would I use as an annotation
instead of the False iteration to have the code note that
the [name1] does not exist in that group anymore? I have
tried null, 0 and others.

I would appreciate any opinions.

Thank you,

Casey
 
C

Casey

Thank you Albert.
-----Original Message-----
Here is two code snips:

The first code snip is to check if the user is part of a group:

The 2nd code snip removes a user from a group.

Public Function IsInGroup(UsrName As String, GrpName As String) As Boolean
'Determines whether UsrName is a member of GrpName

Dim grp As Group
Dim IIG As Boolean
Dim usr As user

IIG = False

For Each usr In DBEngine.Workspaces(0).Users
If usr.Name = UsrName Then GoTo FoundUser
Next

GoTo IIG_Exit

FoundUser:
For Each grp In usr.Groups
If grp.Name = GrpName Then IIG = True
Next

IIG_Exit:
IsInGroup = IIG


End Function


Public Sub RemoveFromSecGroup(strUserName As String, strGroupName As String)

' remove user from a group
Dim uUser As user
Dim gGroup As Group

Set uUser = DBEngine.Workspaces(0).Users(strUserName)

uUser.Groups.Delete strGroupName
uUser.Groups.Refresh


End Sub


--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn


Casey said:
I have some code I am using to delete a user from a
group. I have that happen, then I run this code beneath
it to try to message that the deletion was successfully
done. In the coding below ws has been dimmed as workspace,
[name1] is the text box entry of the user name on a form
(one that has been deleted).



If ws.Users([Name1]).Groups.Count = False Then
MsgBox "User has successfully deleted from group."
Endif

I think that the False iteration is not effective,
because the [name1] text box entry is really deleted and
no longer exists as an object in the group it has been
deleted from. But what would I use as an annotation
instead of the False iteration to have the code note that
the [name1] does not exist in that group anymore? I have
tried null, 0 and others.

I would appreciate any opinions.

Thank you,

Casey


.
 

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