CHAPTER 16

Database Basics

Understanding Database Basics

Access is a popular database program that you can use to catalog and manage large amounts of data. You can use Access to manage anything from a simple table of data to large, multifaceted collections of information. For example, you might use Access to maintain a list of your clients or a catalog of products you sell.

If you are new to Access, you should take a moment and familiarize yourself with the basic terms associated with the program, such as database, table, record, field, form, report, and query. This section contains definitions of all these key terms.

Databases

Snapshot of databases.

Simply defined, a database is a collection of related information. You may not be aware, but you use databases every day. Common databases include the list of movies and TV shows offered by a streaming media service or a sports league’s schedule of upcoming games. A company database might include a list for each aspect of the business, including product categories, customers, employees, orders, products, shippers, and suppliers.

Tables

Snapshot of tables.

The heart of any Access database is a table. A table is a list of information organized into columns and rows. In the example of a company database, the employees table might list the first name, last name, job title, address, phone number, and e-mail address of each person who works for the company. You can have numerous tables in your Access database. For example, you might have one table listing customer information and another table listing your company’s products.

Records and Fields

Snapshot of records and fields.

Every entry that you make in an Access table is called a record. Records always appear as rows in a database table. Every record consists of fields, which are the separate pieces of information that make up each record. Each field of a record appears in a separate column. For example, in a company employee table, each record (row) might include fields (columns) for first name, last name, title, address, city, postal code, phone number, and e-mail address. Field names appear at the top of each column.

Forms

Snapshot of forms.

You can enter your database records directly into an Access table, or you can simplify the process by using a form. Access forms present your table fields in an easy-to-read, fill-in-the-blank format. Forms enable you to enter records one at a time. Forms are a great way to ensure consistent data entry, particularly if other users are adding information to your database table.

Reports and Queries

Snapshot of report and queries.

You can use the report feature to summarize data in your tables and generate printouts of pertinent information, such as your top ten salespeople and your top-selling products. You can use queries to sort and filter your data. For example, you can choose to view only a few of your table fields and filter them to match certain criteria.

Plan a Database

The first step to building an Access database is deciding what sort of data you want it to contain. What sorts of actions do you want to perform on your data? How do you want to organize it? How many tables of data do you need? What types of fields do you need for your records? What sort of reports and queries do you hope to create? Consider sketching out on paper how you want to group the information into tables and how the tables will relate to each other. Planning your database in advance can save you time when you build the database file.

Create a Database Based on a Template

You can build web apps — a kind of database designed with Access and published online — or desktop databases based on any of the predefined Access templates. For example, you can create databases to track contact lists, assets, and task management. You can also search Office.com to find new, featured templates. This book focuses on building desktop databases.

When you create a new database using a template, the database includes prebuilt tables and forms, which you populate with your own data. You control the structure of your database by modifying or eliminating preset tables and fields and adding database content such as tables, forms, and reports.

Create a Database Based on a Template

Snapshot of database on template.

001.eps Start Access.

002.eps Click New.

Note: You can also create a new database from within Access; click the File tab and then click New.

dga.eps On the New screen, templates appear.

dgb.eps You can search for additional templates online by typing keywords here.

Note: To get Microsoft’s Northwind sample database, type Northwind in the search field and press Ent.

003.eps Click a template.

Snapshot of displaying the
template information.

A window appears, displaying the template information.

dgc.eps To view the previous or next template, click these arrows (9781119893516-ma038 and 9781119893516-ma037).

004.eps Type a new name in the File Name field.

005.eps To change the folder in which you store the database file, click the Open file button (9781119893516-ma078).

Note: If you are satisfied with the folder Access suggests, skip to step 8.

Snapshot of database dialog box
appears.

The File New Database dialog box appears.

006.eps Locate and select the folder in which you want to store the database file.

007.eps Click OK.

008.eps Click Create.

Snapshot of security warning appears.

dgd.eps Access downloads the template and creates a new blank database, ready for data.

dge.eps A security warning appears.

009.eps To hide the warning and enable the macros in this template, click Enable Content.

Create a Blank Database

