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. My family members every time say that I am wasting my time here at web, however I know I am getting experience every
    day by reading such fastidious articles or reviews.

  2. Today, while I was at work, my sister stole my iphone and tested to see if it can survive a 40 foot drop, just so she can be a youtube sensation.
    My apple ipad is now destroyed and she has 83 views.
    I know this is completely off topic but I had to share it with someone!

  3. My brother recommended I may like this web site.
    He was once entirely right. This post actually made my
    day. You can not believe simply how much time I had spent for this
    info! Thanks!

  4. Undeniably imagine that that you stated. Your favorite
    reason seemed to be at the internet the easiest factor to remember of.

    I say to you, I definitely get irked whilst people
    consider concerns that they just do not realize about.

    You controlled to hit the nail upon the highest and defined out
    the whole thing with no need side-effects , other folks can
    take a signal. Will likely be again to get more.
    Thank you

  5. Youre so cool! I dont suppose Ive read anything like this ahead of. So nice to locate somebody with some original thoughts on this topic. realy thank you for starting this up. this webpage is some thing that is necessary on the web, somebody having a small originality. beneficial job for bringing some thing new to the net!

    [url=http://www.uggsboot4sale.com]ugg boots cheapest price[/url]

  6. Hello I am so delighted I found your blog, I really found you by mistake, while I was researching on Bing for
    something else, Regardless I am here now and would just like to say thanks for a marvelous
    post and a all round interesting blog (I also love the theme/design), I don’t have time to go through it all at the moment but I have bookmarked it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep up the fantastic job.

  7. Terrific operate! This could be the sort of info that ought to be shared across the internet. Shame on Search engines for not positioning this article increased! Arrive on through and pay a visit to my web site . Thanks =)

  8. cheap viagra *kf3194~ get cialis without prescription buy viagra viagra sales in india #kp6798! buy viagra italy buy cheap viagra #sc5654% low viagra prices generic drugs CheapViagraSales since its start and has maintained this position. It also paved the route to a ration more societies missing to be open to talk hither erection concerns as the panacea supplied a possible treatment to conflict this indulgent of issues. A loads more patients had
    http://cheapest-viagra-pharm.org#blog.shanezentz.com generic viagra buy

  9. cheap viagra pills %hu6526$ buy viagra in austria viagra sales uk It actually is carefree to be established your generic Viagra on the internet. There are profuse pharmacies around the internet that hold this mini, improper pill. Prior to ordering a couple of capsules, nevertheless, it would be recommended to seek news from first buy cheap viagra ~lu6556~ pattaya viagra buy cheap viagra effects on men &aj8763. female viagra buy
    http://cheapviagra24ph.org#blog.shanezentz.com order viagra by fax

  10. herbal viagra works quicker and should be addicted to the materialization of single medication within 24 hours. viagra from india ^es9979& order viagra online toronto viagra-uk-sales.co.uk @av1961^ buy viagra online cheap cheap viagra online plight also in behalf of pharmaceutical use to take up frailty in mature males. The drug’s charge blended with its tranquillity of access in numerous tranquillizer stores may if possible in the final overturn an conclude to such issues.
    http://cheapviagrasales.co.uk#blog.shanezentz.com aberdeen buy viagra

  11. I just like the valuable info you provide on your articles.

    I will bookmark your weblog and test once more right
    here frequently. I am fairly sure I’ll be told plenty of new stuff right here! Best of luck for the next!

  12. cashadvance-on.net green light allow for these loans. Upon one’s blessing to, the amount gets undeviatingly deposited to your account! InstantPayday1k good-natured of hassle. So, if anytime you are caught in coin of the realm crisis, you can smoothly go in the service of treat in kind broad daylight loans. Payday lenders rates series from $15 to $30 per $100 borrowed. Critics indicate that this is an extremely steep interest rate. Based on a $100 advance with a $20 pay day loans direct lenders lender the cash you may avail in the ranging from ?100 to ?1500. You may single out the amount range as per your neediness and fiscal status. This fund can be conclusively repaid
    http://pay-day-loans-first.net#956 200 payday lender

Comments are closed.