How to Password Protect a Form or Report in Microsoft Access

How to Password Protect a Form or Report in Access

by Shane Zentz
Microsoft makes doing a lot of things with databases very easy. And password protecting a form or report is no exception. With just a few lines of code in the right place you can prevent unwanted users from opening and viewing or editing data in your form or report. Just as an aside, this is not the most secure method and in fact is not really secure at all. But in order for someone to find the password (which is hard-coded into the application) they would have to have at least basic knowledge of access from the design and programming point of view, so if they are just users then chances are that they will never discover the password (by looking at the code behind the program) unless someone tells it to them or they discover it written down somewhere. Having said that, this method is still pretty useful for just average applications, like I said it is not really the most secure method, so if your application contains really sensitive data (like social security numbers or bank account numbers) then I would advise using another more secure method. But if you just need a basic password protection to protect just one or a few forms from average users then this method will work and it is also quick and very easy. So read on to see how this is done.

Open the form or report that you want to password protect in design view and find ‘form’ in the properties field (see photo 1). Then switch to the events tab. Under the events tab you will see a field called ‘on load’ (see photo 1), this is the field that controls what the form or report does when it is first loaded or opened. Here we want to add some code to the on load event so that it will first prompt the user for a password. So click on the tiny icon with the three little dots on it and on the window that pops up, select ‘code builder’. This will bring up a Visual Basic window (see photo 2) which will have a method for the ‘onload’ event preloaded. All we need to do is to add the code to this section.

 

Here is the code:
Dim PassWord As String

PassWord = InputBox(“Enter Password”)

If PassWord = “whatever password you choose here” Then’

Open FormDoCmd.OpenForm “name of the form that you want to password protect”
ElseMsgBox (“Wrong Password?”)

DoCmd.Close acForm, Me.NameEnd If

Save the code and exit and also save the changes to the form. Now try to open the form and you will get a password box before the form will open. If you enter the correct password then it will open, otherwise it will not. Another thing I should mention is that the text for the password is not dotted out or starred out like is usually is with password protection forms. I think that this can be changed but that is beyond the scope of this tutorial.
This code is pretty basic. To use this you will need to change the line that says “whatever password you choose here” to whatever you want the password to be. And then change the “name of the form that you want to password protect” to the name of your form. Now, you can change “Enter Password” to whatever message you want to appear when the password box comes up, and likewise, you can change the “Wrong Password?” part to whatever message that you want to display when the user enters the wrong password or does not enter any password at all.
So there you have it, a pretty easy and basic password protection system to password protect a form or report in Microsoft access. This will work with just about any version of Access, so give it a try. Just remember that this is not really completely secure becuase anyone who knows how can just look at the form in design view and then check the ‘onload’ event code to discover the hard-coded password, but the average user will never know how to do this anyway, so this is a reasonably decent solution.
Thanks for reading this tutorial on password protecting a form or report in a microsoft access database.

959 thoughts on “How to Password Protect a Form or Report in Microsoft Access”

  1. We’re a group of volunteers and starting a new scheme in our community. Your site offered us with valuable info to work on. You have done a formidable job and our whole community will be grateful to you.

  2. Pretty section of content. I just stumbled upon your blog and in accession capital to assert that I acquire actually enjoyed account your blog posts. Anyway I will be subscribing to your augment and even I achievement you access consistently fast.

  3. Hey there, You’ve done a great job. I will definitely digg it and personally recommend to my friends. I’m confident they’ll be benefited from this site.

  4. Hi my loved one! I want to say that this article is awesome, great written and come with almost all important infos. I would like to peer extra posts like this .

  5. We’re a group of volunteers and starting a new scheme in our community. Your site offered us with valuable info to work on. You have done an impressive job and our whole community will be thankful to you.

  6. In the great design of things you get a B- with regard to effort. Where you actually confused everybody was first on the particulars. You know, they say, details make or break the argument.. And it could not be much more true here. Having said that, permit me tell you what did do the job. Your article (parts of it) is definitely pretty engaging which is most likely why I am making an effort to opine. I do not really make it a regular habit of doing that. Next, although I can certainly see the leaps in reason you make, I am definitely not convinced of how you seem to connect your points which produce your final result. For now I will, no doubt subscribe to your issue however wish in the foreseeable future you actually link the facts much better.

  7. I precisely needed to say thanks all over again. I’m not certain the things I might have followed in the absence of those recommendations contributed by you regarding that area of interest. It truly was a real terrifying issue in my position, but being able to see a new expert fashion you treated the issue took me to jump for happiness. Extremely happier for the assistance and even trust you find out what an amazing job you happen to be undertaking training the others thru a site. More than likely you haven’t got to know all of us.

  8. I’ve learn a few excellent stuff here. Definitely value bookmarking for revisiting. I wonder how so much effort you place to make this kind of fantastic informative website.

  9. I genuinely have studying by this website, it has got fantastic posts. “And all the winds go sighing, In support of sweet equipment dying.” by Christina Georgina Rossetti.

  10. Really informative and excellent anatomical structure of subject material , now that’s user genial (:.

  11. In this article I will teach you the basics of how to have fun learning your chords
    by playing out of a Fake Book. As an alternative, it will most likely be far more powerful for you to learn about audio and chord idea.
    The last type of chords we will discuss in this article are spread voicings.

  12. If you offer to pay for a lot more than what your state allows you to
    definitely charge in interest propsper will let you already know payday loans online bu durum da tam bir
    felaketti nk hem banka banka kouturmak gerekiyordu, banka grevlilerini eki nakite dndrmeleri iin onlar ikna etmek gerekiyordu,
    sonra da bir ay kadar da beklemek gerekiyordu.

  13. I think this is among the most significant info for me. And i am glad reading your article. But should remark on few general things, The site style is perfect, the articles is really nice : D. Good job, cheers

  14. If the property from qualified people to ascertain the market from failed financial sector occupiers collides with a steady dividend cashflow from the buyers that check out the creating. It must contain the details of the perils which they cover. In the present scenario, there are a limited liability company you have trouble determining who will hear your appeal, contact the Assessor’s Office generally does not need doing. Chapters 2 and 3, pp.

  15. Zune and iPod: Most people compare the Zune to the Touch, but after seeing how slim and surprisingly small and light it is, I consider it to be a rather unique hybrid that combines qualities of both the Touch and the Nano. It’s very colorful and lovely OLED screen is slightly smaller than the touch screen, but the player itself feels quite a bit smaller and lighter. It weighs about 2/3 as much, and is noticeably smaller in width and height, while being just a hair thicker.

  16. Greetings from Los angeles! I’m bored at work so I decided to check out your site on my iphone during lunch break. I enjoy the info you provide here and can’t wait to take a look when I get home. I’m surprised at how fast your blog loaded on my phone .. I’m not even using WIFI, just 3G .. Anyhow, very good blog!

  17. I like the valuable info you supply on your articles. I will bookmark your weblog and take a look at again right here regularly. I am somewhat certain I’ll learn a lot of new stuff right right here! Best of luck for the following!

Comments are closed.