Download ppt - Access 2007 Unit B

Transcript
Page 1: Access 2007 Unit B

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

Building and Using QueriesBuilding and Using Queries

Page 2: Access 2007 Unit B

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

Page 3: Access 2007 Unit B

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

Page 4: Access 2007 Unit B

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

Page 5: Access 2007 Unit B

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

Page 6: Access 2007 Unit B

Simple Query Wizard:Simple Query Wizard:Selecting FieldsSelecting Fields

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Page 7: Access 2007 Unit B

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

Page 8: Access 2007 Unit B

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

Page 9: Access 2007 Unit B

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

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Page 10: Access 2007 Unit B

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

Page 11: Access 2007 Unit B

Modified QueryModified Query

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Page 12: Access 2007 Unit B

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

Page 13: Access 2007 Unit B

Sort and Find ButtonsSort and Find Buttons

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Page 14: Access 2007 Unit B

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

Page 15: Access 2007 Unit B

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

Page 16: Access 2007 Unit B

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

Page 17: Access 2007 Unit B

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

Page 18: Access 2007 Unit B

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

Page 19: Access 2007 Unit B

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)

Page 20: Access 2007 Unit B

Example of AND CriteriaExample of AND Criteria

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Page 21: Access 2007 Unit B

Comparison OperatorsComparison Operators

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Page 22: Access 2007 Unit B

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

Page 23: Access 2007 Unit B

Applying OR CriteriaApplying OR Criteria

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Page 24: Access 2007 Unit B

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

Page 25: Access 2007 Unit B

Example of Formatted Example of Formatted DatasheetDatasheet

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition

Page 26: Access 2007 Unit B

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


Recommended