Monday, September 17, 2018

HOW TO ENCRYPT AND DECRYPT YOUR DATABASE (PASSWORDS)

Password-protecting your database project guards against threats well known to you such as theft of the database or its objects such as tables, queries and forms by importation/exportation.

To encrypt or decrypt a Microsoft Access database you need to open it in exclusive mode.

WARNING: I recommend that you use a copy of your database in doing this as there is no remedy if you forget your password.

Encrypting your database

1.      Launch Microsoft Access
2.      Go to file and click on open as shown below

3.      Navigate to your database file’s location and select it. Click on the arrow next to the OPEN command to see the options such as Open, Open Read Only etc. Select Open Exclusive. The database will now open in exclusive mode.

4.      To encrypt the database, go to file and click on encrypt with password. The following window will appear. Enter your desired memorable password, verify it and click on OK.


5.      You may see this error message. Just click on OK. Your database is now encrypted. To open it you’ll need to enter the password.

Decrypting your database.

Immediately after encrypting your database, you can decrypt it because it is still open in exclusive mode. Otherwise, the steps to take are as follows.
1.      Launch Microsoft Access and open your database in exclusive mode (already explained above)
2.      Go to file and click on Decrypt Database as shown below.

3.      In this window enter your password and click ok. Your database is now decrypted. 

Encrypting your VBA code.

Your VBA code doesn’t have to be complex to necessitate encryption. Somewhere on this blog, there is a tutorial on how to add a real-time clock on your forms that uses a simple line of VBA code. There are many other simple ones out there that aid in simple functions such as opening your form to new record. Protecting your VBA code guards against exportation of your well-designed forms among other objects from your database therefore providing additional security. To the steps now:
1.      Open your database (you don’t have to open it in exclusive mode)
2.      Click on database tools on the ribbon and click on Visual Basic

3.      The Visual Basic Editor window will open as shown below. The DB I used for this blog post does not have code and that is why there are no objects.

4.      Click on tools > [your database name] properties to open the window below

5.      Enter your memorable password, confirm it, tick Lock Project for viewing and click ok.

6.      Now go to file > save. Your VBA code is now protected and you’ll need to enter the password whenever you need to edit the code.