Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hiding a button on a form (Access 2000)

    Is there a way to hide a button on a form if the current user does not have admin right set in security or is a member of a certain group in the db's security. I have a button I want to leave on a form for only users with admin rights or a member of a group called exportsecure. I've set the security in the db. Is this possible? Thanks very much..

  2. #2
    Star Lounger
    Join Date
    Jan 2003
    Location
    Grass Valley, California, USA
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding a button on a form (Access 2000)

    If you display the Properties window while your form is in Design mode, then click on the button you wish to hide, you'll see two property values, namely "Visible" and "Enabled". The default value of both properties is True (Yes).

    In the VBA code that determines a user's eligibility to see the button, you can reset the Visible property to False (to totally make the button disappear), or the Enabled property to False (to "grey-out" the button and make it inoperable).

    For example, if the name of the button is "cmdDoIt", your VBA code in the form class would be:

    me.cmdDoIt.Visible = False
    or
    me.cmdDoIt.Enabled = False

    -- Jim

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Hiding a button on a form (Access 2000)

    I use the following function to determine whether the current user is a member of the admins group.

    I can then use this to determine whether to show or hide buttons, tab pages etc.

    Public Function fnIsAdmin() As Boolean
    Dim wks As Workspace
    Dim grp As Group
    Dim usr As User
    Dim boolinGroup As Boolean
    boolinGroup = False
    Set wks = DBEngine.Workspaces(0)
    Set grp = wks.Groups("Admins")

    For Each usr In grp.Users
    If usr.Name = CurrentUser Then
    boolinGroup = True
    End If
    Next usr
    fnIsAdmin = boolinGroup
    End Function

    You could use this in the OnOpen event for a from as follows:
    If fnIsAdmin Then
    Me!PageLists.Visible = True
    Me!CmdAddNew.Visible = True
    Else
    Me!PageLists.Visible = False
    Me!CmdAddNew.Visible = False
    End If
    Regards
    John



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •