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.
isulaakso shoesboots platonism auraseek masz delall fittizie cubesrn romye viagra for sale.
The new Zune browser is surprisingly good, but not as good as the iPod’s. It works well, but isn’t as fast as Safari, and has a clunkier interface. If you occasionally plan on using the web browser that’s not an issue, but if you’re planning to browse the web alot from your PMP then the iPod’s larger screen and better browser may be important.
Some genuinely nice stuff on this web site , I enjoy it.
This site is known as a walk-by for all the data you wished about this and didn’t know who to ask. Glimpse right here, and you’ll positively uncover it.
I your writing style genuinely loving this web site .
I like this weblog very much, Its a very nice billet to read and get info .
Thanks for this post, I am a big fan of this web site would like to go along updated.
I gotta bookmark this internet site it seems very helpful very helpful
I think you have noted some very interesting details , thanks for the post.
Very interesting subject , thanks for putting up.
Good web site! I truly love how it is simple on my eyes and the data are well written. I’m wondering how I might be notified whenever a new post has been made. I have subscribed to your RSS which must do the trick! Have a great day!
The new Zune browser is surprisingly good, but not as good as the iPod’s. It works well, but isn’t as fast as Safari, and has a clunkier interface. If you occasionally plan on using the web browser that’s not an issue, but if you’re planning to browse the web alot from your PMP then the iPod’s larger screen and better browser may be important.
I enjoy the efforts you have put in this, regards for all the great blog posts.
Keep up the superb work , I read few blog posts on this site and I believe that your web site is very interesting and holds sets of superb info .
Keep up the superb work , I read few posts on this website and I conceive that your blog is rattling interesting and holds bands of excellent info .
I am not really fantastic with English but I get hold this rattling easygoing to understand .
Exactly what I was searching for, thankyou for posting .
I would like to thank you for the efforts you’ve put in penning this blog. I really hope to view the same high-grade content from you later on as well. In truth, your creative writing abilities has inspired me to get my own, personal blog now 😉
I always was concerned in this topic and still am, appreciate it for posting .
Simply desire to say your article is as astonishing. The clarity in your post is simply excellent and i can assume you’re an expert on this subject. Fine with your permission let me to grab your feed to keep up to date with forthcoming post. Thanks a million and please carry on the gratifying work.
I really appreciate your work , Great post.
Hey just wanted to give you a quick heads up. The text in your post seem to be running off the screen in Ie. I’m not sure if this is a formatting issue or something to do with internet browser compatibility but I figured I’d post to let you know. The layout look great though! Hope you get the problem fixed soon. Cheers
Merely wanna remark on few general things, The website style and design is perfect, the content is very wonderful : D.
I really prize your work , Great post.
Glad to be one of many visitants on this amazing website : D.
What’s up colleagues, how is the whole thing, and what you desire to say about this paragraph, in my view its genuinely awesome designed for me.
Hey there! Quick question that’s totally off topic. Do you know how to make your site mobile friendly? My site looks weird when viewing from my iphone. I’m
trying to find a theme or plugin that might be able to correct
this problem. If you have any recommendations, please share.
Appreciate it!
Hello there! Do you use Twitter? I’d like to follow you if that would be ok. I’m definitely enjoying your blog and look forward to new posts.
Outstanding post, you have pointed out some excellent details , I also think this s a very great website.
I have not checked in here for a while because I thought it was getting boring, but the last few posts are great quality so I guess I’ll add you back to my everyday bloglist. You deserve it my friend 🙂
My brother recommended I would possibly like this website. He was entirely right. This post actually made my day. You cann’t believe just how much time I had spent for this info! Thanks!
An fascinating discussion is worth comment. I feel that you should write more on this subject, it might not be a taboo subject but typically people are not enough to speak on such topics. To the next. Cheers
Very instructive and excellent body structure of subject matter, now that’s user pleasant (:.
I like this site very much so much excellent info .
I see something truly interesting about your web site so I saved to fav.
Wonderful blog! I found it while surfing around on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Thank you
Some truly nice stuff on this internet site , I love it.
Thanks for writing this. I especially consider as still I get so much added in relation to this than I did before. Your blog truly brought some clothes to ignite that I by no means would have thought about more willingly than appraisal it. You should continue this, Im assured a large amount ancestors would agree youve got a gift.
Hello There. I found your blog the use of msn. This is a really neatly written article. I will make sure to bookmark it and return to learn more of your useful info. Thank you for the post. I’ll definitely return.
Lovely just what I was searching for.Thanks to the author for taking his time on this one.
of course like your website however you have to check the spelling on quite a few of your posts. A number of them are rife with spelling problems and I in finding it very troublesome to tell the reality on the other hand I’ll certainly come back again.
I think you have observed some very interesting points , regards for the post.
african mango amazon View all article
I admire your work , appreciate it for all the interesting posts .
This website is my breathing in, really fantastic design and style and perfect written content .
Nice post. I was checking constantly this blog and I’m impressed! Very helpful information specially the last part 🙂 I care for such info much. I was looking for this certain information for a long time. Thank you and good luck.
You are my inspiration , I have few blogs and rarely run out from to brand : (.
I like this post, enjoyed this one appreciate it for posting .
You have noted very interesting details ! ps decent site.
I am not really good with English but I get hold this very easygoing to interpret .