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. Write more, thats all I have to say. Literally, it seems as
    though you relied on the video to make your point. You definitely know what youre talking about, why waste your intelligence on just posting
    videos to your weblog when you could be giving us something informative to
    read?

  2. Hmm is anyone else experiencing problems with the images on this blog loading?
    I’m trying to figure out if its a problem on my end or if it’s the blog.
    Any responses would be greatly appreciated.

  3. Greetings! I know this is kinda off topic but I was wondering which blog platform are you using for this
    website? I’m getting fed up of WordPress because I’ve had problems with hackers and I’m looking at alternatives for another platform. I would be fantastic if you could point me in the direction of a good platform.

  4. This is a good tip especially to those new to the blogosphere.
    Brief but very precise information… Many thanks for sharing this one.
    A must read post!

  5. There’s certainly a lot to find out about this subject. I really like all the points you have made.

  6. I have read so many posts about the blogger lovers but this post is actually a fastidious piece of writing, keep it up.

  7. I leave a comment each time I especially enjoy a post on a website or I have something to valuable
    to contribute to the discussion. It is a result of the sincerness communicated in the post I read.
    And on this post How to Password Protect a Form or Report
    in Microsoft Access | Shane Zentz’s Blog. I was actually excited enough to post a thought 😉 I do have a couple of questions for you if it’s
    allright. Could it be only me or do some of these responses appear
    like they are coming from brain dead visitors?
    😛 And, if you are posting at additional places, I’d like to keep up with everything fresh you have to post. Would you list all of all your community pages like your linkedin profile, Facebook page or twitter feed?

  8. I do trust all of the ideas you’ve presented to your post. They are really convincing and will definitely work. Nonetheless, the posts are very quick for novices. May you please lengthen them a little from subsequent time? Thanks for the post.

  9. Thank you for every other informative blog. Where else may just I get that kind of information written in such an ideal manner?
    I have a challenge that I am simply now running on, and I’ve been at the glance out for such information.

  10. Hello There. I found your weblog the usage of msn.

    That is a very smartly written article. I will be sure to bookmark
    it and come back to read extra of your helpful info. Thanks for the post.
    I will certainly comeback.

  11. Hey! I know this is kinda off topic but I’d figured I’d ask.

    Would you be interested in exchanging links or maybe guest authoring a blog post or vice-versa?
    My blog covers a lot of the same subjects as yours and I think
    we could greatly benefit from each other.

    If you are interested feel free to shoot me an e-mail.
    I look forward to hearing from you! Terrific blog by the way!

  12. May I simply just say what a comfort to find a person that actually
    understands what they’re discussing on the web. You definitely understand how to bring a problem to light and make it important. More and more people should check this out and understand this side of your story. It’s surprising you aren’t more popular given that you definitely possess the gift.

  13. It is perfect time to make some plans for the future and it is time to be happy.
    I’ve read this post and if I could I desire to suggest you some interesting things or advice. Perhaps you can write next articles referring to this article. I wish to read even more things about it!

  14. May I simply just say what a comfort to uncover someone who actually understands what they are talking about over the internet.
    You definitely know how to bring a problem to light and make it important.

    More and more people really need to look at this and understand this side of your story.
    I can’t believe you are not more popular because you most certainly possess the gift.

  15. Wonderful site. Lots of helpful information here.
    I’m sending it to some pals ans also sharing in delicious. And of course, thanks in your effort!

  16. Thank you, I’ve recently been looking for information approximately this topic for a while and yours is the greatest I’ve
    came upon so far. But, what concerning the conclusion?

    Are you sure in regards to the supply?

  17. Simply wish to say your article is as astounding.
    The clearness in your post is simply excellent and i can assume you’re an expert on this subject. Well with your permission allow me to grab your feed to keep up to date with forthcoming post. Thanks a million and please continue the rewarding work.

  18. Link exchange is nothing else however it is just
    placing the other person’s webpage link on your page at appropriate place and other person will also do same in support of you.

  19. Simply wish to say your article is as astonishing. The clarity in your post is just excellent and i can assume you are an expert on this subject.
    Fine with your permission let me to grab your RSS feed to keep up to date with forthcoming post.
    Thanks a million and please continue the rewarding work.

  20. I delight in, result in I discovered exactly what I used to
    be looking for. You have ended my four day long hunt!
    God Bless you man. Have a nice day. Bye

  21. It is the best time to make some plans for the future and it is
    time to be happy. I have read this post and if I could I desire
    to suggest you few interesting things or tips.
    Perhaps you could write next articles referring to this article.
    I want to read more things about it!

  22. Its like you read my mind! You appear to know so much about this, like you wrote the book in
    it or something. I think that you can do with some pics to drive the message home a bit, but other than
    that, this is wonderful blog. A great read. I will definitely be back.

  23. Hi there! I could have sworn I’ve been to this blog before but after looking at many of the posts I realized it’s new to me.
    Anyways, I’m certainly pleased I discovered it and I’ll be book-marking
    it and checking back regularly!

  24. Hello would you mind letting me know which web host you’re using? I’ve
    loaded your blog in 3 different internet browsers
    and I must say this blog loads a lot quicker then most.

    Can you recommend a good hosting provider at a honest price?
    Thanks a lot, I appreciate it!

  25. I was wondering if you ever considered changing the layout of your blog?

    Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so people could connect with it better.
    Youve got an awful lot of text for only having
    1 or two pictures. Maybe you could space it out better?

Comments are closed.