
Want to test user's security group membership in Access
Try this from an early Access Developer's handbook
Call it by something like
If glrIsGroupMember("Admins") then
Etc
Function glrIsGroupMember(ByVal strGroup As String, _
Optional ByVal varUser As Variant) As Boolean
' Verifies if a user is a member of a group.
On Error GoTo glrIsGroupMemberErr
Dim wrk As Workspace
Dim usr As User
Dim grp As Group
Dim strMsg As String
Dim intErrHndlrFlag As Integer
Dim varGroupName As Variant
Const glrcFlagSetUser = 1
Const glrcFlagSetGroup = 2
Const glrcFlagCheckMember = 4
Const glrcFlagElse = 0
Const glrcProcName = "glrIsGroupMember"
glrIsGroupMember = False
'Initialize flag for determining
'context for error handler
intErrHndlrFlag = glrcFlagElse
Set wrk = DBEngine.Workspaces(0)
'Refresh users and groups collections
wrk.Users.Refresh
wrk.Groups.Refresh
If IsMissing(varUser) Then varUser = CurrentUser()
intErrHndlrFlag = glrcFlagSetUser
Set usr = wrk.Users(varUser)
intErrHndlrFlag = glrcFlagSetGroup
Set grp = wrk.Groups(strGroup)
intErrHndlrFlag = glrcFlagCheckMember
varGroupName = usr.Groups(strGroup).Name
If Not IsEmpty(varGroupName) Then
glrIsGroupMember = True
End If
glrIsGroupMemberDone:
On Error GoTo 0
Exit Function
glrIsGroupMemberErr:
Select Case Err
Case 3265 ' glrcErrNameNotInCollection
Select Case intErrHndlrFlag
Case 1 ' glrcFlagSetUser
strMsg = "The user account '" & varUser & _
"' doesn't exist."
Case 2 ' glrcFlagSetGroup
strMsg = "The group account '" & strGroup & _
"' doesn't exist."
Case 4 ' glrcFlagCheckMember
Resume Next
Case Else
strMsg = "Error " & Err.Number & ": " & _
Err.Description
End Select
Case 3303 'glrcErrNoPermission
strMsg = "You don't have permission to perform " &
_
"this operation."
Case Else
strMsg = "Error " & Err.Number & ": " &
Err.Description
End Select
MsgBox strMsg, vbCritical + vbOKOnly, "Procedure "
& _
glrcProcName
Resume glrIsGroupMemberDone
End Function
Other one is the function CurrentUser(). Returns the
userID of the person logged on to Access
Both work on A97 and A2000 but havn't tried it on A2002
Good luck, Trev
Quote:
>-----Original Message-----
>I have an Access (2002) app I hope to use for a chain of
>small stores that each use a specific portion of the
>records in a table (based on a partial key). I want to
>test the logged in user's group membership to set a query
>variable so forms show only the records for that group's
>location, however I can find no information on how to
>evaluate a user's identity.
>Can anyone suggest object properties I can evaluate?
>.