Creating a Default Template for New Databases






Creating a Default Template for New Databases

Access 2007 introduces a new feature that allows you to create your own default database template for use with all new blank databases. Rather than set options for each new database after you create it, you can set your preferred options only one time and have those settings apply to each new database. To accomplish this, you first need to open a new blank database from the Getting Started screen. Click the Blank Database command on the Getting Started screen to display the Blank Database task pane on the right, as shown in Figure–36.

Image from book
Figure–36: The Blank Database task pane appears on the right when you click the Blank Database command.

You must name this new database Blank in order for this procedure to work. Type Blank in the File Name text box, and then click the Browse button to open the File New Database dialog box. So that Access 2007 will use this template file for all new databases, you must place this file in a specific subfolder in the Microsoft Office folder. Navigate to the following folder on your system drive by clicking the folder icons in the left pane of the File New Database dialog box: \Program Files\Microsoft Office\Templates\1033\ Access, as shown in Figure–37. This file path assumes a default installation of the 2007 Microsoft Office system, so your exact file path might be different if you chose a custom installation and selected a different installation path.

Image from book
Figure–37: Save the Blank.accdb file in the correct subfolder in the Microsoft Office folder.

Click OK in the File New Database dialog box to return to the Getting Started screen. If you followed the preceding instructions, the Blank Database task pane on the right should look like Figure–38. The File Name text box says Image from book Blank.accdb, and the path to the correct template location is displayed above the Create button.

Image from book
Figure–38: After you enter the correct name and select the correct location, you’re ready to create your new database template.

Caution 

If you are using Microsoft Windows Vista, you might not be able to save the Image from book Blank.accdb database into the needed template folder. Windows Vista uses User Account Control, which protects critical program folders. If your computer is connected to a domain, you get a prompt dialog box and then you can save to the correct folder. You might need to temporarily turn off User Account Control in order to save the database into the template folder. If you are in a corporate network environment, you should ask your system administrator for assistance with this procedure.

Click the Create button, and Access 2007 creates the new file and saves it in the appropriate template folder. By default, Access opens up a new blank table called Table1. You do not need this table, so close it and do not save it.

Now that you have an empty database with no objects, open the Access Options dialog box by clicking the Microsoft Office Button and then Access Options. Select all the options you want to set for any new databases in the various categories of the Access Options dialog box.

Image from book Included on the companion CD is a database called Image from book Blank.accdb that has the Access Options settings that we recommend for new databases. In the Current Database category, in the Name AutoCorrect Options section, we cleared the Track Name AutoCorrect Info check box. In the General section of the Advanced category, we selected the Use Four-Digit Year Formatting and This Database check boxes. We left all other options set to the defaults.

Note 

You can also open the Visual Basic Editor (VBE) and select Options from the Tools menu to select options that apply to Visual Basic in all new databases. In the Image from book Blank.accdb sample database, we selected the Require Variable Declaration check box.

After you have defined all the settings you want, close the database and exit Access 2007. Each new blank database you create from the Getting Started screen will now include all the settings you selected for the Image from book Blank.accdb file. To make revisions to those settings, open the Image from book Blank.accdb file in the template folder and make whatever modifications are necessary. Figure–39 shows our Image from book Blank.accdb file in the appropriate template folder along with the other local database templates discussed at the beginning of this chapter.

Image from book
Figure–39: The Blank.accdb file must be located in the same folder as the local database templates.

Creating a custom blank database template saves you time by not having to continually set your personal Access options and VBE options each time you create a new database. In addition to this timesaver, you can also include specific code modules, forms, and any other database objects with new databases. If, for example, you have some common functions and procedures stored in standard code modules that you use in all your database files, you can include them in this Image from book Blank.accdb file. Instead of having to manually import these modules into all new databases, Access does all the work for you by including them in new databases.



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