Preventing Changes to Database Code
If you have added Microsoft Visual Basic for Applications (VBA) procedures to a database, you certainly don’t want users who aren’t qualified or authorized to make changes to your code. You can prevent unauthorized access in two ways: by protecting your VBA code with a password, or by saving the database as a Microsoft Database Executable (ACCDE) file. If you set a password for the code, it remains available for editing by anyone who knows the password. If you save the database as an ACCDE file, people using the database application can run your code, but they can’t view or edit it.
In this exercise, you will secure the VBA code in a database by assigning a password to it.
On the Database Tools tab, in the Macro group, click the Visual Basic button.
The Visual Basic Editor starts.
On the Tools menu, click base Properties.
The Project Properties dialog box opens.
On the Protection tab, select the Lock project for viewing check box.
In the Password box, type 2007!VbA, and then press the key.
Access disguises the characters of the password as asterisks as you type them, to protect against other people seeing your password.
In the Confirm Password box, type 2007!VbA, and then click OK.
The password is set, but you won’t have to enter it again until the next time you open the database and attempt to edit the VBA code.
Close the Visual Basic Editor, and then close the database.
Reopen the database, and then on the Database Tools tab, in the Macro group, click the Visual Basic button (or press ).
The Visual Basic Editor opens, displaying only the name of the project, and not the Code window.
Click the Expand button to the left of the Prevent database project.
The Password dialog box opens.
In the Password dialog box, type 2007!VbA, and then click OK.
The project expands to display its components.