isds 351

Tonyttttt
Lecture08-UsingMSAccess.pptx

Using Microsoft Access 2016

1

Study Questions

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

Q1: How do you create tables?

Q2: How do you create relationships?

Q3: How do you create a data entry form?

Q4: How do you create queries using the query design tool?

Q5: How do you create a report?

CE5-‹#›

2

This chapter extension discusses fundamental techniques for creating a database and a database application with Microsoft Access 2010, 2016.

PROSPECT (ProspectID, Name, Street, City, State, Zip, Email Address)

WORK (ProspectID, Date, Hour, NumCalls, TotalDonations)

Create tables from data model

Select primary keys

Select foreign keys

Link tables

Q1: How Do I Create Tables?

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

3

Note the ambiguity in name PROSPECT. Before someone has become a volunteer, he is a prospect, and the term is fine. However, once that person has actually done work, he is no longer merely a prospect. This ambiguity occurs because the database is used both for finding volunteers and for recording their experiences once they have joined.

Attributes of the Database

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

This figure further documents the attributes of the design. Sample data for this table are shown in Figure CE5-2.

4

Sample Data

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

5

Opening Access 2016

CE5-‹#›

6

If you use another version of Access, your screen will appear differently, but the essentials will be the same.

Opening Access 2016

CE5-‹#›

7

If you use another version of Access, your screen will appear differently, but the essentials will be the same.

Creates Default Table Named Table1

CE5-‹#›

Access opens the new database by creating a default table named Table1. We want to modify the design of this table, so in the upper left-hand corner, where you see a pencil and a right angle square, click View and select Design View.

8

Click on Blank database

Enter file name in lower right-hand corner box

Click on folder icon to browse to a folder to save database

Click on Create

Blank table opens

Review: Sequence of Steps for Creating a Database with Access 2016

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

9

Use this figure to review the steps presented in previous slides.

Creating a Database with Access 2016 (cont’d)

Click View icon

Select Design View in drop-down list

Enter table name in pop-up box

Window changes to Design View

CE5-‹#›

Explain Access View modes

10

Creating Tables in Access - Step 1: Declaring Field Names and Data Types

Upper part

Enter name of each attribute (Fields)

Enter Data Type

Enter Description

Bottom part

Declare field properties

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

11

Creating Tables in Access - Step 2: Declaring Field Properties

Setting length of a Text Data Type

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

12

Figure shows how to set the length of a Text Data Type.

Complete Sample PROSPECT Table

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

ProspectID is the primary key of this table, and the little key icon next to the ProspectID Field Name means Access has already made it so. If we wanted to make another field the primary key, we would highlight that field and then click the Primary Key icon in the left-hand portion of the Design ribbon.

13

Finished WORK Table

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

Save table

Select Primary Key

Declare Field Properties

Enter Data Types

Enter Field Names

Overview of Steps in Creating Tables

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

15

Go to Database Tools

Select Relationships

Show Table dialog box opens

Double-click on names of tables

Tables added to Relationships window

Close Show Table dialog box

Q2: How Do I Create Relationships? Step 1

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

16

Show Table Dialog Box in Access

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

17

Click the Database Tools tab in the ribbon and then click the Relationships icon near the left-hand side of that ribbon. The Relationships window will open and the Show Table dialog box will be displayed.

Click on attribute in one table

Drag it to attribute in second table

Dialog box appears

Click Enforce Referential Integrity

Click Cascade Update Related Fields

Click Cascade Delete Related Fields

Close Relationships window

Save changes

Creating a Relationship Between Two Tables: Step 2

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

18

Creating a Relationship Between Two Tables: Step 2 (cont’d)

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

19

Click Enforce Referential Integrity, click Cascade Update Related Fields, and then click Cascade Delete Related Records. The specifics of these actions are beyond the scope of our discussion. Just understand that clicking these options will cause Access to make sure that ProspectID values in WORK also exist in PROSPECT.

Completed Relationship Between PROSPECT and WORK Tables

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

∞ means one PROSPECT row can be related to an unlimited number of rows in WORK

CE5-‹#›

20

PROSPECT Table with Data Entered

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

WORK Table with Data Entered

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

Q3: How Do I Create a Data Entry Form?

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

Use default table display

CE5-‹#›

23

Table display, although convenient, is limited in capability. It also does not provide a very pleasing user interface. For more generality and better design, you can use the Access form generator.

Form Generator

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

Starting the Form Generator

CE5-‹#›

24

Resulting Data Entry Form

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

25

Access uses metadata about the tables and their relationship to create the data entry form in Figure CE5-15.

Reformatted Data Entry Form

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

26

Process for Reformatting Data Entry Form

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

Use SQL query language

Use graphical interface to create queries

Click Queries

Click Query Design

Show Table, Add

Query Design form

Q4: How Do You Create Queries Using the Query Design Tool?

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

Run !

CE5-‹#›

28

Like all modern DBMS products, Access can process the SQL query language.

Creating a Query: Step 1 (Select and Add Tables)

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

29

Step 2: Query Design Form

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

30

Notice that Access shows the relationship between the two tables.

Creating a Query: Step 3

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

Note that the Ascending keyword has been selected for the Name column.

Click the red exclamation point labeled Run in the Results section of the ribbon.

31

Results of TotalDonations Query

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

32

Results of More Advanced Query

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

Click Create

Select Report Wizard

Table/ Queries

Highlight table and fields

Click >

Add fields

Select table, add fields

Click Finish

Q5: How Do I Create a Report?

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

34

Selecting Data to Show in a Report

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

35

This figure shows the Report Wizard. To create a report with data from two or more tables, we must use the Report Wizard.

Click the Create tab, and then in the Reports section click Report Wizard.

Report on Donations by Prospect

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

36

Report Design View

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

Click Group & Sort in Grouping & Totals

Click More

Click down arrow to “with no totals”

Click Report icon in View

See result next slide

Grouping and Totaling

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

Creating a Sum of TotalDonations for Each Prospect

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

CE5-‹#›

In the ribbon, click Group and Sort in the Grouping & Totals section. In the bottom of the form, click More, and then click the down arrow next to the phrase “with no totals.” Next, select TotalDonations from the TotalOn box, and then check Show Grand Total and Show subtotal in group footer.

39

Report with Sum of TotalDonations

CE5-‹#›

The only remaining problem is that label NumCalls is cut off. We need to expand the box that contains this value. To do so, select Layout View from View in the ribbon, click Date, and then slide it slightly to the left. Do the same with Hour. Then expand NumCalls until you can see all of the label.

40

Increasing Size of Fields

Select Layout View from View in the ribbon, click Date. Slide it slightly to left. Do same with Hour. Expand NumCalls.

CE5-‹#›

41

Final Version of Report

CE5-‹#›

Active Review

Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall

Q1: How do you create tables?

Q2: How do you create relationships?

Q3: How do you create a data entry form?

Q4: How do you create queries using the query design tool?

Q5: How do you create a report?

CE5-‹#›

CE5-‹#›