Inserting Fields


Perhaps one of the most common changes you’ll make to your database is to insert a new field in a table. Up until now, we’ve renamed and moved the available fields to more closely match tblContacts. If you take a look at the comparison of the two tables again (Tables 5–1 and 5–2 on pages 214 and 215), you can see that we need to add several more fields. Now you’re ready to insert fields to store the middle initial, suffix, contact type, default address indicator, and more. As you go through adding these new fields, be sure to enter a description for each new field as well as the existing fields.

First, select the row or move your insertion point to the row that defines the field after the point where you want to insert the new field. In this case, if you want to insert a field for the middle initial between the FirstName and Title fields, place the insertion point anywhere in the row that defines the Title field. You can also select the entire row by using the arrow keys to move to the row and then pressing Shift+Spacebar or by clicking the row selector. Next, click the Design contextual tab, which is located below Table Tools on the Ribbon. Finally, click the Insert Rows command in the Tools group, as shown in Figure 5–15. (You can also click a field row and press the Insert key to insert a row above your selection.)

image from book
Figure 5–15: The Insert Rows command inserts a new row above a selected row or above the row in which the insertion point is located.

Access 2007 adds a blank row that you can use to define your new field. Type the definition for the MiddleInit field. Choose the Text data type, and set the Field Size property to 1. Now move down to the WorkAddress field, and insert another row above it. Enter a Suffix field that has the Text data type with a field size of 10. Do it one more time and insert a ContactType field between Suffix and WorkAddress, set its data type to Text, and set its length to 50. Insert a field between ContactType and WorkAddress, name it BirthDate, and set its data type to Date/Time. Insert another field between BirthDate and WorkAddress, name it DefaultAddress, set its data type to Number, and set the field size to Integer. The actual Conrad Systems Contacts application uses this field to indicate whether the work or home address is the default mailing address.

Move down to WorkFaxNumber and insert a field above it. Enter a field name of WorkExtension, set its data type to Text, and set the field size to 20. Now move down to the bottom of the field list and insert another new field above Notes. Enter a field name of SpouseName, set its data type to Text, and set the field size to 75. Insert another row between the SpouseName and Notes fields, enter a field name of SpouseBirthDate, and set its data type to Date/Time. Move to the blank row beyond Notes (you can use an existing blank row to add a field at the end), and create a field named CommissionPercent with a data type of Number and a field size of Double. Finally, move down to the empty row below CommissionPercent, create a new field named Inactive, and set its data type to Yes/No.

At this point, your Table window in Design view should look something like the one shown in Figure 5–16. (We entered information in the Description properties of all fields we’re going to keep. You can change your descriptions to match the figure.) Don’t worry about setting other properties just yet. As you can see, we are getting closer to the exact design specifications of tblContacts in the Conrad Systems Contacts database, but we still have more things to change.

image from book
Figure 5–16: The Contacts table with additional fields inserted and descriptions defined.

Inside Out-Using the Keyboard to Move Between Windows 

You can move the insertion point between the upper part and the lower part of any Table or Query window in Design view by pressing F6.




Microsoft Office Access 2007 Inside Out
MicrosoftВ® Office Access(TM) 2007 Inside Out (Microsoft Office Access Inside Out)
ISBN: 0735623252
EAN: 2147483647
Year: 2007
Pages: 234

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