Load form based on user group

  • Thread starter Thread starter Kay
  • Start date Start date
K

Kay

Hi

I have set user groups on my database using the security feature
provided by Access2000. I want to display a form based on the user who
logs in. I have used the following code:

If CurrentUser() = "Admin" Then
DoCmd.OpenForm "ManagerOptions"
Else
If CurrentUser() = "Users" Then
DoCmd.OpenForm "UserOptions"
End If
End If

This works fine if I log in as admin as all the admins will login under
that username. But the group of users have their own login names so
using this code does not work for users. Does anyone know how I can get
it to load a form based on the group te user is part of.

Any help is very much appreciated
 
This function might give you what you need:

Public Function IsUserInGroup(strUserName, strGroupName) As Boolean
On Error Resume Next
Dim strName As String
strName =
DBEngine.Workspaces(0).Users(strUserName).Groups(strGroupName).Name
IsUserInGroup = (Err.Number = 0)
End Function

HTH,
Barry
 
Do you know how I can use this function with my code as I have not
worked with functions

thanks
 
If IsUserInGroup(CurrentUser(),"Admins") Then
DoCmd.OpenForm "ManagerOptions"
Else
If IsUserInGroup(CurrentUser(),"Users") Then
DoCmd.OpenForm "UserOptions"
End If
 
Do you know how I can use this function with my code as I have not
worked with functions

thanks
 
Thanks very much Barry, I really appreciate your help, It is now
working and all thanks to you

Thankyou
 
Back
Top