Access 2007 Unit B

Preview:

DESCRIPTION

 

Citation preview

Microsoft Office 2007- Illustrated Introductory, Microsoft Office 2007- Illustrated Introductory, Windows Vista EditionWindows Vista Edition

Building and Using QueriesBuilding and Using Queries

ObjectivesObjectives

• Create a queryCreate a query

• Use Query Design ViewUse Query Design View

• Modify queriesModify queries

• Sort and find dataSort and find data

(continued)(continued)

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Objectives Objectives

• Filter dataFilter data

• Apply AND criteriaApply AND criteria

• Apply OR criteriaApply OR criteria

• Format a datasheetFormat a datasheet

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Creating a QueryCreating a Query

• A query allows you to “ask” for only A query allows you to “ask” for only the information you want vs. the information you want vs. navigating through all the fields and navigating through all the fields and records of large tablesrecords of large tables

• You can enter, edit and navigate data You can enter, edit and navigate data in a query datasheet just like a table in a query datasheet just like a table datasheetdatasheet

• Query = logical view of the dataQuery = logical view of the data

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Creating a QueryCreating a Query

• One way to create a query is by One way to create a query is by using the Simple Query Wizardusing the Simple Query Wizard

• The Wizard asks you questions to The Wizard asks you questions to determine the information you wantdetermine the information you want

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Simple Query Wizard:Simple Query Wizard:Selecting FieldsSelecting Fields

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Using Query Design ViewUsing Query Design View

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

• Another way to create a query is by Another way to create a query is by using Query Design Viewusing Query Design View

• You also use Query Design View to You also use Query Design View to edit an existing queryedit an existing query

• Query Design View presents the Query Design View presents the fields you can choose from in Field fields you can choose from in Field ListsLists

Using Query Design ViewUsing Query Design View

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

• If 2 or more related tables are used, If 2 or more related tables are used, their relationship is shown with a their relationship is shown with a join join lineline

Switching Between Query Switching Between Query Design View & Datasheet ViewDesign View & Datasheet View

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Modifying QueriesModifying Queries

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

• Work in Design ViewWork in Design View

• Upper pane of Design View window Upper pane of Design View window shows field listsshows field lists

• Lower pane of Design View window Lower pane of Design View window is used to add, delete or change the is used to add, delete or change the order of fieldsorder of fields

Modified QueryModified Query

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Sorting and Finding DataSorting and Finding Data

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

• Works the same way for queries as it Works the same way for queries as it does for tablesdoes for tables

• Data can be sorted by clicking the list Data can be sorted by clicking the list arrow on a datasheet’s column arrow on a datasheet’s column heading, then click a sorting optionheading, then click a sorting option

• Data can also be sorted by using the Data can also be sorted by using the Sort and Find buttons on the Home Sort and Find buttons on the Home tabtab

Sort and Find ButtonsSort and Find Buttons

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Filtering DataFiltering Data

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

• Filters provide a temporary way to Filters provide a temporary way to display a subset of records that match display a subset of records that match given criteriagiven criteria

• Filters are not used to calculate sums, Filters are not used to calculate sums, averages, counts, etc.averages, counts, etc.

• Filters are removed when the Filters are removed when the datasheet is closeddatasheet is closed

• Filters can, however, be saved as Filters can, however, be saved as queriesqueries

Filtering DataFiltering Data

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

• Filter By Selection: Filtering by a Filter By Selection: Filtering by a given field value. Filters records for given field value. Filters records for an exact match.an exact match.

• Filter By Form: Filters by comparative Filter By Form: Filters by comparative datadata

WildcardsWildcards

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

• Used to search for a pattern; Used to search for a pattern; represents any characterrepresents any character

• Entered as criteriaEntered as criteria

• ? Used to search for a single ? Used to search for a single charactercharacter

• * Used to search for any number of * Used to search for any number of characterscharacters

Applying AND CriteriaApplying AND Criteria

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

• AND criteria means AND criteria means allall criteria must criteria must be true for the record to be selectedbe true for the record to be selected

• Created by entering 2 or more criteria Created by entering 2 or more criteria in the in the samesame Criteria row of the query Criteria row of the query design griddesign grid

Criteria SyntaxCriteria Syntax

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

• Quotation marks (“) around text Quotation marks (“) around text criteria and pound signs (#) around criteria and pound signs (#) around date criteria are date criteria are automaticallyautomatically added added by Accessby Access

• Criteria in Number, Currency, and Criteria in Number, Currency, and Yes/No fields are not surrounded by Yes/No fields are not surrounded by any charactersany characters

Searching for Blank FieldsSearching for Blank Fields

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

• 2 common criteria are 2 common criteria are Is NullIs Null and and Is Is Not NullNot Null

• Is NullIs Null – Finds all records where no – Finds all records where no entry has been madeentry has been made

• Is Not NullIs Not Null – Finds all records where – Finds all records where any entry has been made (even if any entry has been made (even if zero)zero)

Example of AND CriteriaExample of AND Criteria

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Comparison OperatorsComparison Operators

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Applying OR CriteriaApplying OR Criteria

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

• OR criteria means OR criteria means any oneany one criterion criterion must be true for the record to be must be true for the record to be selectedselected

• Created by entering 2 or more criteria Created by entering 2 or more criteria on on differentdifferent Criteria rows of the query Criteria rows of the query design griddesign grid

• Also created by entering 2 or more Also created by entering 2 or more criteria in the criteria in the samesame Criteria cell Criteria cell separated by ORseparated by OR

Applying OR CriteriaApplying OR Criteria

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Formatting a DatasheetFormatting a Datasheet

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

• CanCan: Change font size, font face, : Change font size, font face, colors, gridlinescolors, gridlines

• CannotCannot: Add custom headers, : Add custom headers, footers, images, subtotalsfooters, images, subtotals

Example of Formatted Example of Formatted DatasheetDatasheet

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

SummarySummary

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

• Create queries to answer “questions” Create queries to answer “questions” about your dataabout your data

• Use table and query datasheets to Use table and query datasheets to view, sort, filter, and find dataview, sort, filter, and find data

• AND / OR criteria are used to filter AND / OR criteria are used to filter datadata

• Filters are temporary; queries are Filters are temporary; queries are permanent objectspermanent objects