You are on page 1of 34

PRACTICAL IT SKILLS

MS ACCESS
AICT003-4-1-PITS and Version VD1

DATABASE (PART 2)

AICT003-4-1-Practical IT Skills Module Introduction


Lecture Outline

• Review on previous lecture


• How to create queries in database?
– Examples?
• How to create reports in database?
– Examples?
• Lab Session 8 (Queries & Reports)

AICT003-4-1-Practical IT Skills Module Introduction Slide 2 of 34


Learning Outcomes

• By the end of this lecture, YOU should be able to :


– Demonstrate Query Wizard and Query Design features
– Demonstrate Report Wizard features

AICT003-4-1-Practical IT Skills Module Introduction Slide 3 of 34


Key Terms you must be able to use

• If you have mastered this topic, you should be able to use the following terms
correctly in your assignments:
– Query Wizard
– Query Design View
• query window
• run query
• design grid
• criteria
• wildcard
• comparison operator
• sorting data
• joining tables
• calculated fields
• calculate statistics
• report wizard
AICT003-4-1-Practical IT Skills Module Introduction Slide 4 of 34
Introduction to query

• An Access query
– If you want to see just a portion of the data in a table you
can create a query.
– A query is a question you ask about the data stored in a
database table.
– Query means to ask a question.
– Access responds by displaying the data according to your
question.
• For example, if you ask to see all the customers from
New York, the response would be to display only the
records whose state field matches with NY

AICT003-4-1-Practical IT Skills Module Introduction Slide 5 of 34


Introduction to query (continue…)

• You can create a query that will display only selected


fields from a table instead of displaying all fields.
• If you want to select all the fields except one, you
can move them all to the selected fields list and then
remove the one field you don't want.
• You can open an existing query by clicking Queries
on the Objects bar and then selecting the query you
want to open
• When you run and get the results of your query, you
can reorganize the data by sorting the datasheet in
either ascending or descending order

AICT003-4-1-Practical IT Skills Module Introduction Slide 6 of 34


Querying a Database

• Query Wizard
• Query Design Feature
• Query Criteria

A query allows you to select and filter data from


multiple tables.  Queries can be saved and
utilized as often as you need them.

AICT003-4-1-Practical IT Skills Module Introduction Slide 7 of 34


Query Wizard
• The Query Wizard walks you through the
steps to set up a query.  To run a query
using the query wizard:
• Click the Create tab
• Click the Query Wizard button
• Choose the type of query you wish to run
• Click OK
• Choose the fields you wish to include from each table
• To select fields from different tables, click the
Tables/Queries down arrow  Click Next

AICT003-4-1-Practical IT Skills Module Introduction Slide 8 of 34


AICT003-4-1-Practical IT Skills Module Introduction Slide 9 of 34
AICT003-4-1-Practical IT Skills Module Introduction Slide 10 of 34
Query Design Feature

• Click the Query Design Button on the


Create tab  Select the tables  Add
• Double click the name of the field you
would like to query
• Repeat this process for as many fields as
you would like in the query  
• Click Run

AICT003-4-1-Practical IT Skills Module Introduction Slide 11 of 34


AICT003-4-1-Practical IT Skills Module Introduction Slide 12 of 34
Query Criteria
Query criteria are search conditions used in
a query to retrieve specific data. Query
criteria can be set to be a specific number
or data set, or to be a range of data.

To specify search criteria:


Click the query that you
wish to add conditions
Type in the appropriate
query criteria in the
Criteria Box
AICT003-4-1-Practical IT Skills Module Introduction Slide 13 of 34
“value” Will only display items that are that exact value
(replace the word value with what you want to
search by)

= Is equal to
<  Less than
<= Less than or equal to
>  Greater than
>= Greater than or equal to
<>  Not equal to
Between  X  Within a range (replace X & Y with values)
And Y
Is Null Null values
And True only if both conditions exist
Or True if either condition exists
Not True if the single instance is not true

AICT003-4-1-Practical IT Skills Module Introduction Slide 14 of 34


Establishing Query Criteria
Criteria Returns Field Value
“Smith” matching Smith
“Smith” or “Larson” matching either Smith or Larson
Not “Smith” that is not Smith
“S*” that begins with S and ends in anything
“*s” that begins with anything and ends in s
“[A-D]*” that begins with A through D and ends
in anything
#01/01/2005# matching the date 01/01/2005
<#04/01/2005# less than (before) 04/01/2005
>#04/01/2005# greater than (after) 04/01/2005

Access will automatically insert “ and #


