Illustrated Access 2013 Unit A: SAM Project 1a Contact Management Database CREATING A TABLE AND BUILDING A RELATIONSHIP Project Goal PROJECT DESCRIPTION Your sales manager created a database with one table named Customers that stores the company name and contact information for customers. He asks you to create a new table named SalesReps Project Goal to store company sales representative data. You ll create the new table and add two records to it. Then you ll create the relationship between the SalesReps and Customers tables. *Follow all instructions for getting started just as you have learned from the other programs. Click Enable Content if necessary. GETTING STARTED M Project Name Download the following file from the SAM website: o IL_Access2013_UA_P1a_FirstLastName_1.accdb Open the file you just downloaded and save it with the name: o o IL_Access2013_UA_P1a_FirstLastName_2.accdb Hint: If you do not see the.accdb file extension in the Save file dialog box, do not type it. Access will add the file extension for you automatically. Open the _GradingInfoTable table and ensure that your first and last name is displayed as the first record in the table. If the table does not contain your name, delete the file and download a new copy from the SAM website. Note to students from your instructor: The black text is the original text from the start file. The blue text is my explanation of what you are about to do. The red text will be the detailed instructions and explanations. You do not follow the instructions in black and then follow the instructions in red too. If you do that you will be performing each task two times. If you understand the black text without any additional instruction, then it is fine to follow those instructions. However, if you need extra help, then read the blue text and follow the instructions from the red text. PROJECT STEPS Access is a data base program where you can store, organize, and manipulate large amounts of data. Using Access, you are able to create objects called tables, queries, forms, and reports. In this first step, you will create a table. A table is an Access Object made up of records and fields. A record is all the related information, such as a first name, last name, phone number, and address, that relates to one person or place for example. A field is the column of particular information such as first names, from the table. There is more than one way to view the objects in Access. In this first step you will work in Design View and not datasheet view. You will learn to recognize the difference between the views.
a. Create and save a new table in Design view with one field as follows: b. Add a field with the name SalesRepNum and a Number data type. c. Set SalesRepNum field as the table s primary key. d. Save the table with the name SalesReps. *You have opened an Access file that already has two tables created. You will see them on the left side of the program. You are about to create another table. Click the Create Ribbon, Tables Group, Table Deisgn. You just started a Table in Design View. Type SalesRepNum in the space below the Field Name label. You named the field, which will be a column of information. Click in the space under Data Type and choose Number to specify the type of data you will be using in this field. You are specifying that the type of data that belongs in this field will be a number. Click the Design Ribbon, Tools Group, Primary Key. You will observe a small key symbol to the left of SalesRepNum. *A primary key is a field with values that are unique throughout a table. Values of the key can be used to refer to entire records, because each record has a different value for the key. Each table can only have one primary key. Once you specify that a certain field is primary, you will not be able to enter duplicate values in that field. Click the save button and name the table, SalesReps. Click OK. Observe that the tab in the upper left of the table now shows the name you have assigned to the table. e. In Table Design View, add another field to the SalesReps table using the field name RepFirst and a Short Text data type. You will continue to add fields to the table. Click in the space below SalesRepNum and type RepFirst Tab or click into the Data Type column and verify or change the Data Type to Short Text. f. In Table Design View, add a field to the SalesReps table using the field name RepLast and a Short Text data type. Click in the space below RepFirst and type RepLast Tab or click into the Data Type column and verify or change the Data Type to Short Text. g. In Table Design View, add a field to the SalesReps table using the field name HireDate and a Date/Time data type. Click in the space below RepLast and type HireDate Tab or click into the Data Type column and change the Data Type to Date/Time. The Data Type limits the entries in the field to the type of data you have specified.s
h. In Table Design View, add a field to the SalesReps table using the field name StartingSalary and a Currency data type. Save the SalesReps table and switch to Datasheet View. Click in the space below HireDate and type StartingSalary Tab or click into the Data Type column and change the Data Type to Currency. Click the Save button, or click File/Save. On the Design Ribbon, Views Group, click the drop down on the ViewButton and switch to Datasheet View. Now you can see the Database you desiged in datasheet view. Each field you named and created will represent a column of data.this is more of a horizontal view where working in design view is more of a vertical view that is useful during the design phase. In design view, you will also have easy access to the property settings for each field. i. Enter the two records shown in Table 1 below into the SalesReps table. Save and close the SalesReps table. Type the information shown below into the correct columns of the database. (Use the tab key to move to the right) Click the Save Button. Click the X in the upper right corner of the SalesReps Table to close the table. Table 1: SalesReps Data SalesRepNum RepFirst RepLast HireDate StartingSalary 1 Jonathan Plank 1/1/14 $41,000.00 2 Tia Lee 2/1/14 $41,500.00 You just added two records of data to the table you created in design view. Datasheet view is an easy view for adding data. j. Open the Customers table in Table Design View and change the name of the First field to ContactFirst and the name of the Last field to ContactLast. Right click the Customers Table and click Design view to open the table in design view. Design view also gives you field properties that you are able to set while you are in design view. You will notice many additional property settings in the lower half of the screen. The power of Access is that you can define many properties to help maintain the integrity of the data that is entered into the table. You are about to modify field names and other data settings in this table. Click in the space containing First and change the field name from First to ContactFirst Click in the space containing Last and change the field name from Last to ContactLast
k. In the Customers table, Change the data type property of the Comment field to Long Text. Click in the Data Type space for Comment and change to Long Text. l. Add a new field to the Customers table after the Comment field. The field should be named SalesRepNum and have the Number data type. Save and close the Customers table. Click into the space under Comment and type SalesRepNum Change the Data Type to Number. Click the Save Button Click the X in the upper right of the table to close. You should notice that you had already created a field name in the SalesReps table you worked on earlier, with a field named SaleRepNum. You just added a field to the Customers table that used the exact field name. A relationship can be established between the two tables. m. Open the Relationships window, and then add the Customers table and the SalesReps table to the Relationships window. Close the Show Table dialog box. Create a one-to-many relationship between the SalesReps and Customers tables using the common SalesRepNum field. (Hint: Resize the field list for the Customers table so that all fields are visible in the field list.) Enforce referential integrity on the relationship. Save and close the Relationships window. Part of the power of Access is that you can create relationships between tables. That is why Access is often referred to as a relational database. When there is a common field shared among tables, you can create a relationship to relate those tables together. This eliminates having repetitive data from one table to another. You are about to create a relationship between the Customers table and the SaleReps table using the SalesRepNum as the related field. Click the Database Tools Ribbon, Relationship Group, Relationship Button. On the Design Ribbon, Click the Show Table Button. The Show Table dialog box will show a list of all tables in the current database. You are about to add the tables you want to link to the relationships window. Select the Customers Table and click Add. Select the SalesReps Table and click Add. Close the Show Table window. The table field names are now showing in a box with the table name at the top. These boxes can be moved by dragging the title bar of the box. Now, you are about to resize a box. Position your mouse over the lower right corner of the Customers box and look for a diagonal arrow. Click and drag to show all the fields. To create the connection between tables, you click over a field name and drag to a field name in another table. Point the mouse over SalesRepNum in the Customers Table and drag to
SalesRepNum in the SalesRep Table. You will see a small box with a + sign. Release the mouse. Check Enforce referential integrity. Click Create. *Observe that you have created a relationship between two tables. Because of this relationship, you will be able to create other tables, queries, forms or reports, that use information from both tables. The relationship is established because you use the same information in the SalesRepNum field of both tables. When you checked Enforce Referential Integrity, you are setting up a rule that will not allow you to delete records from one table if they are used in another table. Click the X button in the upper right of the relationships window. Answer Yes to saving. n. Open the Customers table in Datasheet view, and resize the CompanyName field to be as wide as needed to display all of the data in the field. Save the Customers table. Double click the Customers Table to open in Datasheet View. Double clicking a table name will always open it in datasheet view. Position the mouse over the line to the right side of the CompanyName label (at the top of the table) and double click to expand the column width. Click the Save button. o. Find, select, and delete the record with a CompanyNum field value of R12668 (and the CompanyName field value of KBR) from the Customers table. Use Find (Ctrl/F), or locate the CompanyNum R12668. Position the mouse to the left side over the gray space. The mouse will change to a dark arrow pointing to the right. Click when you see the arrow to select the record. Press Delete on the keyboard. Click Yes to delete. p. Navigate to the record with a CompanyNum field value of R14855 (and the CompanyNamefield value of Petrohawk), and add a value of 1 in the SalesRepNum field. Use Find (Ctrl/F), or locate the CompanyNum R14855. Tab to the SalesRepNum Field. Type 1 in the field. Press Enter. The SalesRepNum field is the field you have just created a relationship with to the name field in the SalesReps table. Jonthan Plank is SalesRepNum 1 in the SalesReps table. Even though Jonthan Plank is not listed in the Customers table, you would be able identify the sales rep for this customer because of the relationship you have established between tables. q. Navigate to the previous record (with a CompanyNum field value of R14420 and CompanyNamefield value of Moody National Bank), and add a value of 1 in the SalesRepNum field. Save and close the Customers table.
Use Find (Ctrl/F), or locate the CompanyNum R14420. Tab to the SalesRepNum Field. Type 1 in the field. Press Enter. You just established that Jonathan Plank is the sales rep for Moody National Bank. When you set up the SalesReps table, you added two sales reps to the table. You have two sales reps and their numbers are 1 and 2. You just modified the Customers table to show who the Sales Rep is for two different customers. Both of those customers are assigned to Sales Rep 1, who is Jonathan Plank. In another step, you will see relationship between the two tables. Click the X button in the upper right corner of the Table and answer Yes to save. r. Open the SalesReps table in Datasheet view, and then expand the subdatasheet for SalesRepNum 1. (Hint: You should see the two related records from the Customers table.) In the subdatasheet, find the record with a CompanyNum field value of R14420. In that record, change the value of the CompanyName field to First National Bank. Close the SalesReps table. Double click the SalesReps table to open in Datasheet View. Observe the + sign to the left. This indicates there is a relationship established and there are subsets of information as a result of the relationship between tables. Click the + sign to the left of SalesRepNum 1. Observe the two records in the Subdatasheet. In CompanyNum R14220, change the Company Name to First National Bank You were in the SalesReps table when you expanded to view the subset of data, but you were able to modify the CompanyName from the Customers Table through the SalesReps table, even though that data is actually stored in the Customers Table. That is the result of creating a relationship between the tables. Save and close any open objects in your database. Compact and repair your database, close it, and exit Access. Follow the directions on the SAM website to submit your completed project. Click the X in the upper right of any open object window that may be open. Answer Yes to saving if necessary. Click File/Compact and Repair. Close Access. Submit your completed project for grading. You will find your graded report in the Reports section of your SAM account. Download and open the file. On the left side, you will see a report has been created named _GradingReport Double click _GradingReport to view the results.