Hide VBA code from users

If your database contains Visual Basic for Applications (VBA) code, you can hide that code by saving your Microsoft Office Access database in the .accde file format. Saving a database as an .accde file compiles all VBA code modules, removes all editable source code, and compacts the destination database. Your VBA code retains its functionality, but the code cannot be viewed or edited. In general, the database will continue to function as usual — you can still update data and run reports.

In this article

Create an .accde file

Functionality that is changed in an .accde file

Issues with modifying forms, reports, or modules

Restrictions on saving a database as an .accde file

How references work with .accde files

Create an .accde file

Use the following procedure to create an .accde file. This procedure leaves the original .accdb file unmodified.

  1. On the Database Tools tab, in the Database Tools group, click Make ACCDE.

  2. In the Save As dialog box, browse to the location where you want to save the .accde file.

  3. Optionally, type a new name for the file in the File name box.

  4. Click Save.

    If a file by the name that you specify already exists, Access prompts you to replace the existing file. Click Yes to overwrite the existing .accde file, or click No to return to the Save As dialog box and type a new file name.

Access creates the .accde file, closes the original .accdb file, and then opens the .accde file.

Top of Page

Functionality that is changed in an .accde file

Saving your Access database as an .accde file does not completely prevent changes to the database design. However, the following tasks cannot be performed in an .accde file:

  • Modifying or creating forms, reports, or modules.

  • Using the VBA References dialog box to add, delete, or change references to object libraries or databases.

  • Viewing or modifying the VBA code.

  • Importing or exporting Access forms, reports, or modules. However, tables, queries, and macros can be imported from or exported to .accdb databases.

Top of Page

Issues with modifying forms, reports, or modules

Be sure to keep a copy of your original Access database. If you want to modify the design of forms, reports, or modules in an .accde file, you must modify the original Access database (the .accdb file), and then save it again as an .accde file. Saving an Access database that contains tables as an .accde file can lead to problems with reconciling different versions of the data if you later want to modify the design of the forms, reports, or modules. For this reason, saving an Access database as an .accde file is most appropriate for the front-end database of a front-end/back-end application.

Top of Page

Restrictions on saving a database as an .accde file

Some restrictions can prevent you from saving your Access database as an .accde file:

  • You must have password access to the VBA code.

  • If your Access database references another Access database or an add-in, you must save all Access databases or add-ins in the chain of references as .accde files.

If you encrypt a database with a password before you save it as an .accde file, the .accde file will also be encrypted, and you will have to enter the password every time that you open it. If you do not want the .accde file to be encrypted, you must decrypt the .accdb file before saving it as an .accde file. After you save the database as an .accde file, you can encrypt the .accdb file again. Use the following procedure to decrypt an .accdb file:

  1. On the Database Tools tab, in the Database Tools group, click Decrypt Database.

  2. In the Unset Database Password dialog box, in the Password box, type the database password.

  3. Click OK.

Top of Page

How references work with .accde files

If you try to create an .accde file from an Access 2007 database (.accdb) or from an Access 2007 add-in (.accda) that references another Access database or add-in, Access 2007 displays an error message and does not let you complete the operation. To save a database that references another database as an .accde file, you must save all databases in the chain of references as .accde files, starting from the first database referenced. After saving the first database as an .accde file, you must then update the reference in the next database to point to the new .accde file before saving it as an .accde file, and so on.

For example, suppose that Database1.accdb references Database2.accdb, and Database2.accdb references Database3.accda. To save Database1.accdb as an .accde file, do the following:

  1. Save Database3.accda as Database3.accde.

  2. Open Database 2.accdb, and change its reference to point to the new file named Database3.accde.

  3. Save Database2.accdb as Database2.accde.

  4. Open Database1.accdb, and change its reference to point to the new file named Database2.accde.

  5. Save Database1.accdb as Database1.accde.

Top of Page

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×