Creating a Form by Using the Form Tool


Before you begin creating a form, you need to know which database query or table to base it on, and have an idea of how the form will be used. After making these decisions, you can create a form in many ways. Remember that like almost any other object in Access, after you create the form, you can customize it in Design view if it does not quite meet your needs.

The quickest way is to select a table or query in the Navigation Pane, and then click the Form button in the Forms group on the Create tab. This creates a simple form using all the fields in the table or query, and opens it in Layout view.

If there is one (and only one) other table in the database that has a one-to-many relationship with the table on which your form is based, then the Form tool adds a datasheet (called a subform) which displays all the records in the related table that pertain to the current record in the main form.

In this exercise, you will use the Form tool to create a form based on a table.

Use the 01_CreateFormTool database. This practice file is located in the Chapter10 subfolder under SBS_Office2007.

Be Sure To start Access before beginning this exercise.

Open the 01_CreateFormTool database.

1. In the Navigation Pane, under Tables, double-click Customers.

The Customers table opens in Datasheet view.

image from book

2. On the Create tab, in the Forms group, click the Form buttonimage from book

Access creates and displays a simple form based on the active table.

Tip 

You don’t have to open a table to create a form based on it. You can simply click the table in the Navigation Pane to select it, then click the Form button on the Create tab in the Forms group. But it is sometimes useful to have the table open behind the form in order to verify the form contents against the table contents.

image from book

The Form tool automatically added a title (Customer) and a placeholder for a logo in the form header.

3. Scroll through a few of the records by using the navigation controls at the bottom of the form.

You can compare the information shown in the form to that in the datasheet view of the table by alternately clicking the Customers table tab and the Customers form tab in the database window to easily switch back and forth between views.

Close the Customers form (without saving your changes) and the 01_CreateFormTool database.

image from book

Relationships

In Access, a relationship is an association between common fields in two tables. You can use this association to link information in one table to information in another table. For example, you can establish a relationship based on the CategoryID field between the Categories table and the Products table. Each product is in only one category, but each category can contain many products, so this type of relationship-the most common-is known as a one-to-many relationship.

Less common relationships include:

  • One-to-one relationships, in which each record in one table can have one and only one related record in the other table.

    This type of relationship isn’t commonly used because it is easier to put all the fields in one table. However, you might use two related tables instead of one to break up a table with many fields, or to track information that applies to only some of the records in the first table.

  • Many-to-many relationships, which are really two one-to-many relationships tied together through a third table.

    You could see this relationship in a database that contains Products, Orders, and Order Details tables. The Products table has one record for each product, and each product has a unique ProductID. The Orders table has one record for each order placed, and each record in it has a unique OrderID. However, the Orders table doesn’t specify which products were included in each order; that information is in the Order Details table, which is the table in the middle that ties the other two tables together. Products and Orders each have a one-to-many relationship with Order Details. Products and Orders therefore have a many-to-many relationship with each other. In plain language, this means that every product can appear in many orders, and every order can include many products.

If there is a one-to-many relationship between two tables in a database, an excellent way to display this is through the use of a form containing a subform. The main, or primary, form displays one record from the “one” side of the one-to-many relationship, and the subform lists all the pertinent records from the “many” side of the relationship.

image from book



2007 Microsoft Office System Step by Step
2007 MicrosoftВ® Office System Step by Step
ISBN: 0735622787
EAN: 2147483647
Year: 2004
Pages: 231

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net