Training Presentation - Create Queries for a New Database

Post on 06-Apr-2018

220 views 0 download

transcript

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 1/35

Microsoft® Access

®2010 Training

Create queries for a new database

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 2/35

Course contents

Overview: Queries are essential

Lesson: Includes seven sections

Suggested practice tasks Test

Quick Reference Card

Create queries for a new database

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 3/35

Overview: Queries are essential

Create queries for a new database

In this course, you·ll learn how to createqueries for an Access database. Queriesare an essential part of any database.

They·re how you extract meaningfulinformation from your database andanswer key business questions.

This is the fourth course in a series that

teaches beginners how to use Access2010.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 4/35

Course goals

Use the Query Designer to create a select query thatreturns data from a single table.

Create a select query that asks you to enterparameters and then returns results that match those

parameters. Use a formula in a query to calculate a sum.

Use the Query Wizard to create a select query thatreturns data from two tables.

Use an expression to concatenate fields.

Create queries for a new database

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 5/35

Get answers from your data

Create queries for a new database

The building blocks of a select query.

Your new asset-tracking

database is comingalong. You have tables,relationships, and data,so the next step is tobuild some queries.They·ll help you answer

important questions,and they·ll make iteasier to create formsand reports.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 6/35

Get answers from your data

Create queries for a new database

The building blocks of a select query.

Specifically, you·ll create

select queries. They·recomponents thatretrieve and processyour data and displaythe results in adatasheet.

For example, if you wantto know who to callwhen a computer needsrepair, you create aquery that extracts therelevant names and

phone numbers.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 7/35

Get answers from your data

Create queries for a new database

The building blocks of a select query.

That·s what the picture

shows. The query takesasset data from the firsttable, the names of technicians from thesecond table, anddisplays the result in a

way that you canconsume.

Let·s start by looking atthe parts of a query.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 8/35

The basics of creating select queries

Create queries for a new database

The basic process for creating a query.

Access provides two

primary ways to createselect queries ³ theQuery Designer and theQuery Wizard.Regardless of the toolyou use, you follow

some common stepswhen you create a selectquery.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 9/35

The basics of creating select queries

Create queries for a new database

The basic process for creating a query.

Start by choosing a

record source for thequery. A record sourcecan be one or moretables, one or morequeries, or acombination of the two.The picture shows a

table open in the QueryDesigner.

From the record source,select the fields that youwant to see in the query.The picture shows fields

in the Query Designer,but you do the samething in the QueryWizard.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 10/35

The basics of creating select queries

Create queries for a new database

The basic process for creating a query.

Add any sorting,

filtering, or otherselection criteria toyour queries. Forexample, if you use thecriteria shown in thepicture, the query willonly return data for

assets purchased afterMay First of 2010. Youcan also use criteria thatmake a query ask youfor input before it runs;you·ll see that later inthis course.

After you finish addingfields and any selectioncriteria, run your queryto see if it gives you thecorrect results.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 11/35

Ways to use query results

Create queries for a new database

A query as the data source for a report.

When you run a select

query, Access displaysthe results in adatasheet. The result iscalled a record set, andyou can work with it inthe same way that you

work with a datasheet.For example, you canadd or change data, andAccess will write yourchanges to the tablesthat serve as the record

sources for your query.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 12/35

Ways to use query results

Create queries for a new database

A query as the data source for a report.

You can also use your

record sets to providedata for forms, reports,and even other queries.For example, if you wanta report on thecomputers that you

need to replace, you cancreate a query thatreturns that data, andthen quickly build yourreport.

The picture shows this.

The query returns onlythose records where anasset has been markedfor retirement.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 13/35

Ways to use query results

Create queries for a new database

A query as the data source for a report.

The final two courses in

this series show youhow to create forms andreports that use queriesas data sources. Fornow, remember thatunlike tables, record sets

don·t physically exist inyour database. Instead,Access stores the query,and it only displays arecord set when you runthe query.

So let·s build one. We·llstart with the QueryDesigner.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 14/35

Query a single record source

Create queries for a new database

Using the Query Designer.

The Query Designer

gives you the mostcontrol over a selectquery. It also makes iteasy to create a querythat uses a single tableas a record source.

For example, this type of query makes it easy tolist your assets and theirpurchase dates.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 15/35

Query a single record source

Create queries for a new database

Using the Query Designer.

Here·s the process.

On the Create tab, in theQueries group, clickQuery Design. Thedesigner starts anddisplays the Show Tabledialog box. On the

ribbon, the Design tabalso appears.

In the dialog box, selectyour record source. Youcan use a combination of tables and queries, andthe ones you selectappear in the uppersection of the designer.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 16/35

Query a single record source

Create queries for a new database

Using the Query Designer.

In your record source,

double-click the fieldsthat you want to see inyour record set, orresults. Your choicesappear in the bottomsection of the designer.

