Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2002
    Posts
    154

    Question Unanswered: Allowing only certain users to use a button on a form

    Does anyone out there know of any way to restrict the use of a particular command button on a form that is usable by many people besides asking who is the CurrentUser? I can conceive of an if then statement that says if CurrentUser is this user or that user enable the button in the On Current Event but wondered if someone had something different or more clever. Thank you in advance for your time and your replies.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    yes
    short of rolling your own security / acces module one way would be to use the Access workgroup file
    create an entry for each netwrok logon as a user
    create groups as requriede
    assign users to group(s) - think of a group as a role (a person may have more than one role)

    query the workgroup file to see if the specified user is a memebr of a specified group, if they are then enable the button, if not then disable or hde the button

    there are code examples in this thread that will help.
    BTW don't use the currentuser() if you can avoid it if you are in doubt then agin do a search on this thread for details.

    HTH
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Mar 2006
    Posts
    5
    Quote Originally Posted by feetdontfailme
    Does anyone out there know of any way to restrict the use of a particular command button on a form that is usable by many people besides asking who is the CurrentUser? I can conceive of an if then statement that says if CurrentUser is this user or that user enable the button in the On Current Event but wondered if someone had something different or more clever. Thank you in advance for your time and your replies.
    FeetDontFailMe..

    On the form in question do the following:

    1. Put an unbound text box - name it "PasswordTxt"
    2. In properties for "PasswordTxt", select the password input mask
    3. Save the form
    4. Go to the AfterUpdate event of "PasswordTxt", enter the following [Event Procedure]

    If [PasswordTxt] ="my password" Then
    [CommandButton].Visible = True
    Else:[CommandButton].Visible = False
    End If

    5. Set the visible property on your command button to false
    6. In the On Current Event of your form enter the following:

    [CommandButton].Visible = True

    -------------------

    One last thing - I'm going off the top of my head here, but this should work. I've used the approach many times. If you have questions, just ask them.
    If it's about mySQL - don't ask - because I don't know.

    If it's about MS Access - ask away - I've had 10 years experience.

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Button passwords

    See the attachment. You can use it to set the buttons visible/invisible.
    Attached Files Attached Files
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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