[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bump::msaccess

Title:MSACCESS
Moderator:BUMP::HONER
Created:Tue Dec 01 1992
Last Modified:Mon Jun 02 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1661
Total number of notes:6339

1646.0. "Determining what group account(s) for a user" by TEKDEV::NYMAN () Wed Mar 26 1997 18:13

    I apologize if this is already in her somewhere.
    
    I have a need to be able to restrict certain users from accessing
    selected forms and fields on other forms. The restriction will be based
    on what group they belong to. After searching thru the documentation, I
    have not been able to discover a way of determining what group
    account(s) a user is a part of when they log in. Is there a way of
    determining this?
    
    I am using Access 7.0 currently, although the database will probably be
    migrated to Access 97 in the next few months.
    
    Thanks for any help,
    
    Dale
    
T.RTitleUserPersonal
Name
DateLines
1646.1Function to return a list of groups to which a specified user belongs.NETRIX::"dennis@superuser.stl.dec.com"Dennis LaoMon Apr 07 1997 03:0245
Here is a sample function taken from MS Technet article Q123079 (you can find
this at http://www.microsoft.com/kb)

Hope this helps.

   Function ListGroupsOfUser (UserName As String)
   '****************************************************************
   ' Purpose: Lists the groups to which a specified user belongs.
   ' Accepts: The name of a user.
   ' Returns: A list of groups for the specified user.
   ' Assumes: The existence of a user called Developer in the Admins
   '          group, with no password.
   '****************************************************************
 
   On Error GoTo err_ListGroupsOfUser
 
   Dim MyWorkSpace As WorkSpace, i As Integer
   Dim MyUser As User
 
   ' Create a new workspace as a member of the Admins group.
   Set MyWorkSpace = DBEngine.CreateWorkspace("SPECIAL", "Developer", "")
 
   Set MyUser = MyWorkSpace.Users(UserName)
 
   For i = 0 To MyUser.Groups.count - 1
        Debug.Print MyUser.Groups(i).Name
   Next i
 
   MyWorkSpace.Close
   Exit Function
 
   err_ListGroupsOfUser:
   If Err = 3265 Then
        MsgBox UCase(UserName) & " isn't a valid user name", 16, "Error"
   ElseIf Err = 3029 Then
        MsgBox "The account used to create the workspace does not exist"
   Else MsgBox Error(Err)
   End If
 
   MyWorkSpace.Close
   Exit Function
 
   End Function

[Posted by WWW Notes gateway]