Question:
Question:
I am trying to limit access to something by Organizational Department or Team Name. I know that you can access the username (Application.BasicFunctions.SystemInfoFor(UserName)) but how do I get the Organizational Department or Team Name of the user who is currently logged in?
Answer:
This is a function created by Ryan Farley to determine the Users Department or Team.
' sGroupType = "T" for team, and "D" for department
Function IsMember(ByVal sUser, ByVal sGroup, ByVal sGroupType)
Dim objRS
If sGroupType = "T" Then sGroupType = "G"
Set objRS = CreateObject("ADODB.Recordset")
With objRS
Set .ActiveConnection = Application.GetNewConnection
.Open "select accessid from secrights where seccodeid = " & _
"(select seccodeid from seccode where (seccodedesc = '" & sGroup & "') " & _
"and (seccodetype = '" & sGroupType & "')) and (accessid = '" & sUser & "')"
If Not (.EOF Or .BOF) Then
IsMember = (.Fields(0).Value & "" = sUser)
Else
IsMember = False
End If
.Close
End With
Set objRS = Nothing
End Function