4
Access Module 1 Databases and Database Objects: An Introduction Access Lab 1-1: Creating Objects for the Garden Naturally Database For ALL Access labs: If the instructions add records, do not remove them at the end of the lab. If records are deleted by the instructions, do not put them back. For each Access lab after the first one, continue working from the results of the previous Access lab. You will use this same database file for 5 labs. That is, never UNDO any changes to the database made by the instructions or this addenda. You should, of course, correct mistakes discovered in grading. The point is that the lab instructions for each lab are based on everything you did in the previous lab. Notes for this lab: 1. You will be creating 2 TABLES in a SINGLE Database file (which is started for you). Read the instructions carefully and use the names shown in the instructions for your table names. 2. When the book says "Create a query", it means you are required to print the results (an ordinary Print command for the table view which appears when you run the query). The only thing you hand in are printed results. Do NOT submit the actual database. 3. Make sure you save your database on your H: drive so your instructor can get to it in the office, if you have a problem. Problem: “Garden Naturally” is a company that provides products for the organic gardening community. Sales representatives are responsible for selling to distributors, nurseries, and retail stores. The company recently decided to store its customer and sales rep data in a database. Each customer is assigned to a single sales rep, but each sales rep may be assigned many customers. The database, “Lab 1-1 Garden Naturally Database” containing the starting Sales Rep table field definitions (no data) have been created for you, but the Salary YTD field needs to be added to the table. The records shown in Table 1-6 must be added to the Sales Rep table. The company plans to import the Customer table from the Excel worksheet shown in Figure 1-86. Garden Naturally would like to finish storing this data in a database and has asked you to help. Instructions: Perform the following tasks: 1. Run Access, open the Lab 1-1 Garden Naturally database from the Data Files in the Downloads section of Prof. Foreman’s website, enable the content, then click on File, then Options (at the bottom of the list). Click on Object Designers. In the Query section, click on Enable Autojoin. Click OK. You will need this for Access 2-1, and beyond. Use SAVE AS to save the DB on your H: drive. Use the SAME NAME as the file you opened, just change the folder to the H: drive. 2. Open the existing Sales Rep table in Datasheet view and add the Salary YTD field to the end of the table. The field has the Currency data type. Assign the caption SR# to the Sales Rep Number field’s Design. 3. Add the records shown in Table 1-6. (You have to enter this data by hand, in the Table View.)

Access Module 1 Databases and Database Objects: An ...dforeman.cs.binghamton.edu/~foreman/105pages/2018... · Access Module 1 Databases and Database Objects: An Introduction 13. Create

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Access Module 1 Databases and Database Objects: An ...dforeman.cs.binghamton.edu/~foreman/105pages/2018... · Access Module 1 Databases and Database Objects: An Introduction 13. Create

Access Module 1 Databases and Database Objects: An Introduction

Access Lab 1-1: Creating Objects for the Garden Naturally Database

For ALL Access labs: If the instructions add records, do not remove them at the end of the lab. If records are

deleted by the instructions, do not put them back. For each Access lab after the first one, continue working from

the results of the previous Access lab. You will use this same database file for 5 labs. That is, never UNDO any

changes to the database made by the instructions or this addenda. You should, of course, correct mistakes

discovered in grading. The point is that the lab instructions for each lab are based on everything you did in the

previous lab.

Notes for this lab:

1. You will be creating 2 TABLES in a SINGLE Database file (which is started for you). Read the instructions

carefully and use the names shown in the instructions for your table names.

2. When the book says "Create a query", it means you are required to print the results (an ordinary Print command

for the table view which appears when you run the query). The only thing you hand in are printed results. Do

NOT submit the actual database.

3. Make sure you save your database on your H: drive so your instructor can get to it in the office, if you have a

problem.

Problem: “Garden Naturally” is a company that provides products for the organic gardening community. Sales

representatives are responsible for selling to distributors, nurseries, and retail stores. The company recently decided to

store its customer and sales rep data in a database. Each customer is assigned to a single sales rep, but each sales rep

may be assigned many customers. The database, “Lab 1-1 Garden Naturally Database” containing the starting Sales Rep

table field definitions (no data) have been created for you, but the Salary YTD field needs to be added to the table. The

records shown in Table 1-6 must be added to the Sales Rep table. The company plans to import the Customer table from

the Excel worksheet shown in Figure 1-86. Garden Naturally would like to finish storing this data in a database and has

asked you to help.

Instructions: Perform the following tasks:

1. Run Access, open the Lab 1-1 Garden Naturally database from the Data Files in the Downloads section of Prof.

Foreman’s website, enable the content, then click on File, then Options (at the bottom of the list). Click on Object

Designers. In the Query section, click on Enable Autojoin. Click OK. You will need this for Access 2-1, and

beyond. Use SAVE AS to save the DB on your H: drive. Use the SAME NAME as the file you opened, just change the

folder to the H: drive.

2. Open the existing Sales Rep table in Datasheet view and add the Salary YTD field to the end of the table. The field

has the Currency data type. Assign the caption SR# to the Sales Rep Number field’s Design.

3. Add the records shown in Table 1-6. (You have to enter this data by hand, in the Table View.)

Page 2: Access Module 1 Databases and Database Objects: An ...dforeman.cs.binghamton.edu/~foreman/105pages/2018... · Access Module 1 Databases and Database Objects: An Introduction 13. Create

