Saturday, November 11, 2017

Save and reuse database design elements

Save and reuse database design elements

Access provides a variety of ways for you to reuse database design. You can save an entire database as a template, save part of a database as an application part, or save a field or set of fields as a data type template. In each case, Access creates a file that you can then share with others. Likewise, you can use such files from third parties.

This article discusses how to save various database objects as templates, in some cases including data. It also discusses the various template files, and how to share them. This article provides some details about the application parts that come with Access.

Note:  This article doesn't apply to Access apps – the new kind of database you design with Access and publish online. See Create an Access app for more information.

In this article

Overview

Saving and sharing database design elements for reuse

Save a database as a database template or an application part (*.accdt)

Save a field as a data type template (*.accft)

Reuse database design from a third party

Overview

Sometimes, you don't want to start over from scratch. When you spend a lot of time getting your design right, you want to make the most of it, such as by reusing it. Or, maybe you want to take advantage of design work already done by others. Access provides three main ways for you to reuse database design:

  • Database templates   are files (file type *.accdt) that you can use to create a new database. Typically, a database made from a template is ready to use, but you can customize it to meet specific needs. For example, the Assets web database template offers basic asset management capabilities, but you might want to extend it by adding some department or budget information that pertains to your organization. Access comes with a variety of database templates, which you can see in Backstage view when Access opens.

  • Application parts   are files just like database templates, but you use them to add design elements to an existing database, rather than to serve as the basis for a new database. For example, the Comments application part provides a table that is set up to contain comments, including a date/time field. Some application parts start a wizard to help you create a relationship to define how the application part fits in with your existing tables. Access comes with several application parts, which you can see on the Create tab.

  • Data type templates   are files that you can use to create new fields and field combinations. For example, you can use the Start and End Dates data type templates to add a pair of date/time fields to a table with one click. Data type templates use a different file type (*.accft) from database templates and application parts. Access comes with a variety of data type templates, which you can see on the Fields tab when you have a table open in Datasheet view.

Saving and sharing database design elements for reuse

Create a database template or application part   Save a database as an *.accdt file by using commands on the File tab. (For the steps, see the section Save a database as a database template or an application part (*.accdt).) You can then use the template to create a new database or, if it is an application part, add its features to an existing database.

Database templates and application parts that you create are stored by default in your roaming application data templates folder (in Windows 7, C:\Users\<username>\AppData\Roaming\Microsoft\Templates\Access\). You can put template files in this folder to make them available as database templates or application parts. Likewise, you can copy template files from this folder and give them to others for their own use.

Note:  As always, exercise caution when using files from third parties.

Create a data type template   Save a selection of table fields as an *.accft file by using a command on the Fields tab. (For steps, see the section Save a field as a data type template (*.accft).)

Data type templates that you create are stored by default in your roaming application data templates folder (in Windows 7, C:\Users\<username>\AppData\Roaming\Microsoft\Templates\Access\). You can put data type template files in this folder to make them available as data types for new fields. Likewise, you can copy template files from this folder and give them to others for their own use.

Note:  As always, exercise caution when using files from third parties.

Top of Page

Save a database as a database template or an application part (*.accdt)

You save a database as a database template or application part by using commands on the Save & Publish tab in Backstage view.

  1. On the File tab, click Save & Publish.

  2. Under Save Database As, click Template.

  3. In the Create New Template from This Database dialog box, specify the following fields:

    • Name   Required. Enter text that will identify the template or application part. Access displays this name alongside the template or application part.

    • Description   Enter text that describes the contents or purpose of the template or application part. This appears in the tooltip for the template or application part.

    • Category   Select User Templates to have the application part show up under User Templates on the ribbon (the default). You can also add a category by typing it, and you can then assign this and future application parts to that category. The new category will show up in the ribbon.

    • Icon   Specify an icon to display for the template or application part. For application parts, this icon will show up in the application parts gallery on the ribbon.

    • Preview   Specify a larger image to display for the template in Backstage view. When you browse for a template, this image is what you will see for this template.

    • Primary Table   Specify a table that will be the primary table for the application part. This table will be used by default to relate the application part to other tables in a database to which the part is added. When someone uses the application part, Access starts a wizard to help create the relationship. Although the Primary Table is used by default, you can select a different table when the wizard runs.

    • Instantiation Form   Specify a form that will open by default when databases made from this template are first opened. This form by default only opens once. The form can contain code that it runs when it opens, but the presence of code will generate a security warning.

    • Application Part   Select this checkbox to save the database as an application part. Clear this check box to save the database as a database template.

      Note:  You must select this check box before you can specify a value for Primary Table.

    • Include Data in Template   Select this check box to save the data that is in the database as part of the template. When new databases are created from the template, they include this data.

  4. Click OK to save your template. By default, Access saves your template to C:\Users\<current user>\AppData\Roaming\Microsoft\Templates\Access\.

Save a field as a data type template (*.accft)

To create a data type template, you select a field or combination of fields, and then use a command on the ribbon to save them as a template. Make sure that the field or fields are set up the way that you want them before you start – set any properties that you want to be preserved as part of the data type template. For example, if you want to create a "euro" data type template, you might create a currency field, and then set its Format to Euro.

  1. Open the table that has the fields or fields that you want to save as a template.

  2. Select the field or fields that you want to save for reuse.

  3. On the Fields tab, in the Add & Delete group, click More Fields, and then click Save Selection as New Data Type.

  4. In the Create New Data Type from Fields dialog box, specify the following:

    • Name   Required. It identifies your data type template, and is displayed in the list of available fields when you choose a field from the More Fields list.

    • Description   Enter text that describes the contents or purpose of the data type template. This appears in the tooltip that is displayed when you hover over the data type template in the More Fields list.

    • Category   Select a category in which to list the data type template in the More Fields list. By default, the category is User Defined Types.

    • Instantiation form   If desired, specify a form that will open by default the first time that the data type template is used.

  5. Click OK to save your data type template.

Top of Page

Reuse database design from a third party

You can make a database template or an application part from a third party available on the ribbon by putting a copy of the .accdt file into the appropriate folder on your computer.

  1. Obtain the template file (it should have an .accdt or an .accft file extension).

  2. Put a copy of the file in <System Root>Users\<current user>\AppData\Roaming\Microsoft\Templates\Access\, where:

    • <System Root> is the root folder of your Windows installation (usually C:\), and

    • <current user> is the user name that you used to log in to Windows.

      Note:  If the folder does not yet exist, create it.

  3. Do one of the following:

    • To use a database template, on the File tab, click New, click My Templates, click the template that you want, and then click Create.

    • To use an application part, open the database to which you want to add the part, and then on the Create tab, click Application Parts, and then click the part that you want.

    • To use a data type template, open the table in which you want to create a field, and then on the Fields tab, in the Add & Delete group, click More Fields, and then click the data type template that you want.

Top of Page

No comments:

Post a Comment