If you determine that none of the predesigned database templates suits your purposes, you can create a new blank database and then decide on the tables, forms, and other objects your database will include. Creating a blank database is the way to go if you find that the predesigned templates that Access offers are too complicated for your needs. Creating a database from scratch is also the better choice when you know exactly what data you want to store and have a good idea of what tables, forms, and reports you will need.

Create a Blank Database

Snapshot of create a blank database.

001.eps Start Access.

Note: You can also create a new blank database from within Access; click the File tab and then click New.

002.eps Click Blank database.

Snapshot of displaying
the template information.

A window appears, displaying the template information.

003.eps Type a new name in the File Name field.

004.eps To change the folder in which you store the database file, click the Open file button (9781119893516-ma078).

Note: If you are satisfied with the folder Access suggests, skip to step 7.

Snapshot of file new database dialog box
appears.

The File New Database dialog box appears.

005.eps Locate and select the folder in which you want to store the database file.

006.eps Click OK.

007.eps Click Create.

Snapshot of creates a new table
named Table1.

dga.eps Access creates a new blank database and creates a new table named Table1, ready for data.

Create a New Table

Access databases store all data in tables. A table is a list of information organized into columns and rows. A table might list the names, addresses, phone numbers, company names, titles, and e-mail addresses of your clients. Each row in a table is considered a record. You use columns to hold fields, which are the individual units of information contained within a record.

If you need to add a table to a database, you can easily do so. All table objects that you create appear listed in the Navigation pane; double-click a table object to open it.

Create a New Table

Snapshot of create a new table.

001.eps With your database open in Access, click the Create tab.

002.eps Click Table.

Snapshot of new table created.

dga.eps Access creates a new table and displays it in Datasheet view.

Note: See the next section, “Change Table Views,” to learn more about Datasheet view.

003.eps Click the Click to Add link at the top of the field column.

004.eps Click the type of field you want to add.

In this example, a Short Text field is added.

Snapshot of Access prompts you to save the
table changes.

005.eps Type a name for the field and press Ent.

006.eps Repeat steps 3 to 5 to create more fields for the table.

007.eps When you are finished adding fields, close the table by clicking the Close button (9781119893516-ma005).

Access prompts you to save the table changes.

008.eps Click Yes.

Snapshot of Save As dialog box appears.

The Save As dialog box appears.

009.eps Type a name for the table.

010.eps Click OK.

Access lists the table among the database objects in the Navigation pane.

Note: After you save a table, you can reopen it by double-clicking it in the Navigation pane.

Change Table Views

You can view your table data using two different view modes: Datasheet view and Design view. In Datasheet view, the table appears as an ordinary grid of intersecting columns and rows where you can enter data. In Design view, you can view the underlying structure of your fields and their properties and modify the design of the table.

In either view, you can add fields by typing new field names in the final (blank) column or change the field names. In Design view, you can also change the type of data allowed within a field, such as text or number data.

Change Table Views

Snapshot of design view.

Switch to Design View

001.eps Open any table by double-clicking it in the Navigation pane.

Access displays the table in the default Datasheet view.

002.eps Click Home.

003.eps Click the bottom half of the View button.

004.eps Click Design View.

Note: You can quickly switch from Datasheet view to Design view by clicking the top half of the View button.

Snapshot of access to design view.

dga.eps Access displays the table in Design view.

dgb.eps The bottom of the view displays the properties of the field you select in the top of the view.

dgc.eps Access displays the Table Design contextual tab.

Snapshot of datasheet view.

Switch to Datasheet View

001.eps Click Home.

002.eps Click the bottom half of the View button.

003.eps Click Datasheet View.

Note: You can quickly switch from Design view to Datasheet view by clicking the top half of the View button.

Snapshot of datasheet view of table.

dgd.eps Access displays the default Datasheet view of the table.

Add a Field to a Table

You can add fields to your table to include more information in your records. For example, you may need to add a separate field to an Employees table for e-mail addresses. Or you may need to add a field to a table that contains a catalog of products to track each product’s availability.

After you add a field, you can name it whatever you want. To name a field, double-click the field label in Datasheet view, type a new name, and press Ent. Alternatively, you can change the field name in Design view.

Add a Field to a Table

