Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall1 Exploring Microsoft Office Access 2007 1 Committed to Shaping the Next Generation.

Similar presentations


Presentation on theme: "Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall1 Exploring Microsoft Office Access 2007 1 Committed to Shaping the Next Generation."— Presentation transcript:

1 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall1 Exploring Microsoft Office Access 2007 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2: Relational Databases and Multi-Table Queries Robert Grauer, Keith Mulbery, Maurie Wigman Lockley

2  Date: November 23, 2009  Content: ◦ Excel and Access. Week 6 to Week 11.  Format: ◦ 1 Excel problem that contains format of worksheet, computations using VLOOKUP and PMT, and create a graph. ◦ 1 Access problem that contains create tables, setting relationship, create a set of queries and a simple report. Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall2

3 3 Objectives  Create a query  Specify criteria for different data types  Copy and run a query  Use the Query Wizard  Understand large database differences

4 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall4 Using Query Design View  Query Design grid has two panes – the table pane and the design pane  Striking the F6 key will toggle you between sections Tables pane Design pane

5 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall5 Select Query  Searches associated tables and returns a dataset that matches the query parameters  Changes made to the dataset will be reflected in the associated tables

6 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall6 Specifying Criteria in a Select Query  Table row – displays the data source.  Field row – displays the field name  Sort row – enables you to sort the dataset  Show row – controls whether or not you see a field in the dataset  Criteria row – determines the records that will be selected for display Fields in design grid allow us to specify criteria for the dataset

7 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall7 Specifying Criteria – Currency and Operands  Specify criteria with currency ◦ Without the dollar sign ◦ With or without the decimal point  Use operands such as: ◦ Less than and greater than ◦ Equal to or not equal to Greater than (>) operand Currency amount entered without dollar sign

8 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall8 Specifying Criteria – Wildcards  Asterisk - searches for a pattern that includes any number of characters in the position of the asterisk  Question mark - searches for a pattern that includes a single character in the position of the question mark Query with question mark and asterisk wildcard and resulting dataset to specify criteria for the dataset Query with asterisk wildcard and resulting dataset

9 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall9 Specifying Criteria – Null Values  IS NULL finds only records that have no value  IS NOT NULL excludes Null value records Is Null criteria and resulting dataset IS NOT NULL criteria and partial resulting dataset

10 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall10 Specifying Criteria – AND, OR, NOT  OR finds records that can match one or more conditions  AND finds records that must match all criteria specified  NOT returns the opposite of the specified criteria. Or Criterion and resulting dataset And criterion and resulting dataset

11 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall11 Copy a Query  Right click on the query - chose Copy form the shortcut menu  Right click and chose paste  In the Paste as dialog box, give the query a new name

12 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall12 Run a Query  Running or executing a query is done by clicking the Run command Run command

13 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall13 Creating Queries – Using the Query Wizard  From the Create tab, choose Query Wizard for the Other group  Choose query type from the New Query dialog box Query Wizard icon Select Simple Query Wizard

14 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall14 Creating Queries – Using the Query Wizard: continued  Select the Table/Queries to include and choose the desired fields  Select aggregate totals needed in the Summary Options box

15 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall15 Creating Queries – Using the Query Wizard: continued  Title your query and open in Datasheet View or Query Design View

16 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 16 Understand Expressions  Expressions are formulas based on existing fields ◦ Result in a new field called a calculated field ◦ Used primarily in queries, reports and forms  Expressions may include ◦ The names of fields, controls or properties ◦ Operators like +, *, or () ◦ Functions, constants or values

17 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 17 What Are Expressions Used For?  You can use an expression to: ◦ perform a calculation ◦ retrieve the value of a field or control ◦ supply criteria to a query ◦ create calculated controls and fields ◦ define a grouping level for a report Result of a calculation in a report formed by using an expression

18 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 18 Parts of an Expression  Constants: a named item whose value remains constant while Access is running  Values: literal values such as the number 1.75 or the word “Hello” [Price] * [Quantity_On_Hand] * 0.7 Identifiers Operator Value

19 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 19 Creating a Calculated Field Use correct syntax  Assign a descriptive name to the field  Enclose field names in brackets Total Value: [Price] * [Quantity_On_Hand] Descriptive name for new field preceded with colon (:) Expression using existing fields in a database ◦Use correct syntax◦Assign a descriptive name to the field◦Enclose field names in brackets◦Use correct syntax◦Assign a descriptive name to the field◦Enclose field names in brackets

20 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 20 Calculated Field in a Query Calculated Field Query Design View  A calculated field is added to a blank column in the design grid

21 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 21 Saving a Query with a Calculated Field  Does not change the data in the database ◦ Only the query structure is saved ◦ Allows new data to be added to a table that is associated with a query  When query executed again, includes the values of the new table data

22 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 22 Expression Builder  Used to formulate the expressions in a calculated field

23 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 23 Expression Builder  Use expressions to add, subtract, multiply, and divide the values in two or more fields/ controls Fields available in current query Expand folders by clicking plus sign

24 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 24 The Expression Builder Work Area  All expressions begin with an equal sign  Logic and operand symbols may be either typed or clicked in the area underneath the work area  Double-click fields to add them to the work area Logical and operand symbols Work area with expression

25 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 25 Access Functions  Predesigned formulas that calculate commonly used expressions Payment function in work area Function categories

26 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 26 Access Functions  Some functions require arguments ◦ A value that provides input to the function ◦ Separate multiple arguments with commas Arguments separated by commas

27 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 27 The IIF Function  Evaluates a condition  Executes one action when the expression  Alternate action when the condition is false The IIF function syntax in the work area of the expression builder

28 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 28  Displays the message “In Stock” if value of 1 or greater  Otherwise “Out of Stock” will be displayed =IIF(Quantity_on_Hand] >= 1, “In Stock”, “Out of Stock”) Arguments of IIF function separated by commas

29 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 29 Performing Date Arithmetic  Access stores dates as serial numbers which allows calculation of dates no matter the format entered Calculated field using dates Query results from date calculation

30 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 30 Variations of DatePart Function  =DatePart(“q”, “01/22/2007”) ◦ Displays the quarter in which the given date falls  =DatePart(“h”, Now()) ◦ Displays the hour part of the current date  =DatePart(“d”, Now()) ◦ Displays the day part of the current date

31 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 31  =DateDiff(“d”, [orderdate],[shippeddate]) ◦ Displays the number f days between ordering and shipping  =DateDiff(“m”,#01/06/2006#, #07/23/2007#) ◦ Displays the number of months between the two dates  =DateDiff(“d”,[dateborn], Now()) ◦ Displays the number of days between the dateborn field and the current date

32 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 32 Data Aggregates Data aggregation allows summarization and consolidation of data

33 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 33 Performing an Aggregate Calculation in Datasheet View  Must be in a a numeric or currency field  Click Totals in the Records group  Choose the aggregate function desired Aggregate functions displayed by clicking the arrow next to Total

34 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 34  When using the Avg function, null fields ignored  When using the Count function, null fields are not included unless an asterisk (*) is used as the argument for the function

35 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 35  Examples ◦ Count(*) will include null fields in the calculation ◦ Count(records) will not include null fields  The Sum function ignores null values

36 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 36  The total row can be added to the design grid by clicking the Totals Icon Totals Icon Total row added to the query

37 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 37 Use a Totals Query to Group  Organizes query results into groups  Only use the field or fields that you want to total and the grouping field Grouping field Field to be totaled


Download ppt "Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall1 Exploring Microsoft Office Access 2007 1 Committed to Shaping the Next Generation."

Similar presentations


Ads by Google