johnlute said:
Permissions granted by workgroup.
I'm trying to limit what users can access. I've modified my main menu for
full permissions users (KEYSTONEeditids) and created another menu for
read-only users (KEYSTONEqryrpt). The database opens to the KEYSTONEqryrpt
form which has the comand button to close it and open the KEYSTONEeditids
form.
One can check whether the user has permissions on a particular object, but
what I have done in the past is just check to see if the current user is a
member of a particular security group. To that end, I wrote this function:
'------ start of code ------
Function fncUserIsInGroup(GroupName As String) As Boolean
' Returns True if the current user is a member of the specified
' security group; False if not, or if the group doesn't exist, or
' if an error occurs reading the groups.
Dim ws As Workspace
Set ws = DBEngine.Workspaces(0)
On Error Resume Next
fncUserIsInGroup = _
(ws.Users(CurrentUser).Groups(GroupName).Name = GroupName)
Set ws = Nothing
End Function
'------ end of code ------
So, to see if the current user is a member of the group named "Read-Only
Users", you might write:
If fncUserIsInGroup("Read-Only Users") Then
' this is a read-only user
Else
' this user has write permissions.
End If
That's assuming that you assign permissions by group, not by individual
user, and also (for this example) that you have only one read-only group of
users. If you have more than one group of read-only users, you'd need to
check each group.
Does that get you where you want to go, John?