Question : Code for User Permission level

I want to assign users to groups that have various permissions. Once I have assigned users to groups, how do I determine their user permission or access/control level. Meaning, we have secretaries, analysts, senior analysts, supervisors, managers, etc. that I want to control what they can and can not do. Is there a table or something that I can access to find out the users particulate group?

Answer : Code for User Permission level

You can determine whether a user is part of group like this (see code snippet below):

If IsUserInGroup("Scott", "Managers") Then
  '/enable your controls here, perhaps
Else
  Msgbox "You may not be able to use certain fields in this form."
End If
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
Function IsUserInGroup(UserName As String, GroupName As String) As Boolean
'/Purpose:
'/Created: 12/11/2008 09:45 AM
'/Created By: Scott
 
Dim usr As DAO.User
 
On Error GoTo Err_IsUserInGroup
 
Set usr = DBEngine.Workspaces(0).Groups(GroupName).Users(UserName)
 
IsUserInGroup = True
 
Exit_IsUserInGroup:
  On Error Resume Next
  Set usr = Nothing
  Exit Function
 
Err_IsUserInGroup:
 
  Select Case Err
    Case 3265
      '/either the group doesn't exist, or it does but the User isn't a member.
      '/either way, we return False
    Case Else
     MsgBox "An error occurred in this application." & vbCrLf & vbCrLf & Err & ":" & Error$ & vbCrLf & vbCrLf & "Technical Information: Occurred in [Module1].[IsUserInGroup]", vbCritical, "Application Error"
  End Select
  
  Resume Exit_IsUserInGroup
End Function
Random Solutions  
 
programming4us programming4us