Secure Visual Basic for Applications code in Access projects
You can protect the Visual Basic for Applications (VBA) code in your Microsoft Access project (.adp) by using a password or by saving a copy of your file as an .ade file. Saving your .adp file as an .ade file is more secure than password protecting your code. However, there are some limitations in using an .ade file.
Protect Visual Basic for Applications code with a password
To prevent someone from viewing or making changes to your Microsoft Visual Basic for Applications (VBA) code, you can protect the code by requiring a password.
- Open the Microsoft Access project (.adp) file or Microsoft Access database (.mdb) file that has the VBA code you want to protect.
- In the Database window, point to Macro on the Tools menu, and then click Visual Basic Editor.
Tip
You can also press ALT+F11.
- In the Microsoft Visual Basic Editor, click <Access database or Access project name> Project Properties on the Tools menu.
- On the Protection tab, select the Lock project for viewing check box. If you set a password but don't select Lock project for viewing, the code can be viewed and edited by anyone, but the Project Properties dialog box is protected.
- In the Password box, type your password.
Guidelines for passwords
User names can range from 1 to 20 characters, and can include letters, accented characters, numbers, spaces, and symbols, with the following exceptions:
- The characters " \ [ ] : | < > + = ; , . ? *
- Leading spaces
- Control characters (ASCII 10 through ASCII 31)
Note Passwords are case-sensitive.
- In the Confirm password box, confirm your password by typing the password again, and then click OK.
The password is now set. The next time you or any other user opens the database, a dialog box will be displayed that requests a password.
Important If you forget your password, it can't be recovered, and you won't be able to view or edit the VBA code.
Make an ADE file
Cautions
Be sure to save a copy of your original Microsoft Access project (.adp) file.
- You can't modify the design of forms, reports, or modules in an Access project file saved as an .ade file. If you need to change the design of these objects, you must do so in the original Access project file and then resave the Access project file as an .ade file.
- You can't create an .ade file in Access 2002 from an Access project file created in an earlier version. You can only save an .ade file from an Access project file from the same version of Access.
- You also won't be able to convert an Access project file saved as an .ade file in future versions of Microsoft Access. You will be able to run the .ade file in a later version of Access.
- Close the Access project file. If you are working in a multiuser environment, make sure that all other users have closed the Access project file.
- On the Tools menu, click Database Utilities, and then click Make ADE File.
- In the Database To Save As ADE dialog box, specify the Access project file you want to save as an .ade file, and then click Make ADE.
- In the Save ADE As dialog box, specify a name, drive, and folder for the Access project.