Password on opening a form RRS feed

  • Question

  • Hello,

    I use the following script for opening a form:

        DoCmd.OpenForm "01 Menu Roosteraars", acNormal, , , , acWindowNormal

    The form is used as a menu for a specific group of users. They only need access to this form.

    Is it possible to put in a password before opening this form.

    Can anybody help me with this.



    Saturday, September 15, 2018 12:07 PM

All replies

  • Hi Ton,

    You can wrap that code in an If statement. For example:

    If Inputbox("Enter password") = "password" Then
        MsgBox "Wrong password"
    End If

    Hope it helps...

    Saturday, September 15, 2018 1:42 PM
  • I agree with theDBGuy's code, but it should be in Form_Open, and set Cancel to True if the password is wrong.

    Why? Because there is no way the user could open the form without my code running, while there could be several ways the user could open the form without clicking the button.

    -Tom. Microsoft Access MVP

    Saturday, September 15, 2018 5:47 PM
  • You might like to take a look at PasswordForm.zip in my public databases folder at:


    Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to  amend the form design accordingly.  

    If you have difficulty opening the link, copy the link (NB, not the link location) and paste it into your browser's address bar.

    This little demo file illustrates how a form can be given a password as a custom property of the form.

    Ken Sheridan, Stafford, England

    Saturday, September 15, 2018 5:55 PM
  • Why not create a table of authorized users (their windows usernames) and compare that again the system username (see: http://theaccessweb.com/api/api0008.htm ) and using a simple DLookUp you can compared the 2 and grant access or not without requiring any password or inconveniencing your users.


    You may benefit from reviewing http://www.devhut.net/2018/09/16/access-password-protect-a-form-or-a-report/

    Daniel Pineault, 2010-2017 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    Saturday, September 15, 2018 6:50 PM