Password Protect MS Access VBA Code
Return to FAQsMany MS Access developers have asked if it is possible to password protect the VBA code in an Access database they have developed, without password protecting entire database. The answer is yes!
To password protect the VBA Code in an MS Access Database:
- Open the MS Access VBA editor (You can press ALT+F11 to open the editor)
- On the Tools menu, select <Database Name> Properties
- On the Protection tab, select the ‘Lock project’ for viewing check box. Enter and confirm a password (Make sure to note down the password somewhere securely)
- Click the OK button, and then close and reopen the database.
When you next go to to view the VBA code, you will be prompted for the password.
You should be aware that there are tools and methods that can be used to remove VBA passwords, so protecting your VBA by using this procedure should not be considered a fool-proof security method. However, it is a very good way to keep most people from accessing or accidentally changing the code.
A more robust method to protect your VBA code, and indeed your entire database, is to compile the database to an .accde or .mde file format. For more information on protecting the VBA code in your database or information on converting your database to a compiled format we recommend you read this Microsoft Office.com article.