Snapshot of field to a table.

001.eps Double-click to open the table to which you want to add a field in Datasheet view.

002.eps Click the column heading to the left of where you want to insert a new field.

Note: Access adds the column for the new field to the right of the column you select.

003.eps Click Table Fields.

004.eps In the Add & Delete group, click the button for the type of field you want to add.

In this example, a Short Text field is added.

Snapshot of name for the new field.

dga.eps Access adds the new field to the right of the column you selected in step 2.

005.eps Type a name for the new field and press Ent.

Delete a Field from a Table

You can delete a field that you no longer need in a table. For example, if your employee contact information database contains a Pager Number field, you might opt to delete that field.

When you remove a field, Access permanently removes any data contained within the field for every record in the table. If you do not want to delete the information in the field, you might choose to hide the field. For information, see the next section, “Hide a Field in a Table.”

Delete a Field from a Table

Snapshot of delete a field from table.

001.eps Double-click to open the table that you want to edit in Datasheet view.

002.eps Click the column header for the field you want to remove.

dga.eps Access selects the entire column.

003.eps Click Table Fields.

004.eps Click Delete.

Access prompts you to confirm the deletion.

005.eps Click Yes.

Note: You might also see a message warning you that deleting the field will also delete an index; click Yes.

Snapshot of access removes field and any
record content for the field from the table.

dgb.eps Access removes the field and any record content for the field from the table.

Hide a Field in a Table

You can hide a table field that you do not want to view regularly but that you do not want to delete from the table. For example, a table containing a catalog of products might include a field indicating the name of the supplier from which your company obtains the product — information that you might need to view only occasionally. You also might hide a field to prevent another user on your computer from seeing the field. Whatever the reason, you can hide the field. When you are ready to view the field again, you can unhide it.

Hide a Field in a Table

Snapshot of hide field.

001.eps Double-click the table that you want to edit to open it in Datasheet view.

002.eps Right-click the column heading of the field you want to hide.

003.eps Click Hide Fields.

Snapshot of access hides the field.

dga.eps Access hides the field.

Note: To view the field again, right-click any column heading and click Unhide Fields. In the Unhide Columns dialog box that appears, select the column that you want to display again (9781119893516-ma001 changes to 9781119893516-ma002) and click Close. Access displays the field in the table.

Move a Field in a Table

You can change the order of fields in a table. Moving fields is particularly useful if you built your database from a predesigned template, because you may find that the order in which fields appear in the table does not suit your needs.

It is important to understand that moving a field changes its position in Datasheet view but does not change the order of the fields in the table design. If you create a form after re-ordering fields, the form fields appear in their original position.

Move a Field in a Table

Snapshot of move a field.

001.eps Double-click the table that you want to edit to open it in Datasheet view.

002.eps Click the column heading of the field you want to move.

dga.eps Access selects the entire column.

003.eps Drag the column to a new position in the table (9781119893516-ma030 changes to 9781119893516-ma031).

dgb.eps A bold vertical line marks the new location of the column as you drag.

004.eps Release the mouse button.

Snapshot of access moves the field to a new region.

dgc.eps Access moves the field to the new location.

Create a Form

Although you can enter data into your database by typing it directly into an Access table, you can simplify data entry, especially if someone else will be entering the data, by creating a form based on your table. Forms present your table fields in an easy-to-read, fill-in-the-blank format. When you create a form based on a table, Access inserts fields into the form for each field in the table.

Using forms is a great way to help ensure accurate data entry, particularly if other users are adding information to your database.

Create a Form

Snapshot of create a form.

001.eps Double-click the table that you want to edit to open it in Datasheet view.

002.eps Click Create.

003.eps Click Form.

Snapshot of access creates a form.

dga.eps Access creates the form.

004.eps Click the Close button (9781119893516-ma005) to close the form.

Snapshot of access prompts you to save your changes.

Access prompts you to save your changes.

005.eps Click Yes.

Snapshot of Save As dialog box appears.

The Save As dialog box appears.

006.eps Type a name for the form.

007.eps Click OK.

Access lists the form among the database objects in the Navigation pane.

Note: After you save a form, you can reopen it by double-clicking it in the Navigation pane.

