Hack 77. Protect Programming Code from Curious Users
Your code is valuable. Add password protection to your modules. I think you'll agree that developed code is valuable, in terms of the time and expense it took to create it as well as what would be involved to recreate it. So, like any valuable asset, a little protection goes a long way. Of course, I would be remiss if I didn't mention that the first thing you should do is have a backup system in place. But even if you do have a back-up system, if the code in a production system gets trampled somehow, it still costs the company to take down the system to fix the code. Luckily, there is an easy way to protect your code. This hack prevents all but those who know the password from seeing your code. To add this protection, you must access the Tools
Figure 8-4. Accessing the project properties![]() On the Protection tab in the Project Properties dialog box, select the option to protect the project and establish a password. Enter a password, and click OK, as shown in Figure 8-5. Don't forget that passwords are case-sensitive. Figure 8-5. Protecting the project![]() You won't see any change until you close the database and then reopen it. When you go to the VB editor, the list in the Project window will be collapsed to the top level of the project itself. If you try to open the list (by clicking the plus sign), a box in which to enter the password will pop up, as shown in Figure 8-6. Figure 8-6. Requiring a password to see the code![]() This is as far as you can get without knowing the password. The protection actually helps in two ways: not only is the code protected from tampering, but also it is invisible. Therefore, your code is protected in terms of intellectual rights as well. If you developed some excellent routines that you hold dear, you can relax knowing that others can't even view them, much less copy them. |