AICT003-4-1-Practical IT Skills Module Introduction Slide 15 of 34
Basic Queries

Using AND OR Operators


Both conditions of AND must be satisfied in order to produce a true
result.
The OR operation is true as long as one condition is true.

AICT003-4-1-Practical IT Skills Module Introduction Slide 16 of 34


Basic Queries

Using IIF Functions


Offers alternate action if neither condition is met

AICT003-4-1-Practical IT Skills Module Introduction Slide 17 of 34


Multiple Table Queries

Creating a Calculated Field


Add a column with an expression

AICT003-4-1-Practical IT Skills Module Introduction Slide 18 of 34


Advanced Queries

Creating a Parameter Query


Lets you add specific search criteria every time you run a query

AICT003-4-1-Practical IT Skills Module Introduction Slide 19 of 34


Advanced Queries

Using Parameter Queries


Run query, enter criteria

AICT003-4-1-Practical IT Skills Module Introduction Slide 20 of 34


Calculated Fields

• Expressions
• Zoom

A calculated field is a field that gets its


information from the calculations performed on
other fields.  You can build calculated fields in the
Query screen by using the addition (+),
subtraction (-), multiplication (*) and division (/)
operators. 
AICT003-4-1-Practical IT Skills Module Introduction Slide 21 of 34
Expressions
Expressions is a combination of functions,
field names, numbers, text, and the operators
listed above. 
To build an expression to create a calculated field:
• Open an existing query or start a new query
• Click on the View Button  Design View
• In the Query Pane, right-click on the field where you would like
to create the calculation Click Build
• Choose the tables that you wish to build the calculation from
• Double-click the field that you want to include in the calculation
• Click the operator that you wish to include in the calculation
• Click the second field you wish to include in the calculation 
Click OK  Click Run

AICT003-4-1-Practical IT Skills Module Introduction Slide 22 of 34


AICT003-4-1-Practical IT Skills Module Introduction Slide 23 of 34
Zoom
• To view an entire expression at one time. 
To view the Zoom Dialog Box:
– In Design View, right click on the field you
want to display
– Click Zoom

AICT003-4-1-Practical IT Skills Module Introduction Slide 24 of 34


Basic Queries

Sorting a Query
Sort & Filter section of the Home ribbon Header menu

AICT003-4-1-Practical IT Skills Module Introduction Slide 25 of 34


Basic Queries

Filtering a Query
Sort & Filter section of the Home ribbon

AICT003-4-1-Practical IT Skills Module Introduction Slide 26 of 34


Generating Reports

• Report Views
• Create a Report
• Report Wizard
• Custom Calculated Fields

AICT003-4-1-Practical IT Skills Module Introduction Slide 27 of 34


Create a  Report

To create a blank report:


• Click the Blank Report button on the
Create tab
• Click the Add Existing Fields button
• From the field list, Click and drag the fields
to the report

AICT003-4-1-Practical IT Skills Module Introduction Slide 28 of 34


Report Wizard
To create a report using the report wizard:
• On the Create tab, click the Report Wizard button
• Choose the Tables/Queries that you wish to have on the form
• Choose the fields you wish to have on the forms  Click Next
• Choose the sort order for your report
• Chose the layout for the form  Click Next
• Choose a style  Click Next
• Create a title for the form
• Choose whether you want to open
the form to view it or modify the
form’s design  Click Finish

AICT003-4-1-Practical IT Skills Module Introduction Slide 29 of 34


Print a Report

To print a report:
– Select the report you wish to print
– Right-click on the Report Name
– Click Print Preview
– Choose the appropriate layout, margins, and
paper size in the Page Layout group
– Click Print  Click OK

AICT003-4-1-Practical IT Skills Module Introduction Slide 30 of 34


Quick Review Questions

• How to create queries?


• How to create reports?

AICT003-4-1-Practical IT Skills Module Introduction Slide 31 of 34


Summary of Main Teaching Points

• Understand Queries in MS Access


• How to apply queries wizard, query design in database

AICT003-4-1-Practical IT Skills Module Introduction Slide 32 of 34


Question and Answer Session

Q&A

AICT003-4-1-Practical IT Skills Module Introduction Slide 33 of 34


Next Session
• Lab Session 8:
• How to create queries? (using query design,
choose the right table/s and provide criteria
or/and formula using builder)
• How to create reports? (include: company logo,
background color, etc.)
• Assignment Progress

• Lecture 9: Database (Part 3)


• Refer to Lab Session and Hand-Out materials

AICT003-4-1-Practical IT Skills Module Introduction Slide 34 of 34

You might also like