Change Form Views

You can view your form using three form views: Form view, Design view, and Layout view. Form view is the default; in this view, you can enter data. In Design view, each form object appears as a separate, editable element. For example, in Design view, you can edit both the box that contains the data and the label that identifies the data. In Layout view, you can rearrange the form controls and adjust their sizes directly on the form. Access makes it easy to switch from Form view to Design view to Layout view and back.

Change Form Views

Snapshot of design view.

Switch to Design View

001.eps Double-click the form that you want to edit to open it in Form view.

002.eps Click Home.

003.eps Click the bottom half of the View button.

004.eps Click Design View.

dga.eps Access displays the form in Design view.

Snapshot of access displays the form in
Design view.

Switch to Layout View

001.eps Click Home.

002.eps Click the bottom half of the View button.

003.eps Click Layout View.

dgb.eps Access displays the form in Layout view.

dgc.eps To return to Form view, you can click the bottom half of the View button and then click Form View.

Move a Field in a Form

You can move a field to another location on your form. For example, you might move a field to accommodate the order in which data is entered in the form. To easily move both a field label and the field contents, select both at the same time.

Although you can move a field in either Design view or Layout view, you might find it easier to make changes to your form in Layout view.

Move a Field in a Form

Snapshot of move a field in form.

001.eps Double-click the form that you want to edit to open it in Form view.

002.eps Switch to Layout view (see the previous section “Change Form Views” for details).

003.eps Click the label of the field that you want to move (9781119893516-ma030 changes to 9781119893516-ma009).

004.eps Press and hold Ctrl as you click the contents of the field.

005.eps Click and drag the field label and contents to the new location on the form.

dga.eps This symbol (a pink line) identifies the proposed position of the field label and contents.

Snapshot of Click anywhere outside the field
label and contents to deselect
them.

dgb.eps When you release the mouse button, Access repositions the field.

006.eps Click anywhere outside the field label and contents to deselect them.

Delete a Field in a Form

You can delete a field that you no longer need in a form. When you remove a field, you need to remove both the data box and the field label. Although you can delete a field in Design view or in Layout view, you might find it easier to do this in Layout view.

Note that removing a form field does not remove the field from the table upon which the form is originally based or any of the data within that field; it only removes the field from the form.

Delete a Field in a Form

Snapshot of delete a field in a form.

001.eps Double-click the form that you want to edit to open it in Form view.

002.eps Switch to Layout view (see the section “Change Form Views,” earlier in this chapter, for details).

003.eps Click the label of the field that you want to delete (9781119893516-ma030 changes to 9781119893516-ma009).

004.eps Press and hold Ctrl as you click the contents of the field.

005.eps Click Home.

006.eps Click Delete.

Note: You can also delete the selected items by pressing Delete.

Snapshot of access removes the field and label
from the form.

dga.eps Access removes the field and label from the form.

Format Form Fields

To change the look of a form, you can apply formatting to fields in the form. You might format a form field to draw attention to it in order to make it easier to locate that field for data-entry purposes. Or, you might opt to change the font of all field labels, make them larger, and change their color to make them stand out on the form for those who enter data.

You can apply the same types of formatting to form fields that you apply to words in Word documents, PowerPoint presentations, Outlook messages, and Excel cells.

Format Form Fields

Snapshot of format form fields.

001.eps Double-click the form that you want to edit to open it in Form view.

002.eps Switch to Layout view (see the section “Change Form Views,” earlier in this chapter, for details).

003.eps Click to select the field whose text you want to format.

dga.eps To select multiple fields, you can press and hold Ctrl as you click additional fields.

004.eps Click the Format tab.

005.eps Use these tools to format the fields:

Click the Font 9781119893516-ma135 and choose a font.

Click the Font Size 9781119893516-ma135 and choose a font size.

Click to the right of the Font Color button (9781119893516-ma047) and choose a color for text.

Click to the right of the Background Color button (9781119893516-ma109) and choose a background color.

Snapshot of access formats the text in the selected
fields.

dgb.eps Access formats the text in the selected fields.

006.eps Click anywhere outside the selected fields to deselect them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.43.26