O'Reilly logo

Access 2003 VBA Programmer's Reference by Armen Stein, Graham Seach, Teresa Hennig, Patricia Cardoza

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

16.4. Secure VBA Code

There are many reasons to protect your Microsoft Visual Basic for Application (VBA) code. You may wish to prevent persons who are not experienced with the design of the code from introducing errors. You may also wish to conceal your intellectual property by preventing anyone from viewing the code. Or, you may want to ensure consistent application of business rules by preventing unauthorized changes. And, of course, there is the concern about hackers. Access provides two primary methods for protecting the code: securing a project and making an MDE file.

16.4.1. Securing Modules by Securing the Project

You can secure Visual Basic code from viewing or editing by locking the project from viewing and setting a password on your project. You set the project password while viewing the project in the Visual Basic Editor (VBE). When a project has a password and is locked for viewing, the password must be entered in the VBE before the Visual Basic code can be opened. The password is requested only once for each time that database is opened, and it is only requested if there is an attempt to access the code using the VBE.

Setting a password and locking the project from viewing also prevents changing the HAS Module property on forms and reports until the password has not been entered in the VBE. This is because Access needs to open the code before it can delete it, or add to it.

Setting a password and locking the project from viewing does not prevent users from changing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required