recall current group name and compare

dt01pqt

Certified
Local time
Today, 10:32
Joined
Mar 22, 2004
Messages
271
I need to be able find out what group the current user is in and check whether it is the senior users group.

Although junior users cannot append records according to their rights, due to the interface design I have made it clear which fields can be edited by highlighting the labels in red when a user presses the edit button (plus unlocking them). I think it would be neater if this didn't happen for junior users and therefore would like a simple if statement to surround this code.

I realise you use something like:

DBEngine.Workspaces(0).Users(CurrentUser).Groups(index).name
 
dt01pqt said:
I need to be able find out what group the current user is in and check whether it is the senior users group.

Although junior users cannot append records according to their rights, due to the interface design I have made it clear which fields can be edited by highlighting the labels in red when a user presses the edit button (plus unlocking them). I think it would be neater if this didn't happen for junior users and therefore would like a simple if statement to surround this code.

I realise you use something like:

DBEngine.Workspaces(0).Users(CurrentUser).Groups(index).name

Ok got it:

Code:
Function IsUserInGroup(GroupName As String) As Boolean
Dim ws As Workspace
Dim usr As User
Dim intLoop As Integer

IsUserInGroup = False

Set ws = DBEngine.Workspaces(0)
Set usr = ws.Users(CurrentUser())
For intLoop = 0 To usr.Groups.Count - 1
If StrComp(usr.Groups(intLoop).Name, GroupName, vbTextCompare) = 0 Then
IsUserInGroup = True
Exit For
End If
Next intLoop

End Function
 

Users who are viewing this thread

Back
Top Bottom