MicrosoftВ® Office Access(TM) 2007 Inside Out (Microsoft Office Access Inside Out)

You might want to move a field in a table definition for a number of reasons. Perhaps you made an error as you entered or changed the information in a table. Or perhaps you’ve discovered that you’re using some fields you defined at the end of a table quite frequently in forms or reports, in which case it would be easier to find and work with those fields if they were nearer the beginning of your table definition.

Inside Out-How Important Is the Sequence of Fields in Your Table? 

The actual sequence of field definitions in a table is not all that important In the relational database model, there really is no defined sequence of fields in a row or rows in a table. Access 2007, like most databases that implement the relational model, does allow you to define a field order when you create a table. This order, or sequence of fields, becomes the default order you see in a table datasheet or in a list of field names when you’re designing a query, form, or report

We like to at least group fields together in some reasonable order so that they’re easy to find, and we like to place the primary key fields at the top of the list There’s really no hard and fast rule that you must follow for your database to work efficiently.

You can use the mouse to move one or more rows. Simply follow these steps.

  1. To select a row you want to move, click its row selector.

    If you want to move multiple contiguous rows, click the row selector for the first row in the group and scroll until you can see the last row in the group. Hold down the Shift key and click the row selector for the last row in the group. The first and last rows and all rows in between will be selected. Release the Shift key.

  2. Click and drag the row selector(s) for the selected row(s) to a new location. A small shaded box attaches to the bottom of the mouse pointer while you’re dragging, and a highlighted line will appear, indicating the position to which the row(s) will move when you release the mouse button.

In the design for the tblContacts table in the Conrad Systems Contacts database, the EmailName field appears after all the address fields and before the Website field. It certainly makes sense to place all the Web-related fields together. Select the EmailName field by clicking its row selector. Click the row selector again, and drag down until the line between the WorkCountry field and the Website field is highlighted, as shown in Figure 5–12.

Figure 5–12: You can drag the EmailName field to a new position between the WorkCountry and Website fields.

Inside Out-Using the Keyboard Instead of the Mouse in Table Design 

When it comes to moving fields, you might find it easier to use a combination of mouse and keyboard methods. Use the mouse to select the row or rows you want to move. Then activate Move mode by pressing Ctrl+Shift+F8, and use the arrow keys to position the row(s). Press Esc to deactivate Move mode. As you experiment with Access 2007, you’ll discover more than one way to perform many tasks, and you can choose the techniques that work the best for you.

In Figure 5–13, the fields are positioned correctly.

Figure 5–13: The EmailName field is now correctly placed.

In this exercise, we’ll move a couple of additional fields to make the design of Contacts more similar to tblContacts. In the tblContacts table, the HomePhone and MobilePhone fields appear just before the EmailName field. Click the row selector for HomePhone, hold down the Shift key, and click the row selector for MobilePhone to select both fields. Drag and drop the two fields before the EmailName field. Now that you’ve moved HomePhone and MobilePhone out of the way, you can select both WorkPhone and WorkFaxNumber and drag them to where they belong after the WorkCountry field. Finally, move the Notes field after the Photo field. After you’ve done this, your table should look like Figure 5–14.

Figure 5–14: After moving several fields, the sequence of fields in your Contacts table is similar to that in tblContacts.

Категории