Access Module 1 Databases and Database Objects: An Introduction 4. Resize the columns (as you did in Excel) to best fit the data (this is NOT the same as “fit to page”). Save the

changes to the layout of the table. You do NOT have to save the whole database unless Access asks if you want to.

Changes to DATA are AUTOMATICALLY saved.

5. Creating the Customer Table:

a. Import (see the book for instructions) the Lab 1-1 Customer workbook (an Excel file, as shown in Figure

1-86,) from the Data Files in the Downloads section of Prof. Foreman’s website into the database. The

import operation saves you from typing all the information for the table. Click on “First row contains

column headings. Click on “Choose own primary key”. Customer Number will now be the 1st column and

will become the primary key for the new table, note that it is NOT an actual number. It is a “short text”

field of length 4. Access will properly guess the TYPE of each field but you MUST verify that they are the

proper SIZE in the Design View and change them if needed. Assign the name Customer to the table. Save

the Import steps, and assign the name Import-Customer Workbook to the steps, so you can reuse it if

your DB is damaged. Assign Import Customer Workbook as the description.

b. If you see a field called ID in the Table View, it means you did not follow the instructions correctly. To

fix it do the following steps (i - vi)

i. Open Design view for the table

ii. Click on the field that has the key symbol on its left (its name will be ID)

iii. Click on the key icon on the ribbon. The key symbol will disappear from in front of the field.

iv. Now delete the ID field.

v. Now click on the field that is supposed to be the key (Customer Number)

6. Open the Design view of the Customer table (if it isn’t open)

a. Be sure Customer Name is 25 characters long.

b. Customer Number & Service Rep Number are not numbers (they are TEXT fields). Be sure the Sales Rep

Number field is 2 characters. You MUST change it in BOTH tables. And its name must be spelled

EXACTLY the same way in both.

c. Postal Code is a 5 character TEXT field. That's because zip codes beginning with zero would lose the zero

if they were numeric.

d. Be sure to change the alignment for Postal Code to "right".

7. In the Sales Rep Data table, add a record with your name as the rep with the following values:

Sales Rep Number: 40

Monthly Salary: $4,000

Remaining data for THIS entry is required, but up to you.

8. In the Customer Data table, add the following record. Substitute your initials, first name then last name, for

"ZZ" in both places. e.g.; my ZZ would be DF:

Customer

Number

Customer Name Street City State Postal

Code

Balance Amount

Paid

Sales Rep

Number

XXZZ ZZ's Styles 999 9th Richmond VA 23233 $500.00 $1350.00 40

Page 3: Access Module 1 Databases and Database Objects: An ...dforeman.cs.binghamton.edu/~foreman/105pages/2018... · Access Module 1 Databases and Database Objects: An Introduction 13. Create

Access Module 1 Databases and Database Objects: An Introduction

9. Open the Customer table in Design view and make the following changes:

a. Change the field size for the Customer Number field to 4. Change the field size for the Customer Name field

to 30. Change the field size for the Address field to 25 and the field size for the City field to 20. Change the

field size for the State field to 2 and the field size for the Postal Code field to 5. Change the field size for the

Sales Rep Number field to 2.

b. Add the caption CU# to the Customer Number field. This is done in the Design View, at the bottom of the

screen, under the heading “field properties”, when you click on the field name.

c. Add the caption SR# to the Sales Rep Number field.

10. Save the changes to the Customer table. If a Microsoft Access dialog box appears with the ‘Some data may be lost'

message, click the Yes button.

11. Open the Customer table in Datasheet view and resize all columns to best fit the data. Save the changes to the

layout of the table.

12. Create a query using the Simple Query Wizard for the Customer table that displays the Customer Number,

Customer Name, Amount Paid, Balance Due, and Sales Rep Number. Save the query as Customer Query. For future

lab reference, notice that in all query instructions, ONLY the fields named with capital letters are included in ANY

query, list or report, unless the instructions say to include ALL fields or they do not list any specific fields (in both

cases you include ALL fields).

Page 4: Access Module 1 Databases and Database Objects: An ...dforeman.cs.binghamton.edu/~foreman/105pages/2018... · Access Module 1 Databases and Database Objects: An Introduction 13. Create

Access Module 1 Databases and Database Objects: An Introduction

13. Create the Customer Financial Report shown in Figure 1-87 for the Customer table. The report must include the

Customer Number, Customer Name, Amount Paid, Balance Due, and Sales Rep Number fields. Include totals for

the Amount Paid and Balance Due fields. Be sure to change the column headings to those shown in Figure 1-87.

Save the report as Customer Financial Report.

14. Change the entry for Pat Jones in the Sales Rep table to your name. Leave the address alone.

15. ****Print each of the completed tables in List view.

a. Switch to Design view of the Sales Rep table, take a screen shot of your entire screen. Open Word and

press CTRL-V to paste the clipboard. Print that screenshot. Discard the Word file.

b. Repeat step “a” for the Design View of the Customer table.

16. The Commission Rate field has a field size of Single. If you changed the field size to Integer, what values would

appear in the Commission Rate column? Try it to see what happens. Why? Hand write your answer on the last

page of step 12. UNDO this change. Close your DB.