Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group instead of CurrentUser

Status
Not open for further replies.

Lisabm

Programmer
May 14, 2002
2
US
Does anyone know how to reference in code a group in security instead of listing all current users. So if you create a group called OES and list all users under the group. Instead if saying: If CurrentUser = JJacob or CurrentUser = JJones, can we just say (hopefully) CurrentGroup = OES or something like that. I can not find anything under help about group security.
 
This function will tell you if the user is in a particular group. This will usually do the kind of thing you're looking for.

Jeremy

Public Function IsUserInGroup(sUser As String, sGroup As String) As Boolean
On Error GoTo Error
Dim ws As Workspace
Dim uUser As User
Dim iCount As Integer

Set ws = DBEngine.Workspaces(0)
Set uUser = ws.Users(sUser)
IsUserInGroup = False
For iCount = 0 To uUser.Groups.Count - 1
If uUser.Groups(iCount).Name = sGroup Then
IsUserInGroup = True
End If
Next iCount
Exit Function
Error:
'ErrorTrap Err.Number, Err.Description, "IsUserInGroup"
End Function
=============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top