Preventing Changes to Database Code





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.

See Also

For information about saving a database as an executable file, see "Securing a Database for Distribution" later in this chapter.


In this exercise, you will secure the VBA code in a database by assigning a password to it.

USE the 02_Prevent database. This practice file is located in the Chapter10 subfolder under SBS_Access2007.

BE SURE TO start Access before beginning this exercise.

OPEN the 02_Prevent database.


1.
On the Database Tools tab, in the Macro group, click the Visual Basic button.

The Visual Basic Editor starts.

2.
On the Tools menu, click base Properties.

The Project Properties dialog box opens.

3.
On the Protection tab, select the Lock project for viewing check box.

4.
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.

Tip

The Lock and Password settings operate independently. Selecting the Lock Project For Viewing check box requires the user to enter the password to view the project. If a password has been set and the Lock Project For Viewing check box is not selected, the user can view the project code but has to enter the password to open the Project Properties dialog box.

5.
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.

6.
Close the Visual Basic Editor, and then close the database.

7.
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.

8.
Click the Expand button to the left of the 02_Prevent database project.

Expand

The Password dialog box opens.

9.
In the Password dialog box, type 2007!VbA, and then click OK.

The project expands to display its components.

Tip

You need to enter the password only once per database session. In other words, you won't have to enter it again unless you close and reopen the database.

CLOSE the 02_Prevent database.


Tip

To remove the password, on the Visual Basic Editor Tools menu, click Base Properties. On the Protection tab, clear the Lock Project For Viewing check box, delete the asterisks from the two password boxes, and then click OK.




 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows