Microsoft Office Access 2013

Transcription

Microsoft Office Access 2013
Microsoft Office Access 2013
Content

















Lesson 01: Introduction
Lesson 02: What is a Database?
Lesson 03: Objects
Lesson 04: Thinking about Database Design Worksheet Views
Lesson 05: Plan Database Tables
Lesson 06: Create a Sahalsoftware Database
Lesson 07: Switching Views
Lesson 08: Validation Text
Lesson 09: Using Field Properties to Ensure Data Integrity
Lesson 10: Building Table Relationships
Lesson 11: Understanding Types of Relationships
Lesson 12: Adding and Editing Data in Tables
Lesson 13: Test 2
Lesson 14: Forms
Lesson 15: Using Queries to Make Data Meaningful to You
Lesson 16: Reports
Lesson 17: Test 3
Microsoft Office Access 2013
Lesson 01: Introduction
Microsoft Office Access 2013
These Lessons will show you how to build a database from scratch, including how
to:






plan
set up tables and fields
create and use forms to enhance data integrity
design
run meaningful queries
Create useful and attractive reports.
Lesson 02: What is a Database?
A database allows you to store information related to a specific topic in an
organized way. In addition to storing data, you can also sort, extract, and
summarize information related to the data. One of the software programs that allow
you to do.
Microsoft Office Access 2013
This is Microsoft Office Access 2013, which is a database creation and
management program.
Exploring Databases







Creating Database
Open Access 2013
Click Blank Desktop Database
Give name: Test
Ok
Click Create
Note: the location you’re saved by default is document
Environmental of Database (MS-Access Window)









Ribbon
Tabs (Home, Create, External Data, Database Tools, Field and Tables)
Quick Access Toolbar
Backstage View
Navigation Pane
Shutter Bar Button (to Close or Open Navigation Pane)
Title bar
Status bar
View Option (Datasheet View and Design View)
Microsoft Office Access 2013
Lesson 03: Objects
A database is made up of several components, or objects. These objects include:




tables
queries
forms
reports
Tables
A table is the database object that contains the basic information you wish to store.
A blue and white icon represents the table in the Navigation Pane.
Table contains:
 Record (Row)
 Field (Column)
Queries
Another database object is called a query. A query allows you to retrieve
information from one or more tables based on a set of search conditions you define
using the table fields.
Microsoft Office Access 2013
Forms
A third database object is the form. Forms are an Access tool that users can create
to make data entry in database tables easier.
Entering data directly into a table can be difficult if there is a lot of information to
enter. Like an Excel spreadsheet, an Access table is essentially a screen filled with
blank rows where a user enters records. Forms, however, provide users with an
easy-to-read interface where they can enter table data. Forms are especially useful
for Access users that aren’t comfortable working with databases.
Reports
The final database object is the report. A report is an effective way to analyze and
present data using a specific layout. The text can be formatted in an Access report,
just like it can be in Word documents.
Lesson 04: Thinking about Database Design
The first step in creating a database is to think about:




Why you need it?
What is its purpose?
What kinds of information will it store?
How will I have to break that information down?
Once you know that, you can begin designing your own database
Microsoft Office Access 2013
Designing a Database
The Sahalsoftware Bookstore
The best way to learn about designing a database is to jump right into the process.
Let's pretend we work for the Sahalsoftware bookstore and we need to build a
database for the store to use. Let's think about what we might need the database to
do for us. The following diagram shows that we have customers, and we sell books
via orders both in the store.
Determine the Purpose of the Database
The first step of designing a database is to determine the purpose of the database.
What do we need it to do? At Sahalsoftware, our customers will place orders for
books. we will want our database to track the books we sell, the customers we sell
them to, and the date of each of the orders.
The database will also be able to tell us where our customers live when we need to
send those books. Additionally, we can use it to track our sales or to make a
bestseller list to post in the store.
Microsoft Office Access 2013
Lesson 05: Plan Database Tables
Once you have established the purpose, you can begin brainstorming about how to
break the information up into the tables that your database will need to store the
data. Recall that a table is a collection of records and each record is broken up into
the smallest pieces of needed information, called fields. Since we are planning a
database to track our customers, the books we have, and the orders our customers
place, we will need a table for each one of these.
Sahalsoftware Tables
 Customers
 Orders
 Books
Setting up Tables and Fields
Creating a Table
First Create a Database Called Sahalsoftware
Click Save and give Books
Rename Table
 In the Navigation Pane select your Table
 Right-click
 Select Rename
Creating New Table
 Click Create Tab
Microsoft Office Access 2013
 Click Table
 Save
Delete Table
 In the Navigation Pane select your Table
 Right-click
 Select Delete
Finally, Create Sahalsoftware Tables
 Customers
 Orders
 Books
Lesson 06: Switching Views
To switch views, select the Views command group from either the Home tab or
View Options.
Access 2013 lets you control how data can be entered in each table field within
your database. This is done using Data Type. The default Data Type is short text
Microsoft Office Access 2013
for every field after the ID field, which was set to autonumber. You can change the
Data Type setting:






AutoNumber,
Short Text
Number
Date/Time
Yes/No
etc
Microsoft Office Access 2013
Lesson 07: Designing Tables and Fields
Table Name: Customers
Fields
CustomerID
FirstName
LastName
Street
City
State
Zip Code
Email
Data Type
Auto number
Short Text
Short Text
Short Text
Short Text
Short Text
Number
Short Text
Table Name: Books
Fields
BookID
AuthorFirst
AuthorLast
Price
Category
Data Type
Auto number
Short Text
Short Text
Currency
Short Text
Table Name: Orders
Fields
OrderID
CustomerID
BookID
Date
Data Type
Auto number
Number
Number
Date/Time
Microsoft Office Access 2013
Data Validation
Data Validation is a very important database concept. It is the process by which
Access tests the data that is being entered into the database, to make sure it is in an
acceptable, or valid, format. Imagine that one of your database users has entered an
order date of January 4, 2013 in the month/date/year format, as 01/04/2013.
Another user has entered an order placed on that same date in the day/month/year
format, as 04/01/2013. Now, if the database is tracking all sales for the month of
January 2013, it may not show both orders as placed in January, even though both
were placed on the same date. Access 2013 allows you to set field properties and
data validation rules, to force the person entering data to follow a specific format.
Data Types and Validation Rules
Data Validation begins when data types are set during the process of building
tables and fields. For example, if a field data type had been set to Currency and a
text value is entered in that table field during data entry, Access will not accept an
invalid format and will display a validation error.
Setting Data Validation Rules
In Design View, highlight the field that requires a validation rule.
In the Field Properties section at the bottom half of the window, set your validation
rule using the Expression Builder. The expression builder offers common syntax to
set up a data validation rule.
Microsoft Office Access 2013
In the design view (Book) select Category Field, then select Validation Rule
Go datasheet view and then save.
Lesson 08: Validation Text
Validation Text is a specialized error message that you can set to have Access tell
the person entering data the specific way you would like them to enter it. To set the
Validation Text, enter the error message exactly as you want it to appear to your
user in the row directly beneath the Validation Rule row in the Field Properties
section of Design View. For the validation rule that we set for Category, you
would set the validation text like this:
Microsoft Office Access 2013
Lesson 09: Using Field Properties to Ensure Data Integrity
Another way to ensure data integrity is by setting field properties such as Field
Size, Format, and Required.
Field Size can be set to hold a specific number of characters, up to as many as 255
for text fields. If you were using a text field to hold the two letter state postal
abbreviation, the field size could be set to 2 to ensure that no one enters a full state
name into this field.
The Format field property can be set to display text or numbers in a standardized
way. For example, text can be set to show as all uppercase and numbers can be set
to show scientific numbers, percentages, or decimals.
Microsoft Office Access 2013
Set the Required property to Yes if you want the person entering data to be
required to enter something in the field. Choose No if the person entering data is
allowed to leave the field blank.
These are just some ways Access helps you ensure that data being entered into
your database is valid.
Microsoft Office Access 2013
Lesson 10: Building Table Relationships
By now, you have set up the tables you need for your database, and created fields
for those different tables. Relationships provide Access 2013 with the means to
bring that information together for you when you need it. This lesson explains how
to establish relationships between the tables in an Access 2013 database. You will
learn how to read and manipulate the relationship map. You will also learn about
Primary and Foreign Keys, relationship types, and about referential integrity.
Relationships





First, Create Customer table, Order table, Books and their Fields.
Click Database Tools
Click Relationships
Select each table and Add button
Then click Close
To join tables:
Microsoft Office Access 2013






Drag CustomerID Primary key and Release to tblOrdersCustomerID
Dialog box will appear, check Enforce Referential Integrity
Then click create button
This relationship called one-to-many Relationship.
Another Relationship between tblOrders and tblBooks
To join tables, Drag BookID from tblOrders Primary key and Release to
tblBooksBookID
Understanding the Relationship Map
The relationship map lists all of the tables that were selected to relate, and all of the
fields that were set up for that table previously. Notice that the first field has a key
icon next to it. This is the Primary Key for the table.
Primary and Foreign Keys
A Primary Key is the first field in each table of the database. You may recall that
this field auto numbers by default, so that every record in the table has its own
unique number to identify it. Access uses this number to quickly pull information
together for you when you run queries or reports, which are covered later. In the
example above, the primary key for the Customers table is Customer ID, the
primary key for the Orders table is Order ID, and the primary key for the Books
table is Book ID.
A Foreign Key is a field that is the Primary Field in its own table, but that shows
up in another table. If you look closely at the Orders table, the fields Customer ID
and Book ID appear there, as well as in their own respective tables. These fields
are the primary key in their own tables, but in the Orders table, they are considered
Foreign Keys.
Lesson 11: Understanding Types of Relationships
Microsoft Office Access 2013
Access 2013 allows for several different types of relationships. These include:
 One to One
 One to Many
 Many to Many
The relationship type you will come across most frequently, and the one created in
our bookstore scenario, is the One to Many relationship. One to Many the One to
Many relationship means that data for that field will show up a single time in one
table, but many times in the related table. For example, let's look at one of the book
titles in our bookstore. The Book ID for that book should appear only once in the
Books table, because that table lists every title that we stock. But it will probably
appear many times in the Orders table, because we hope that it gets ordered by
many people many times.
Microsoft Office Access 2013
Enforcing Referential Integrity
In the Edit Relationships dialog box, an option to Enforce Referential Integrity
appears.
You should click Enforce Referential Integrity to make sure that we NEVER have
an order for a book that doesn't appear in our Books table. Selecting this option
tells Access to check for these things when someone is working with your data
records.
Editing Existing Relationships
Access 2013 allows you to edit relationships that already exist. This is can be done
using the Edit Relationships command on the Ribbon. However, a much simpler
way is to simply double click on the link that appears in the relationship map.
Either method brings up the Edit Relationships dialog box, where you can change
your settings.
Lesson 12: Adding and Editing Data in Tables
To Add Records in the New Record Row:
 Click the record row with the asterisk that appears at the bottom of the table
(empty row).
 Type the data into the appropriate fields.
 Hit Enter or the Tab key to move to the next field.
Editing Records in Tables
Microsoft Office Access 2013
Sometimes it is necessary to edit records in the database. Like with every other
task in Access 2013, this can be done several different ways.
To Edit a Record Directly:
 Scroll through the records or use the Navigation Buttons in the navigation
bar to find the record to edit.
 Click the cell that contains the information that must be edited. A pencil icon
appears to indicate edit mode.
 Type the new information into the field.
 Click outside of the record row to apply the change
To Copy and Paste a Record:
 Select the record that you want to copy. Right click and select Copy.
 Select the new record row. Then right click and select Paste. The record
information appears, with a new record ID number.
To Delete a Record:
Select the record that you want to delete. Then, right click and select Delete
Record.
A dialog box appears, telling you the action cannot be undone and asking if you
are sure you want to delete the record.
Microsoft Office Access 2013
Note: There may be other records that rely on the record you are trying to delete.
DO NOT delete a record without knowing how it will impact the rest of your
database.
When you delete a record, that record number is permanently deleted from the
database table. If you delete the last record from a table, and then add a new
record, your new record numbers will appear to be out of sequence.
Lesson 13: Test 2
---------------------------------------------------------------------------------------------------GRAPHICAL USER INTERFACE (GUI)
---------------------------------------------------------------------------------------------------Lesson 14: Forms
A third database object is the form. Forms are an Access tool that users can create
to make data entry in database tables easier.
Entering data directly into a table can be difficult if there is a lot of information to
enter. Like an Excel spreadsheet, an Access table is essentially a screen filled with
blank rows where a user enters records. Forms, however, provide users with an
easy-to-read interface where they can enter table data. Forms are especially useful
for Access users that aren’t comfortable working with databases.
Creating and Using Forms
Microsoft Office Access 2013
Click Create tab, select Form wizard
 Select Books and all fields.
 Leave the default option
 Click next, and then Finish
Repeat these steps above and create Customers and Orders Form.
Populating a database is easy once you have a basic form in place. Record
navigation works the same way for forms as it did for tables. The Navigation Bar is
located in the bottom left of the object pane. The Navigation Buttons work the
same way they did for the tables, also. The following picture shows the navigation
buttons for a form.
To Add a Record using a Form
 To add a record to the database using a form:
 Navigate to a new record, either by using the New Record navigation button
or the new command in the Records group on the Ribbon.
 Then, simply add the new data.
 Your data must be entered using an acceptable format. The acceptable
formats were established when the field properties were set.
 Finally, you must save the record. by progressing to another record using the
New (Blank) Record navigation button
Microsoft Office Access 2013
Lesson 15: Using Queries to Make Data Meaningful to You
The real power of an Access 2013 database is in the ability to pull data for quick
analysis, which is what happens when you run a query. Queries allow you to
retrieve information from one or more tables based on a set of search conditions
you define. Access 2013 will display your results in their very own table that you
can analyze and manipulate further. This lesson will explain how to plan a query
using a three-question planning process. You will learn how to use the Query
Design command to run the query, as well as how to modify the query to hide
fields or other information in your query results. Finally, it will show you how to
save the query for later use.
Queries retrieve information from one or more tables based on a set of search
conditions that you set up and then combine that information in a way that is easy
for you to analyze. If you have used an Advanced Filter in Access 2013, then you
have already run a very basic query on only one table. If you want to pull data
from more than one table, though, you will need to use either the Query Design
command or the Query Wizard.
Before using the Access 2013 query tools, it is important to plan out the query
using a logical process. Otherwise, you may not get the results you expect.
Planning a Query
Microsoft Office Access 2013
There are three questions you need to answer when you are planning a query:
 What do you want the results to look like? Identify every field or bit of
information that you want included in the results.
 Where is the information stored in the database? List which tables (and/or
queries) hold the information that you want to see.
 What conditions do you want the data to meet? This helps determine how to
set the criteria so Access can search the records properly.
Planning: Which Customers Ordered Technology Books?
Let's think about this process for our bookstore database scenario. We have new
technology series coming out soon, and we want to send coupons to customers that
have ordered technology books from us in the past. A query can help us answer the
question: which customers have ordered technology books from us already? Let's
use the three-question process to plan this query.
What fields do we want to see in the results? We need a list of customer names and
addresses in order to mail the coupons to our customers, so we'll need the results to
show:
Microsoft Office Access 2013





In which tables is the information stored? Well, for this query we'll need:
Customers table - to get the customers' names and addresses
Books table - to know which books are technology books
Orders table - to know which customers ordered those books.
What is the condition we want the data to meet? We want Access to look for
only the books where the book's category is technology.
Once you have planned out your query, you can build and run it using Access
2013's query tools.
To Build a Query using the Query Design Command
Microsoft Office Access 2013
 To build and run a query using the Query Design command:
 Select the Query Design command from the Create tab on the Ribbon
 Use the Show Table dialog box to select which tables (and/or queries) to
include in the query. Our plan called for all three tables
 Drag and drop the fields you want to see in your results to the bottom
portion of the query design screen.
Enter the condition in the Criteria row for the condition field. For our query, we
typed Technology in the cell labeled Criteria for the Category field. As seen above,
Access 2013 puts quotation marks around the term to show it is looking for exactly
that term within the designated field.
Once the condition is set, click Run! in the Results group on the Ribbon.
Finally, view your results to determine if they match your desired results.
Hiding Fields or Other Information in the Results
Microsoft Office Access 2013
Sometimes the results of a query will include information that is seemingly
unnecessary to you. Access 2013 allows you to easily hide these fields.
 To Hide Part of the Query Result
 To hide a field in your query results:
 In the query design window, de-select the Show option by clicking on it.
Now, when you run your results, that field will be hidden.
Saving the Query
Sometimes you will not need to save your results or your query design. Other
times, you may want to keep it to run again later or to modify it slightly. Saving a
query is very easy to do.
To Save a Query




To save the query for later use:
Right click on the query tab.
When the Save As dialog box opens, give your query a meaningful name
Click OK.
The query will now be listed in the object list on the left side of the Access
window.
Microsoft Office Access 2013
To Sort via the Query Design
 To add a Sort to any field in the query design:
 Click on the Sort row for the field you wish to sort. A drop down list will
appear:
Lesson 16: Using Reports to Make Data Meaningful to Others
Now that you know how to use queries to analyze the data in a database, it is time
to find out how to create a report that will make the data meaningful to someone
else. This lesson will show you how to create a report using the Report command.
It will also show you how to use grouping options and query limits to make the
report easier to read, as well as identify several report formatting and layout
options that can be set in Layout View. Finally, you will see how to use Print
Preview and how to save the report.
As you know, queries make the data in a database meaningful to you. Sometimes,
though, you need to share that data with someone else. A report is an effective way
to present your data using an attractive layout. The text can be formatted in an
Microsoft Office Access 2013
Access report like it can be in Word documents. Microsoft Access 2013 offers
tools that allow you to create and format a report. The Report Wizard walks you
through the steps of creating a report. The Report command, however, is much
easier to use, and all of the formatting options are still available to you in
To Create Report
 Create tab/report wizard
 Read steps
Lesson 17: Test 3
END ACCESS 2013