Copying Fields


As you create table definitions, you might find that several fields in your table are similar. Rather than enter each of the field definitions separately, you can enter one field definition, copy it, and then paste it as many times as necessary.

To finish defining our Contacts table, we need five additional fields-HomeAddress, HomeCity, HomeStateOrProvince, HomePostalCode, and HomeCountry. You could certainly insert a new row and type all the properties as you just did in the previous section, but why not copy a field that is similar and make minor changes to it?

For this part of the exercise, select the row for the WorkAddress field definition by clicking the row selector at the left of the row. Click the Copy command in the Clipboard group on the Home tab, as shown in Figure 5–17.

image from book
Figure 5–17: Select the WorkAddress field and click the Copy command on the Home tab of the Ribbon to copy the field to the Clipboard.

Move the insertion point to the row that should follow the row you’ll insert. (In this case, move the insertion point to the HomePhone field, which should follow your new field.) Insert a blank row by clicking Insert Rows in the Tools group of the Design contextual tab below Table Tools on the Ribbon. (In this procedure you switch back and forth between the Home tab and the Design contextual tab.) Select the new row by clicking the row selector. Click the Paste command in the Clipboard group on the Home tab of the Ribbon, as shown in Figure 5–18.

image from book
Figure 5–18: You can paste the copied WorkAddress field into a new blank row.

Caution 

If you click the Paste command when a row containing data is selected, the copied row will replace the selected row. Should you make this replacement in error, click the Undo command on the Quick Access Toolbar to restore the original row.

You can use the Paste command repeatedly to insert a copied row more than once. Remember to change both the name and the description of the resulting field or fields before you save the modified table definition. In this case, it’s a simple matter to change the name of the copied row from WorkAddress to HomeAddress and to correct the description and caption accordingly. Note that this procedure also has the benefit of copying any formatting, default value, or validation rule information.

If you’re careful, you don’t actually have to insert a blank row to paste a field definition from the Clipboard. You can also copy and paste multiple fields at a time. After you fix the HomeAddress field name and description in the upper part of the window and caption in the lower part of the window, select the WorkCity field, hold down the Shift key, and select the WorkCountry field. Click the Copy command to copy all four fields to the Clipboard. Move down to the HomePhone field again and click in the row but do not select the row. Click the Paste button in the Clipboard group of the Home tab to insert the four fields just above HomePhone. Change the name of the first one to HomeCity, the second to HomeStateOrProvince, the third to HomePostalCode, and the fourth to HomeCountry and correct the descriptions and captions. You should now have a table that’s almost identical to the tblContacts table in the Conrad Systems Contacts sample database as shown in Figure 5–19. Be sure to save your changed table.

image from book
Figure 5–19: The Contacts field list is now almost identical to tblContacts.




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