When you finish addingfields, go to the Designtab, and in the Resultsgroup, click Run.

Your record set appearsas a datasheet.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 17/35

Make a query ask for input

Create queries for a new database

Using criteria in a query.

The type of query that

you created in theprevious section canreturn a lot of data. Acommon way to limitwhat the query returnsis to use a parameter.

Put simply, parametersmake the query ask forinput before it runs; theyare a type of filter thatyou build into yourquery.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 18/35

Make a query ask for input

Create queries for a new database

Using criteria in a query.

Here·s how to use

parameters in yourqueries:

Open the query inDesign view, and in theCriteria row of the fieldyou want to filter, enter

your parameter. Forexample, you can usethe criteria shown in thepicture.

When you run the query,that criteria asks you fora start date, then an enddate, and it returns onlythe records that fallwithin the dates youspecify.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 19/35

Use a formula in a query

Create queries for a new database

Using a function in a query.

Another common way

to alter the selectioncriteria in a query is toadd a f unction.

For example, if you wantto know how much yourcompany spent on office

furniture last year, youcan add an aggregatefunction to the queryand the sum will appearin your results.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 20/35

Use a formula in a query

Create queries for a new database

Using a function in a query.

Open your query in

Design view.On the Design tab, inthe Show/Hide group,click Totals. The Totalrow appears in thedesigner.

In the field where youwant to use the function,click the Total row andselect a function fromthe list.

When you run yourquery, the results include

your calculation.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 21/35

Query multiple record sources

Create queries for a new database

Using the Query Wizard to build a multi-source query.

You can use multiple

tables, or other queries,as the record source fora new query. In fact,you·ll query multiplerecord sources far morethan you will single

sources. Multi-sourcequeries are how youanswer questions suchas which assets camefrom which suppliers.

The Query Wizard is the

easiest way to getstarted building multi-source queries,especially if you·re newto Access.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 22/35

Query multiple record sources

Create queries for a new database

Using the Query Wizard to build a multi-source query.

On the Create tab, in the

Queries group, clickQuery Wizard.

Complete the wizard. Aspart of that process,select the tables andfields you want to use as

your record source,and¬

Give your new query adescriptive name, andremember to avoid usingspaces in the name.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 23/35

Suggestions for practice

1. Create a select query from a single table.

2. Make the query ask for your input (add a parameter).

3. Add a calculated field to a query.

4. Format the calculated field.

5. Create a query from multiple tables.

6. Concatenate fields with an expression.

Create queries for a new database

Online practice (requires Access 2010)

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 24/35

Test question 1

When you first create a query, you select which of thefollowing? (Pick one answer.)

Create queries for a new database

1. A record source.

2. A system table.

3. A record set.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 25/35

Test question 1

Create queries for a new database

The record source can be a combination of tables andqueries.

When you first create a query, you select which of thefollowing?

 Answer:

1.  A record source.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 26/35

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 27/35

Test question 2

Create queries for a new database

Criteria can be quite powerful, too. For example, you canuse criteria to find records for people who live in a givencity and have birthdays that fall between dates that youspecify.

Use criteria in a query when you need to do which of thefollowing?

 Answer:

3. Sort, filter, or otherwise limit what the query returns.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 28/35

Test question 3

Before you can use multiple tables as a record source,

those tables must: (Pick one answer.)

Create queries for a new database

1. Be open in Datasheet view.

2. Participate in a relationship.

3. Not serve as the record source for another query.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 29/35

Test question 3

Create queries for a new database

If the tables don·t participate in a relationship, the queryreturns all the data in each table, and the results are almostalways meaningless.

Before you can use multiple tables as a record source,those tables must:

 Answer:

2. Participate in a relationship.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 30/35

Test question 4

 An expression is: (Pick one answer.)

Create queries for a new database

1. A formula stored in one or more database tables.

2. A formula that just calculates dates.

3. An object that can perform calculations and other taskssuch as data validation.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 31/35

Test question 4

Create queries for a new database

This course has shown you a couple of ways to useexpressions. The Quick Reference Card that·s linked to atthe end points you to a lot more information about them.

 An expression is:

 Answer:

3.  An object that can perform calculations and other taskssuch as data validation.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 32/35

Test question 5

This course has taught you everything you need to know aboutqueries. (Pick one answer.)

Create queries for a new database

1. True.

2. False.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 33/35

Test question 5

Create queries for a new database

The Quick Reference Card, linked to on the next slide,points to a lot more information. Grab it.

This course has taught you everything you need to knowabout queries.

 Answer:

2. False.

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 34/35

Quick Reference Card

For a summary of the tasks covered in this course, view theQuick Reference Card.

Create queries for a new database

8/3/2019 Training Presentation - Create Queries for a New Database

http://slidepdf.com/reader/full/training-presentation-create-queries-for-a-new-database 35/35

Using this template

See the notes pane or view the fullnotes page (View tab, Notes Page)

for detailed help on this template.