Objective Number
KE KEY TERMS
ascending as composite key co descending de lter l foreign key innermost eld outermost eld referential integrity sort wildcard
49
Copyright 2012 John Wiley & Sons
50
Lesson 3 Fourth Coffee is a national chain of coffee shops. A new store recently opened in your neighborhood. You were able to get a part-time job working in the ofce, helping the ofce manager organize data on the computer. In addition to being a traditional neighborhood coffee shop, the store has also started selling coffees to companies for use at their business sites. It is your job to manage the inventory, customers, and order tables in Access. In this lesson, you learn to navigate among records; enter, edit, and delete records; nd and replace data; sort and lter data; attach and detach documents; and dene, modify, and print table relationships.
Database tables are usually large, but contain useful information that ca be manipulated in large, u g, can different ways. When a table contains many records and elds, it is im important to be able to When table contains many records he able onta able ontains ma y ec a navigate among them. n hem. ng the e
STEP BY STEP
The Fourth Coffee le for this lesson is available on the book companion website or in WileyPLUS.
2. Click the File tab, then click the Save Database As command. The Save As dialog box Fi e File click the lick k e As S appears. Key Fourth Coffee XXX (where XXX is your initials) in the File name box. y Fourth Four Fourth e XX is XXX where y Find the location where you will save the solution les for this lesson and click Save. here you will save the r i av h v less 3. In the Navigation Pane, double-click Coffee Inventory: Table to open the table. 4. Notice that the rst cell of the rst record is selected. 5. Press the Down Arrow key to move down to the next row. Notice that the cell is selected.
6. Press the Right Arrow key to move to the Product Name eld. 7. Press the Tab key to move to the next cell. 8. Press the Tab key to move to the next cell. 9. Press the Tab key to move to the next row. 10. Press Ctrl+Down Arrow to move to the rst eld of the last record. PAUSE. LEAVE the database open to use in the next exercise.
Table 3-1 lists keys and key combinations for moving among records.
51
Commands
Tab or Right Arrow End Shift Tab or Left Arrow Home Down Arrow Ctrl Down Arrow Ctrl End Up Arrow Ctrl Up Arrow Ctrl Home
Results
Moves cursor to the next eld Moves cursor to the last eld in the current record Moves cursor to the previous eld Moves cursor to the rst eld in the current record Moves cursor to the current eld in the next record Moves cursor to the current eld in the last record Moves cursor to the last eld in the last record Moves cursor to the current eld in the previous record Moves cursor to the current eld in the rst record Moves cursor to the rst eld in the rst record
Last record Previous record First record Filter indicator Search box Add new (blank) record Current record Next record
52
Lesson 3
2. Click the Next record button. The selection moves to the next record. 3. Select and then delete the number 2 in the Current Record box. Key 5 and press Enter. The selection moves to the fth record. 4. Click the Search box to position the insertion point. Key sunrise into the Search box. Notice that the selection moves to the rst occurrence of the word Sunrise. 5. Press Enter. The selection moves to the next occurrence of the word Sunrise. 6. Click the New (blank) record button. The insertion point moves to the rst column and last row of the table. PAUSE. LEAVE the database open to use in the next exercise.
SOFTWARE ORIENTATION
Records Group, Record Selector Box, and Record Shortcu Menu Shortcut
There are a few ways you can enter record data, delete data from individua elds of records, you can enter record data, u n cor data a, individual and insert and delete entire records, using the Records group, Record S Selector box, and delete enti elet entire let i th Records the R c n th n in Figure F commands in the Record Shortcut menu, as shown in Figure 3-2. Refer to this gure as a thr throughout this hi ell hs o reference throughout this lesson as well as the rest of this book. well this book.
Record Shortcut menu menu n Records group gr group
Figure 3-2 Records group, Record Selector box, and Record Shortcut menu
Use the commands in the Records group and the Record Shortcut menu, as well as the Record Selector box (a blank square to the left of a record), to assist you in entering record data and inserting and deleting records.
53
STEP BY STEP
Enter, Edit, Enter, Edit, and Delete Records dit, t, Delete Rec et Records t co
USE USE the database you used in the previous exercise. dat ase ataba at as t used s ep previous exercise. s x xe 1. The insertion point sh uld be positioned in the rst eld of the new, blank row at the insertion p n shou be positioned rt t point should si sit n d rst eld t bottom of the datasheet, as show in Figure 3-3. Notice the as Notice asterisk in the Record the datasheet, s shown i Figure aa t own o o c Selector box, whic indicates that this is a new record, ready f data. box, which indicates at s is record, for x hich c c e t o
New record
54
Lesson 3
2. Key 21905 and press Tab. Notice that the asterisk has changed to a pencil icon, as shown in Figure 3-4, indicating that the record is being edited.
Figure 3-4 Entering data into a record Indicates that the record is being edited
3. Key Hazelnut and press Tab. 4. Key 30 and press Tab. 5. Key 02112012 and press Enter. 6. Highlight sunrise in the Search box and key Kona to locate the Kona record. 7. Select Kona in the record to position the blinking insertion point there. Key Hawaiian and press Tab. 8. Click the Undo button on the Quick Access Toolbar. button o the Quick Access to o ui k cce 9. Press Tab. Key 12292010 and press Tab. Ke 12292010 Key 1229 22 10. Click the Record Selector box to the left of the Product ID eld of th rst record, e Record Selector box to the Re ecto ector c h P od Prod duct the 20051. 1. 1. 11. On the Home tab, in the Records group, click the Delete button drop-down arrow. the he Records o s Delete le lete dro Select Select Delete Record from the menu, as shown in Figure 3-5. ee the menu, h Figure ue
Another Way
An easy way to select an entire record is to click the Record Selector box. If you need to select other records above or below it, you can drag the mouse up or down to include those in the selection. To delete one or more selected records, rightclick the Select All button and choose Delete Record from the shortcut menu. Figure 3-6 6 Conrm deletion dialog box
12. A dialog box appears, as shown in Figure 3-6, asking if you are sur you want to dia dialog appears, s shown s o n g f sure delete the record. Click Yes. Click Yes. t te the l e
Another Way
To delete a record without selecting it, place the cursor in one of the elds of a record and click the Delete menu on the Home tab in the Records group. Select Delete Record from the menu.
13. Notice that the Undo button on the Quick Access Toolbar is not available because you cannot undo a deletion. Close the table. PAUSE. LEAVE the database open to use in the next exercise.
Ref
As you become more advanced in your knowledge of Access, you may want to create a delete query that can delete multiple records at once. You learn more about queries in Lesson 8.
55
As you learned in Lesson 1, a primary key is a column that uniquely identies a record or row in a table. Customer IDs, serial numbers, or product IDs usually make good primary keys. Each table should have a primary key, and some tables might have two or more. When you divide information into separate tables, the primary keys help Access bring the information back together again.
STEP BY STEP
Another Way
To add or remove move the primary key from a eld, ld, you can also select the row, w, right-click, and select Primary mary Key from the shortcut menu. nu.
2. On the Home tab, in the Views group, click the View button dr 2. Home t m tab, Views group, click e ro w button drop-down arrow, and menu that appears, from the menu that appears, select Design View. n e s ct De t e 3. Click the Row Selector box beside the Order ID row to select the row. 3. Click C box ow ow to th 4. On the Design tab, in the Tools group, click the Primary Key button. The Primary Key On tab, in e Tools a o P m Primary bu button highlighted orange butt button is highlighted in orange and appears to be pushed in. A key icon appears on utt g d a o be designate primary shown in Figure 3-7. the Order ID row to designate the eld as a primary key, as sh e Order r w to desig design ri
2.4.1
How do you designate a primary key in an Access table? PAUSE. LEAVE the table open to use in the next exercise.
56
Lesson 3
selected Both fields are selected s 3. On the Design tab, in the Tools group, click the Primary Key button. A key icon should the n Tools group, Primar mary r button displayed both be displayed beside both of the two selected elds. pl pl y b h of the h elds. ds. 4. With the rows still selected, click the Primary Key button again to remove the primary rows s w still Primary Key r e r designation from both elds. key designation from both elds. io o m ot oth ds. 5. Click on any eld name to remove the selection. 6. Click the Row Selector box beside the Order ID row. Press and hold the Ctrl key and 6 row hol click the Row Selector box beside the Customer ID row. Both elds should be selected. 7. On the Design tab, in the Tools group, click the Primary Key button. Both rows should have a key displayed beside them. 8. Click the Save button on the Quick Access Toolbar. 9. Close the Design View. PAUSE. LEAVE the database open to use in the next exercise.
57
In the Find and Replace dialog box, key the text or numbers that you want to search for into the Find What box and click Find Next to locate the record containing the data. If you want to replace the data, key the new data into the Replace With box and click Replace or Replace All.
Take Note
When replacing data, it is usually a good practice to click Replace instead of Replace All so that you can conrm each replacement to make sure that it is correct.
STEP BY STEP
58
Lesson 3
8. Click the Find Next button. Access searches the table and nds and selects the word Elm. 9. Click the Replace button. Access replaces Elm with Little Elm. 10. Click the Find Next button. Access nds Elm in the new text that was just inserted. 11. Click Find Next again. Access displays a message saying that no more occurrences of the word have been found. Click OK. 12. Click Cancel to close the Find and Replace dialog box. 13. Press the down arrow to remove the selection and allow Access to save the change. 14. Close the table. PAUSE. LEAVE the database open to use in the next exercise.
2.3.1
How do you nd data within a table?
Another Way
To open the Find tab in the Find and Replace dialog box using the keyboard, press Ctrl+F. To open the Replace tab, press Ctrl+H.
Take Note
If you want to use the Find and Replace dialog box to search for characters that are used as wildcards, such as a q question mark, y must enclose that character in brackets, for example [?]. you Follow this rule when searching for all wildcard characters except exclam exclamation points (!) and closing brackets (]).
Access 2010 allows you to attach documents, such as Word documents or photo les, to records 2010 01 documents, u d documents in a database. For example, the human resources department of a large c company could keep a database. hu a human department of n photo, a resume, and employee evaluation documents with each em employee record. These photo, resume, o esume m employee evaluation documents with mplo mp oyee valuati n tion men s i ents attached les can ch c ed e a easily detached, f necessary. Th Attachments dia a y hed, d he attached les can also be easily detached, if necessary. Th Attachments dialog box allows you to The a h manage n documents attached to records. u ach c e ec r manage the documents attached to records. You cannot attach les to databases created in versions of Ac ess prior to Access 2007. You u cannot attach a t h databases created bases versions e o Acce Access cannot cannot share attachments with a database created in these prior versions of Access. n o attachments h database a m da abase in these th r versions o e
Take Note
You can attach a maximum total of 2 gigabytes of data, but each individual le cannot exceed 256 megabytes in size. If the program that was used to create the attached le is installed on your computer, you can open and edit the le using that program. For example, if you open a Word resume that is attached to a record, the Word program starts and you view the document in Word. If you do not have the program that was used to create a le, Access prompts you to choose a program you do have to view the le.
Another Way
You can also rightclick in the Attachments eld to display a shortcut menu. Select Manage Attachments from the menu to display the Attachments dialog box.
59
STEP BY STEP
The invoice 100 le 0 for this lesson is available able on the book companion ion website or in WileyPLUS. LUS. Figure 3-11 e Attachments dialog box og
5. Double-click the rst row of the Attachments eld. The Attachm . Double-click w f eld. T Attachments dialog ld The d box box appears. 6. Click the Add button. Navigate to the data les for this lesson and select Invoice100.docx. 6. Click the Cl lic button. Nav ate to the utto ton av ate vigat e les for th e o this an Click Cli Open. Click Open. The document appears in the Attachments dialog b d um document appears p a Attachments t h ents box, as shown in Figure 3-11. Figure 3-11. gu u
7. Click OK. The number of attachments in the rst record changes to 1, as shown in The number of attachments in h umber b t chment h e change Figure 3-12. Figure 3-12 Attachments eld displaying the number of attachments Attachments field
Number of attachments
60
Lesson 3
8. Double-click the attachment number in the Attachment eld. The Attachments dialog box appears. 9. Click the Open button. The attachment, an invoice document, opens in Microsoft Word. 10. Click the Close button to close the invoice document. 11. Click the Access button on the taskbar, if necessary, to return to Access. 12. In the Attachments dialog box, click the Remove button, and click OK. The attachment is removed from the record. 13. Close the Order Summary table. PAUSE. LEAVE the database open to use in the next exercise.
Take Note
Once a eld has been set to the Attachment data type, it cannot be converted to another data type.
SORTING AND FILTERING DATA AND SETTING FIELD V VIEWING OPTIONS WITHIN A TABLE WITHIN TABLE TH TH N ABLE B
It is often helpful to display data in order, display similar records, or hi and freeze certain helpful e pful sim similar hide elds without affecting th preexisting data. Sorting allows you to order records. For example, without ho g the preexisting data. h ing allows lo an ofce co that employees in alphabetical order by last name would help the e contact list tha displays emp hat mployees alphabetical order c l user nd information for a particular employee quickly. If you wanted to view only the records nd particular n u r you yo of employees in a particular department, you could create a lter to displ only those records. employees lter display mp m l department, a e te You could also hide or freeze certain elds. For example, in a table that has several elds, you can could also hide freeze certa l l i e certain elds For example i table lds. d le le, a hide or freeze elds to help you concentrate on certain data. you concentrate e or freeze elds ez p y c cent at ntr n data. a at
61
To sort text, numbers, dates, or other data types in a column, you rst need to select the column. Then click the Ascending or Descending button in the Sort & Filter group of the Home tab. You can also right-click a selected column and choose a Sort command from the shortcut menu. The available sort commands in the shortcut menu vary depending on the type of data in the column, as shown in Table 3-2.
Table 3-2 Sort Commands on the Shortcut Menu Number, Currency, or AutoNumber Type of Data Sort Command on the Shortcut Menu
Yes/No
Date/Time
You can also sort re u ca a records on multiple elds. When you are using multiple elds, determine which records multiple u ul i u are e multip order you want them to be sorted in. The primary sort eld is called the outermost eld. A order r e sorted o d t eld e secondary sort eld is called an innermost eld. For exa innermost ld example, if y want to sort a contact seco seco econdary o y innermost eld. er o xample, you xa list o t each employees last name so list so that each emplo ees last name is sorted primarily and rst name is sorted secondarily, Last t ploy pl pl e s s a e sorted primarily and m ly n y Name ul outermost el and Name would be innermost eld. In your comNa would Name would be the outermost eld an First Name would be the inn ut mo eld n m d pleted sort, Wright, David, would be pleted sort, Wright, David would be listed before Wright, Steven, in a A to Z (ascending) sort. l o or id, id d l re Wright, Steven, an e e When designating order, select innermost eld When designating the sort order, however, you select the innermost el rst and choose the type sig at ord however, se c nr want of sort you want from the sh f w nt shortcut menu. Then select the outermost eld and select the type of h t menu. Then select e sort sort that you want. o u want. n After one or mo columns, Access inserts more arrows After you sort one or more columns, Access inserts sort ar ows in the header row to show that f m s cce arro r the sorted. These t commands remain the eld is sorted. The sort commands remain with the table until you remove them. When h ed hese e m nd m e table a you remove order, button the you want to remove a sort order, click the Remove Sort button from t Sort & Filter group on o d he Remove e utt the This the Home tab. This removes the sorting commands from all the elds in the table. In a table h h s e om om el with more sorted eld, just with more than one sorted eld, you cannot remove just one sort. th t orted e u us
STEP BY STEP
62
Lesson 3
4. The data is sorted and an arrow is inserted in the header row, as shown in Figure 3-15, indicating that the data is displayed in sort order.
Sort arrow
5. On the Home tab, in the Sort & Filter group, click the Remove Sort button. The sort is n the h t Filter Remove Re removed removed from the Customer ID eld. e r eld. 6. Select the First Name eld. On the Home tab, in the Sort & Filter g Select le t F First Name eld. On th Home m el the Hom o n the Sort group, click the Ascending button. e data in he First Ascending button. The data in the First Name eld is sor ed in ascending order. s d t e ir r eld is sorted asce orte o 7. Select the Last Name eld On the Home tab, in the Sort & Filter g Select he Last e he as eld. O he eld. e n the h t group, click the Ascending button. Ascending button. The data in the Last Name eld is sorted in ascending order. s g ut u data the t h eld sorted asce ld l r d
2.3.2
How do you sort data within a table?
8. On the Home tab, in the Sort & Filter group, click the Remove Sort button. The sort is n Home tab, m a So Sort Filt r ilte il , click i Remo move removed First Name and Last Name elds. removed from both the First Name and Last Name elds. e m both s am s s 9. Close the table. If a dialog box appears asking if you want to save changes to the Close l table. e dialog box appears asking i o o pe s s n sk want a table, click No. table, PAUSE. LEAVE the database open to use in the next exercise. S datab a abase open o b e n the he h se se. PAUSE. exercise.
STEP BY STEP
Apply a Filter
USE the database you used in the previous exercise. 1. Open the Coffee Inventory table. 2. Select the Product Name eld. On the Home tab, in the Sort & Filter group, click the Filter button. A menu appears.
63
3. Point to Text Filters. A second menu appears. Select Contains, as shown in Figure 3-16.
4. The Custom Filter box appears. Key Decaf, as shown in Figure 3-17, and click OK. ustom m D c Decaf, Custom Filter Access database o display the Access lters the database to display only the records containing the word Decaf. A cess e atabase b th contain lter displayed in the header the lter icon is displayed in the header row of the eld, as shown in Figure 3-18. lte ter ispl yed pl h h Figure 3-17 e Custom lter box er
Filter icon
5. Click the Toggle Filter button in the Sort & Filter group to display the records without the lter. 6. In the second record in the Product Name eld, double-click the word Decaf to select it. 7. Right-click the word Decaf to display the shortcut menu. Select Does Not Contain Decaf, as shown in Figure 3-19. Notice that the records are ltered to show only those that do not contain the word Decaf.
64
Lesson 3
Figure 3-19 Shortcut menu with Does Not Contain Decaf option selected
8. Click in the Pounds eld of the rst record. 9. On the Home tab, in the Sort & Filter group, click the Filter button. 10. Click the check boxes to remove the check marks beside 30, 35, 40, and 50, as shown in Figure 3-20. Only the check mark beside 25 should remain. check chec mark beside eck k e
Figure 3-20 0 Filter menu selected d to show only 25 in the e pounds column n
11. Click OK. Access lters the records to show only those co Click lick lters records e r o e containing t number 25 in o the the po e po pounds eld. eld. 12. Click th Toggle Filter button. k the h Filter button. e t 13. In the second row of the Sched second eco f the Scheduled Order Date eld, highlight 1/14/2012 by clicking e cheduled ched eld, ld 1/14 dragging the and dragging the mouse. ging gi g 14. On the Home tab, in the Sort & Filter group, click the Selection button. A menu tab, in the Sort Filte g ou b th o ilt group, ter but 3-21. appears, as shown in Figure 3-21 21. 2
2.3.3
How do you lter table records?
15. Select On or After 1/14/2012. The data is ltered to show only those records with content in the Scheduled Order Date eld that matches the lter selection. 16. In the seventh row of the Pounds eld, select 30. 17. On the Home tab, in the Sort & Filter group, click the Selection button. Select Less Than or Equal to 30. The records are ltered. PAUSE. LEAVE the database open to use in the next exercise.
65
Only one lter can be applied per column. When you apply a lter to a column that is already ltered, the previous lter is removed and the new lter is applied.
Removing a Filter
After applying a lter, you may need to return to records not displayed by the lter. The Toggle Filter button lets you switch between viewing the ltered records and viewing the table without the lter. Note that the purpose of this button changes accordinglywhen the records are ltered the button is used to remove the lter, and when the lter is removed the button is used to apply the lter. When you are nished using the lter, you can permanently remove it. In this exercise, you permanently remove the lter you previously applied.
STEP BY STEP
Remove a Filter
USE the table you used in the previous exercise. 1. Select the Pounds eld. On the Home tab, in the Sort & Filter g Pounds eld. On the Home un s eld n l th om group, click the Filter button. A menu appears. button utton n. 2. Select Clear Filter from Pounds, as shown in Figure 3-22. Select Clear e Pounds, s in Figure F
3. On the Home tab, in the Sort & Filter group, click the Advanced Filter Options button. the tab, n the Sort ab e o click lick ck menu A menu appears. enu 4. Select Clear All Filters from the menu, as shown in Figure 3-23 Clear All Filters lear Al F ll menu, s enu 3-23.
5. Save and close the table. PAUSE. LEAVE the database open to use in the next exercise.
66
Lesson 3
STEP BY STEP
3. Select Freeze Fields. Notice that the Last Name eld moves to the rst eld position in Sele Sel ct Fields. No e s Notice that t L t Name Last moves o e the table. the h 4. Click the Restore Down button in the top, right corner of the applic Click li D Down button n o r f application window, as shown in Figure 3-25. The Restore Down button now becomes the Maximize button. show own ow . The Restore Th e o w becomes e Press the Right Arrow key to scroll the tables elds to the left, and stop when you the s th Arrow y o scroll o r s o the reach the ZIP/Postal Code eld. Notice that the Last Name eld stays xed as the other h Code eld. d d Last Name ast as sta scroll. elds scroll. roll o
Figure 3-25 Restore down button 5. Click the More button again and select Unfreeze All Fields. Notice how the Last Name eld remains in the tables rst eld position. Press the Right Arrow key several times until the Last Name eld scrolls off from view. Notice how the Last Name eld moved with the other elds when the Right Arrow key was pressed several times.
Take Note
Fields can be rearranged in Datasheet View by clicking on the eld name headers and dragging them to where you want to move them.
6. Click the Maximize button on the application window. 7. Select the Customer ID eld. Click the More button and select Hide Fields. Notice the Customer ID eld is now hidden from view, as shown in Figure 3-26.
67
Figure 3-26 Hidden Customer ID eld 8. Click the More button and select Unhide Fields. The Unhide Columns dialog box should appear as shown in Figure 3-27. Notice the check mark is missing from the pp g Customer ID check box, signifying that its hidden.
2.2.5 .2.5
How do you freeze or unfreeze elds? 9. Deselect the check boxes next to all the other eld representations except Last Name check boxes next o all he k ox e xes ex representat Unhide Columns dialog and Business Phone, and then click the Close button in the Un box. elds box Notice the only elds now displayed in Datasheet View are the Last Name and ar Business Phone elds. 10. Close the Customers table without saving the changes to the layout. PAUSE. LEAVE the database open to use in the next exercise.
2.2.4 24
How do you hide or unhide elds?
You can save your table so it retains your formatting the next time you open it. To select more than one eld to freeze or hide, hold down the shift key while selecting adjacent elds.
Another Way
You can also access the Hide/Unhide and Freeze/ Unfreeze options from the shortcut menu that appears after you right-click a eld name.
68
Lesson 3
SOFTWARE ORIENTATION
Relationship Tools on the Ribbon
When you click the Relationships button on the Database Tools tab, the Relationship window appears and the Relationship Tools are displayed in the Ribbon (Figure 3-28).
Figure 3-28 Use the Relationship Tools to dene and modify table relationships Removes tables and relationships from the display but does not delete them Close Master View button
Displays all the relationships and related tables for the selected table
As you have already learned, most databases have more than one table. Creating relationships you u already lre d most databases o ta ta more one e C among these table allows Access to bring that information back together again through objects tables allows Access to information back together among o bles bl l l c ce s g f c such as reports and queries so that you can display information from sever tables at once. This can display information from several h as d queries so that u c d a in ue n o is why it is a good idea to dene table relationships before you star creatin reports and queries. start hy idea to de table relat nships d de a e l tionship s s art creating
69
3. Select Order Summary and click Add. 3. Summ Sum ary and u Add. d . 4. Click Close. The Customer table and Order Summary table are represented in 4. Customer table e a Summary ay Relationships View. Relationships View. ew w 5. Click the Customer ID eld in the Customers table and drag it t the Customer ID eld Click c Customer D e in m eld table abl to of the Order Summary tab and release the mouse button. The Customer ID eld the Summary table e mmary ab a able e mouse Th represents the common eld between the two tables. The Edit Relationships dialog represents s nt the two h tw box appears, as shown in Figure 3-30. appears, as shown Figure 3-30. ar ar , show show igure 30 g 30.
Primary table
Related table
70
Lesson 3
6. Select the Enforce Referential Integrity check box. Then select the Cascade Update Related Fields and Cascade Delete Related Records check boxes. 7. Click Create. A relationship line representing the one-to-many table relationship of the Customers and the Order Summary tables is displayed, as shown in Figure 3-31. You just created a one-to-many relationship between these tables using Customer ID, the common eld. The one-to-many relationship type signies that each customer record in the Customers table can have many order records in the Order Summary table.
Relationship line
2.4.2 2
How do you use primary keys s to create relationships? PAUSE. LEAVE PAUSE. LEAVE the database open to use in the next exercise. S E E database open o us in ba o use exercise. e s
71
To remove a table relationship, you must delete the relationship line. You can select the line by pointing to it and clicking it. When the relationship line is selected, it appears thicker. Press the Delete key to delete the line and remove the relationship or right-click the line to display the delete menu.
STEP BY STEP
2. Select Delete. A message appears asking if you are sure you w 2. message appears g p are sure r want to delete the relationship. Click Yes. The line disappears. rela i ns relationship. Click Yes. The line disappears. lick e c i e sa 3. Select the Customer ID eld in the rst table. Drag the mouse to the Customer ID eld 3. Select the Customer ID el m d n the table. Dr the e Drag e the second and r ease release button. The Relationships dialog box in the second table and release the mouse button. The Edit Re h e a u appears. appears. e 4. Click the Create button. A line appears, creating the relationsh 4. the Cr h Cr n n. e creating at relationship. l 5. Double-click the center section of the relationship line. The Edit Relationships dialog 5. Double-click -c k c center section o n ti relationship line.The Edi e t n box appears again, listing the tables and the Customer ID eld on each side. appears again, listing he tables and Customer elds a n, is n is n he b e m r 6. Click the Enforce Referential Integrity box and click OK. The line appears thicker, with 6. Enforce R n c Referential Integrity box n a teg t o e OK K lin beside e rst table and the number 1 beside the rst table and the innity symbol ( ) beside the second, as e es s l n symbol y Figure shown in Figur 3-33. ure ur r Figure 3-33 e Relationship displaying laying enforced referential integrity tegrity Relationship line with the th the h number 1 on the one side one one ne
2.4.3
How do you edit relationships?
Infinity symbol displayed on the many side PAUSE. LEAVE the database open to use in the next exercise.
72
Lesson 3
STEP BY STEP
Page Layout group: ge Controls page orientation ols n and printing options d ns s
Data group: Controls Da a Data all aspects of data exporting dat data exporting i
Page Size group: Controls margins and page size Figure 3-34 Print preview of Relationship Report
2. Click the Print button. The Print dialog box appears, allowing you to select the printer you want to use. 3. Click OK to keep the default settings and print the report. 4. Click the Close button to close the Relationships for FourthCoffee tab. A message appears asking if you want to save changes to the report. Click No. 5. Close the Relationships tab. STOP CLOSE the database. .
73
SKILL SUMMARY
In This Lesson You Learned How To: Navigate among Records Enter, Insert, Edit, and Delete Records Work with Primary Keys Find and Replace Data Attach and Detach Documents Sort and Filter Data and Set Field View Options within a Table Use Sort. Use Filter commands. Freeze or Unfreeze elds. Hide or Unhide elds. Use Primary se creat Use Primary Keys to create Relatio ships. e ation Relationships. Relationships. ation Edit Relationships. 2.3.2 2.3.3 2.2.5 2.2.4 2.4.2 2.4.3 Dene Primary Keys. Use Find. 2.4.1 2.3.1 Exam Objective Objective Number
Column 1 1. foreign key 1. 2. composite key comp com osite 3. outermost eld outerm utermost eld 4. referential integrity referential i ntia nt a integrity t 5. wildcards 6 ascending order 6. 7. descending order 8. lter 9. sort 10. innermost eld
Column 2 Co o a. prevents orphan records, to ensure that records do not ts s records, r ensur records reference other records that no longer exist rd r lo b. sorts data from beginning to end beginning g c. c. sorts data from end to beginning end nd d. to arrange data alphabetically, numerically, or e data a num chronologically chronologi ch onologic chronologically i e. a primary key from one table that is used in another table f f. a set of rules for determining whic records will be which displayed g. the secondary sort eld in a multield sort h. two or more primary keys in a table i. characters used to nd words or phrases that contain specic letters or combinations of letters j. the primary sort eld in a multield sort
74
Lesson 3 True/False
Circle T if the statement is true or F if the statement is false.
T T T T T T T T T T
F F F F F F F F F F
1. You can use the Navigation buttons to search for data in a table. 2. You can enter any kind of data into any eld. 3. After you enter data and move to a new eld, Access automatically saves the data for you in the table. 4. After you delete a record, you can click the Undo button to bring it back. 5. The Find and Replace dialog box searches all the tables in a database at one time. 6. An AutoNumber eld will usually make a good primary key. 7. Before you can attach a document, there must be a eld in a table formatted with the Attachment data type. 8. The outermost eld is the primary sort eld in a multield sort. 9. The Toggle Filter button lets you permanently remove a lter and switches you lt back to the original view. 10. In a one-to-many relationship, each record in the rst table can have many one-to-many relationship, each e-to many elations p, c t ationship, records in the second table. records in cord cords od
GET READY. LAUNCH Access if it is not already running. T READY. LAUNCH Access f it not already running. U C s y un u 1. OPEN the Charity Event database. OPEN P Charity Event database. ri Eve Event a s The Charity Event le for this lesson is available on the book companion website or in WileyPLUS. 2. SAVE the database as Charity Ev SAVE A database s Charity EventXXX (where XXX is your initia a t EventXXX (where XXX s your initials). 3. Open the Contacts table. Ope Open ts table. s 4. Enter the records shown in the following table: Enter nte the following ID 17 18 19 20 Company Company Trey Research Tr y Trey Fourth Coffee th Coffee h o Wingtip Toys T ys Toys Margies Travel Last Name Last Name t a Tiano T Tiano Culp Baker Baker k Nash First Name e Mike Scott Scott cott co t o Mary Mary Mike Business Phone 469-555-0182 469-555-0 469-555-0141 469-555-0 972-555-0167 972-555-0 972-555-0189 972-555-0
5. Click the View menu and choose Design View. 6. Select the ID row. On the Design tab, on the Tools menu, click the Primary Key button. 7. Save the design of the table and return to Datasheet View. 8. On the Home tab, in the Find group, click the Find button. The Find and Replace dialog box appears. Key 0177 into the Find What box. 9. Select Contents from the Look In menu and select Any Part of Field in the Match menu. 10. Click the Replace tab. Key 0175 into the Replace With box. 11. Click Find Next and then click Replace. 12. Click Cancel to close the dialog box. 13. Select the Lucern Publishing record. 14. On the Home tab, in the Records group, click the Delete button. Click Yes to delete the record. 15. CLOSE the database. LEAVE Access open for the next project.
Copyright 2012 John Wiley & Sons
75
GET READY. LAUNCH Access if it is not already running. The Angels le for this lesson is available on the book companion website or in WileyPLUS. 1. OPEN Angels from the data les for this lesson. 2. SAVE the database as Angels XXX, where XXX is your initials. 3. Open the List table. 4. Select the Gender eld. On the Home tab, in the Sort & Filter group, click the Ascending button. 5. Select the Age eld. On the Home tab, in the Sort & Filter group, click the Descending button. 6. On the Home tab, in the Sort & Filter group, click the Remove Sort button. , g p, 7. In the Gender eld, select the M in the rst record. 8. On the Home tab, in the Sort & Filter group, click the Selection button and select Home tab, in the Sort Filter group, m b, h o ilte g Equals M. s M. M. M. 9. On the Home tab, in the Sort & Filter group, click the Toggle Fi the he tab, in the Sort a t p click i Filter button. 10. Select the Wants eld On the Home tab, in the Sort & Filter gr S Select Wants eld. On the an ants ld. d eS Sort group, click the Filter button. Select Text Filters from the menu, select Co bu button. s from o Contains from the next menu, and key Bike in the Custom Filter dialog box and press Enter. Filter dialog e a Enter. nte ter 11. On the Home tab, in the 11. On the Home tab, in the Sort & Filter group, click the Advanced Filter Options button 1 e a rt rt Filter ilte e p, click the lick he k and select and select Clear All Filters from the menu. n e A Fi All Fil ers from the ilt o h LEAVE Access open for the next project. LEAVE Access E es e r the next project. x r
Address
City
State GA GA
4. Switch to Design View. Remove the primary key from the Home Phone eld and dene the ID eld as the primary key. 5. Save the design and return to Datasheet View. 6. Select the ID eld and sort it in ascending order. 7. On the Database Tools tab, in the Relationships group, click the Relationships button. 8. Create a one-to-one relationship between the ID eld of the List table and the ID eld of the Contact Information table. 9. Save the Relationships View and close it. 10. CLOSE the tables and the database. LEAVE Access open for the next project.
76
Lesson 3
GET READY. LAUNCH Access if it is not already running. The Wingtip Toys le for this lesson is available on the book companion website or in WileyPLUS. 1. OPEN the Wingtip Toys database and save it as Wingtip XXX, where XXX is your initials. 2. Open the Inventory table. 3. On the Home tab, in the Find group, click the Replace button to display the Find and Replace dialog box. Change the following prices: Find all 14.99 and replace with 29.99 Find all 16.99 and replace with 34.99 Find all 15.99 and replace with 30.99 p Find all 24.99 and replace with 34.99 4. Delete the following records from the data following records from the database: wing ecords rom h database: in c ds ID ID ID ID D ID ID ID 13 19 9 16 6 30, change the number of items in stock to 3 30, change the number items n 0, a h u b r items item o 28, change the number of items in stock to 6 28, change 8 h n mb number items in m 6, change the number of items in stock to 4 change ng number of items mb tem e
6. Select the In Stock eld and create a lter to display all the records with a value less Select e Stock e nd create e disp di play the than equal to than or equal to 10 in the eld. h u eld. e 7. Remove the lter. Remove e lter. er 8. Close the table. Close l table. le 9. CLOSE the database. CLO CLOSE database. ab a s LEAVE Access project. LEAVE Access open for the next project. V for the or o
GET READY. LAUNCH Access if it is not already running. The Soccer le for this lesson is available on the book companion website or in WileyPLUS. 1. OPEN the Soccer database from the data les for this lesson. 2. SAVE the database as Soccer XXX, where XXX is your initials. 3. Open the Roster table. 4. Enter the following record for a new player: Eric Parkinson, 806-555-0170, uniform number 9 5. One player has quit the team, Russell King. Replace his data with this data for the following new player: George Jiang, 806-555-0123, uniform number 4 6. In the Size eld, enter XS for each player, except for uniform numbers 4, 6, and 7, which should be size S.
77
The Medical Alert le for this lesson is available on the book companion website or in WileyPLUS.
GET READY. LAUNCH Access if it is not already running. 1. OPEN the CharityEvent XXX database you created in Project 3-1. 2. Open the Donations table. 3. Create a lter to display the items in the Needs eld without Commitments from a company. 4. Remove the lter. lter. te e 5. Use Find and Replace to nd each occurrence of the word Com nd and Replace d d occurrence ccurre Company in the Needs eld replace Volunteer. and replace it with the word Volunteer. epl o 6. Create a relationship between the ID eld in the Contacts table and the Committed Ce Create relationship betwee ti nship between nshi tw the h Company C Company ID in the Donations table. in Donations t ti n 7. Print the relationship. 7. Print 8. Close the relationship without saving. 8. Close the relationship without saving. Close h los tionship i p o vin 9. Close the tables. 9. Close the o 10. CLOS the database. 10. CLOSE the database. 0 OSE h O e CLOSE Access. CLOSE Access. ss
Name, Lo Name, Location, Phone Number, and Hours of Operation. me e Phone Number, n Insert data for the ve coffee shops you found. If you feel data ve coffee sho ready for a challenge, create the tab in a new database. table e e, create