Link to home
Start Free TrialLog in
Avatar of Jody Reid
Jody ReidFlag for United States of America

asked on

How to put password on a button in Access 2013

I have a form that has 10 buttons to open other forms. How can i put a password protection on some of these buttons so only some people can access these forms. I am running access 2013 and windows 10.
Thank you.
Avatar of Arana (G.P.)
Arana (G.P.)

there is more than one way to do this, a quick and dirty way would be to go to your form_open event
and add Abort = (InputBox("Enter Password:") <> "p@$$w0rd")

Ideally the password should be encrypted and in a table so you can edit it at will, but with this maybe you get the idea
yes, several ways of doing that.
What I like to do is get the "username" when the form loads and restrict the access only to certain users.
Add the below code to ON CLICK event procedure for one of our cmd buttons.

Dim user As String
user = Environ("username")
' msgbox user ' this could help you find out your username if you don't know it :)
If user <> "username1" And user <> "username2" And user <> "username3" And user <> "username4" Then
    MsgBox "ACCESS DENIED - " & user
Else
    DoCmd.OpenForm "FORM NAME", acNormal, "", "", , acNormal
End If
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jody Reid

ASKER

Thank you.