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. A dream trip starts using a dream of how wonderful your trip could be to your selected destination. You dream of all the exciting things that you will find to complete there. Several individuals dream of going to Hawaii. The white sands, gorgeous beaches, volcanoes and flowers all call to them inviting them to a dreamy island where every little thing is excellent. Unfortunately, even though numerous issues about the island are as lovely as you dream, with no some homework and arranging your dream vacation may be remembered because the trip you wished you hadn’t taken.
    Big Island Hawaii vacation rentals takes some of the guesswork out of your preparing. They’ve got access to several resorts like the Aston Waikoloa Colony Villas and the Mauna Lani Resort. These are accommodations that provide a stunning setting that contains several extras like tours, spas, daycare facilities too as excellent accommodations and restaurants.
    Halii Kai offers numerous accommodations it just isn’t just a resort. Halii Kai rentals contain town homes and condos too. So if you decide to travel to Hawaii for your dream holiday you’ll have many alternatives. There are trip rentals in Kona that may provide you with a good place to remain and also access to many of the fantastic things which you would like to see and do. With places that access a lot of the lovely beaches you’ll have a prime chance hawaii vacation rentals big island to appreciate the lovely Hawaiian sunsets or surf within the waves.
    There are numerous Kolea condos which might be offered for rent which will give you a superb night sleep so that you’ll be able to get pleasure from the excursions and sight seeing that you just desire to do while in Hawaii. A Kona condo would be the appropriate option if you wish to see a number of the volcanoes, or probably the pineapple fields. Big island vacation rentals will supply all kinds of possibilities for you to get pleasure from the culture and people of Hawaii.
    Hawaii can be a stunning island and also the

  2. uahuf [url=http://beatbydreonlinesales.co.uk]beats by dre[/url] xazez http://beatbydreonlinesales.co.uk mttet [url=http://beatsbydrebestsales.co.uk]dr dre beats[/url] gvnot http://beatsbydrebestsales.co.uk xqcqx [url=http://beatsbydrecheapsales.co.uk]cheap beats by dre[/url] iltof http://beatsbydrecheapsales.co.uk golkm [url=http://drebeatsheadphonesforsale.com]cheap beats by dre[/url] qkwwm http://drebeatsheadphonesforsale.com qgolg [url=http://cheapbeatsbydreoutletforsales.com]beats by dr dre[/url] fvlcz http://cheapbeatsbydreoutletforsales.com uynml [url=http://monsterbeatsdreheadphoneoutlet.com]beats outlet[/url] jkcbd http://monsterbeatsdreheadphoneoutlet.com ccoz

  3. ueamn [url=http://beatbydreonlinesales.co.uk]beats by dre[/url] lieks http://beatbydreonlinesales.co.uk nbzvm [url=http://beatsbydrebestsales.co.uk]beats by dre[/url] ynpgu http://beatsbydrebestsales.co.uk camnz [url=http://beatsbydrecheapsales.co.uk]cheap beats by dre[/url] mxlgv http://beatsbydrecheapsales.co.uk euyaf [url=http://drebeatsheadphonesforsale.com]cheap beats by dre[/url] dulqy http://drebeatsheadphonesforsale.com jqlil [url=http://cheapbeatsbydreoutletforsales.com]beats by dr dre[/url] zzqxb http://cheapbeatsbydreoutletforsales.com eqjky [url=http://monsterbeatsdreheadphoneoutlet.com]cheap beats by dre[/url] wxzwz http://monsterbeatsdreheadphoneoutlet.com avsj

  4. ntfwa [url=http://beatbydreonlinesales.co.uk]beats by dre[/url] uslbd http://beatbydreonlinesales.co.uk lngds [url=http://beatsbydrebestsales.co.uk]by dre beats[/url] gscsb http://beatsbydrebestsales.co.uk mvvbd [url=http://beatsbydrecheapsales.co.uk]dr dre beats[/url] gtkzi http://beatsbydrecheapsales.co.uk dplsn [url=http://drebeatsheadphonesforsale.com]beats by dre[/url] aorcr http://drebeatsheadphonesforsale.com yopah [url=http://cheapbeatsbydreoutletforsales.com]beats by dr dre[/url] cfwsu http://cheapbeatsbydreoutletforsales.com vagwl [url=http://monsterbeatsdreheadphoneoutlet.com]cheap beats by dre[/url] yrnlt http://monsterbeatsdreheadphoneoutlet.com xgyl

Comments are closed.