|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
IsUserInGroup Function in a Form's Open Event Here is my current Syntax but I am getting the following error message: Expected End Sub Private Sub Form_Load() Function faq_IsUserInGroup(strGroup As String, strUser As String) As Integer ' Returns True if user is in group, False otherwise ' This only works if you're a member of the Admins group. Dim ws As Workspace Dim grp As Group Dim strUserName As String Set ws = DBEngine.Workspaces(0) Set grp = ws.Groups(strGroup) On Error Resume Next strUserName = ws.Groups(strGroup).Users(strUser).Name faq_IsUserInGroup = (Err = 0) If faq_IsUserInGroup("Regulatory", CurrentUser) Then Me.Add_Review_Employee_Information.Visible = True Me.cmdViewTraining.Visible = True Me.cmdReviseSops.Visible = True Me.cmdAddBpr.Visible = True Me.cmdRunReports.Visible = True Me.cmdAddLotNumber.Visible = True Me.cmdExit.Visible = True Else Me.cmdAddLotNumber.Visible = True Me.cmdRunReports.Visible = True Me.cmdExit.Visible = True End If End Function End Sub Should the function be entered in as a Module in the Form Code? See my answer in the original thread.
-- Show quoteHide quoteJoan Wild Microsoft Access MVP Olu Solaru wrote: > What is the proper Syntax for using the > IsUserInGroup Function in a Form's Open Event Here is my current > Syntax but I am getting the following > > > error message: Expected End Sub > > Private Sub Form_Load() > > Function faq_IsUserInGroup(strGroup As String, strUser As String) As > Integer ' Returns True if user is in group, False otherwise > ' This only works if you're a member of the Admins group. > > Dim ws As Workspace > Dim grp As Group > Dim strUserName As String > > Set ws = DBEngine.Workspaces(0) > Set grp = ws.Groups(strGroup) > On Error Resume Next > strUserName = ws.Groups(strGroup).Users(strUser).Name > faq_IsUserInGroup = (Err = 0) > > > If faq_IsUserInGroup("Regulatory", CurrentUser) Then > Me.Add_Review_Employee_Information.Visible = True > Me.cmdViewTraining.Visible = True > Me.cmdReviseSops.Visible = True > Me.cmdAddBpr.Visible = True > Me.cmdRunReports.Visible = True > Me.cmdAddLotNumber.Visible = True > Me.cmdExit.Visible = True > Else > Me.cmdAddLotNumber.Visible = True > Me.cmdRunReports.Visible = True > Me.cmdExit.Visible = True > End If > End Function > End Sub > > Should the function be entered in as a Module in the Form Code?
Programatically load a form based on user login.
Can I improve my setup? Security Alert in Access 2007 Access-New User-Help!! Diff Workgroups, Same DB, diff Security log on screen in Access? Programatically hide and unhide the database window can't run report from crystal reports Self-Signed Certificate how to export? Switchboard Security |
|||||||||||||||||||||||