L546 Session 7, IU-SLIS 1 DB Implementation: MS Access Queries & Reports.

Slides:



Advertisements
Similar presentations
Working with Tables 1 of 5. Working with Tables 2 of 5.
Advertisements

Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
© Paradigm Publishing, Inc Access 2010 Level 1 Unit 2Creating Forms and Reports Chapter 6Creating Reports and Mailing Labels.
Jeopardy Objects Navigation Buttons True/False Parts of a Report Vocabulary Q $100 Q $200 Q $300 Q $400 Q $500 Q $100 Q $200 Q $300 Q $400 Q $500 Final.
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module J (Office 2010 Version) Implementing.
Access Lesson 8 Using Advanced Queries Microsoft Office 2010 Advanced Cable / Morrison 1.
Exploring Microsoft Access
Concepts of Database Management Seventh Edition
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
Extended Learning Module J (Office 2007 Version) Implementing a Database with Microsoft Access McGraw-Hill/Irwin Copyright © 2010 by the McGraw-Hill Companies,
1 DB Implementation: MS Access Queries. 2 Outline Access Queries ► Query Creation ► Sorting & Filtering ► Query Types ► Dynamic Query.
Chapter 2 Querying a Database
With Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access.
Pasewark & Pasewark 1 Access Lesson 4 Creating and Modifying Forms Microsoft Office 2007: Introductory.
Access Lesson 4 Creating and Modifying Forms
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Chapter 2 Querying a Database
Chapter 3 Maintaining a Database
Exploring Office Grauer and Barber 1 Information From the Database: Reports and Queries(Wk4)
Developing Effective Reports
Copyright 2007, Paradigm Publishing Inc. BACKNEXTEND 3-1 LINKS TO OBJECTIVES Save a Filter as a Query Save a Filter as a Query Parameter Query Inner, Left,
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 4: Create, Edit, and Perform.
DB Implementation: MS Access Queries. MS Access Queries Database Queries Core DBA skill From SQL to Query by Example (QBE) What does it do? Find target.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 1 1. Chapter 2: Relational Databases and Multi-Table Queries Exploring Microsoft Office.
® Microsoft Access 2010 Tutorial 6 Using Form Tools and Creating Custom Forms.
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
XP New Perspectives on Microsoft Access 2002 Tutorial 51 Microsoft Access 2002 Tutorial 5 – Enhancing a Table’s Design, and Creating Advanced Queries and.
McGraw-Hill Technology Education © 2004 by the McGraw-Hill Companies, Inc. All rights reserved. Office Access 2003 Lab 3 Analyzing Data and Creating Reports.
Analyzing Data For Effective Decision Making Chapter 3.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 6 – Designing.
S511 Session 7, IU-SLIS 1 DB Implementation: MS Access Forms.
Chapter 4: Create, Edit, and Perform Calculations in Reports Exploring Microsoft Office Access 2007.
Concepts of Database Management Seventh Edition
® Microsoft Office 2010 Access Tutorial 3 Maintaining and Querying a Database.
Exploring Office Grauer and Barber 1 Committed to Shaping the Next Generation of IT Experts. Chapter 3 - Information From the Database: Reports.
Analyzing Data Using Access. Creating a new database To create a new database 1.Start Access. In the Task Pane, click Blank Database. 2.The File New Database.
Database Systems Microsoft Access Practical #3 Queries Nos 215.
Copyright 2008 McGraw-Hill Ryerson 1 TECHNOLOGY PLUG-IN T7 PROBLEM SOLVING USING ACCESS.
® Microsoft Access 2010 Tutorial 3 Maintaining and Querying a Database.
With Microsoft Office 2007 Introductory© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory.
COMPREHENSIVE Access Tutorial 3 Maintaining and Querying a Database.
Chapter 3 Query and Report. Agenda Report types Report contents Report creation Report design view Query and dynaset Function and grouping Action query.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
McGraw-Hill/Irwin ©2005 The McGraw-Hill Companies, All rights reserved ©2005 The McGraw-Hill Companies, All rights reserved McGraw-Hill/Irwin.
McGraw-Hill/Irwin © 2008 The McGraw-Hill Companies, All Rights Reserved Plug-In T7: Problem Solving Using Access 2007 Business Driven Technology.
Database Applications – Microsoft Access Lesson 4 Working with Queries 36 Slides in Presentation.
McGraw-Hill/Irwin The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Access 2002 Lab 3 Analyzing Tables and Creating.
Reports and Queries Chapter 3 – Access text Reports – Page Queries – Page
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 4: Create, Edit,
T7-1 LEARNING OUTCOMES – ACCESS PROBLEM SOLVING 1.Describe the process of using the Simple Query Wizard using Access 2.Describe the process of using the.
© 2001 ComputerPREP, Inc. All rights reserved. Access 2000: Module II.
1 11 Exploring Microsoft Office Access 2007 Chapter 6 Data Protection.
(SQL - Structured Query Language)
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 6 BACKNEXTEND 6-1 LINKS TO OBJECTIVES Using the Report Button Using the Report Button Print.
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module J (Office 2007 Version) Implementing.
Microsoft Access Lesson 5 Lexington Technology Center February 25, 2003 Bob Herring On the Web at
Lesson 4: Querying a Database. 2 Learning Objectives After studying this lesson, you will be able to:  Create, save, and run select queries  Set query.
McGraw-Hill/Irwin © 2008 The McGraw-Hill Companies, All Rights Reserved Plug-In T7: Problem Solving Using Access 2007 Business Driven Technology.
Microsoft Access 2007 – Level 2
Building a User Interface with Forms
Plug-In T7: Problem Solving Using Access 2007
DB Implementation: MS Access Queries
DB Implementation: MS Access Queries
DB Implementation: MS Access Queries
From and Report.
Exploring Microsoft Office Access 2010
DB Implementation: MS Access Queries
Chapter 3 Query and Report.
Presentation transcript:

L546 Session 7, IU-SLIS 1 DB Implementation: MS Access Queries & Reports

L546 Session 7, IU-SLIS 2 Outline Access Queries ► Query Creation ► Sorting & Filtering ► Query Types ► Dynamic Query Access Reports ► Report Sections ► Grouping & Filtering MS Access File for Lecture

L546 Session 7, IU-SLIS 3 MS Access Queries Database Queries ► Core DBA skill ► From SQL to Query by Example (QBE) What does it do? ► Find target information Retrieve, Filter, Sort, Aggregate/Summarize ► Manipulate data Perform calculations Add, Change, Delete, Combine data in tables Assemble/Supply data for forms and reports How does it work? ► Access translates QBE to SQL ► SQL performs data manipulations based on Relational Algebra ► Access queries create a dynaset (“live” view of table) changes made in data by query is reflected in underlying tables

L546 Session 7, IU-SLIS 4 Access Queries: Views Datasheet view ► For displaying the result of the query ► Useful for reviewing/validating the query Design View ► For creating/modifying a query using drag & drop GUI (i.e., QBE) ► Consists of Diagram Pane & Grid Pane Add tables/queries to the Diagram Pane Add fields to the Grid Pane (Field row) ► Can sort/filter/compute by fields Sort row: set to Ascending/Descending Criteria row: use Expression to apply data filter Total row: compute (sum, min, max, count, etc.) of each field ► Automatically generates SQL statements SQL View ► For creating/modifying a query by manually writing SQL statements ► Only way to create SQL-specific queries Union/Data-definition/Pass-through query

L546 Session 7, IU-SLIS 5 Access Queries: Basic Types Simple Query ► Uses one table/query ► To generate a subset (row/column) of a table Multi-table Query ► Joins multiple tables/queries ► To merge small chunks of data in normalized tables Linked tables are automatically linked in in the Query Design Grid Creating a link in the Query Design Grid does not permanently link tables Select Query ► Selects records that meet given criteria ► Does not change the data Parameter Query ► Prompts for query criteria values (parameters) to run a dynamic query

L546 Session 7, IU-SLIS 6 Access Queries: Sort & Filter Datasheet View ► Sorting Click column and right-click ► Filtering Filter Tool (Home tab)  Filter by Selection  Filter by Form  Advanced Filter/Sort Design View ► Sort using the Sort Row Sort priority is from left to right for multiple sort ► Filter using the Criteria Row Criteria in multiple rows make OR query Criteria in single row make AND query Criteria in a single cell  AND/OR  Wildcards (*) in Like and Between – e.g. Like “A*”, Like “[A-C]*”, Like “*av*”, Like “ave?”, Not Like “A*” – e.g. Between 1950 and 1960, >1960

L546 Session 7, IU-SLIS 7 Access Queries: Query Criteria Query Criteria Expressions ExpressionReturns Between #1/1/99# and #12/31/99# Dates from 1/1/99 to 12/31/99 In (“John”,”Mary”,”James”)Records with John, Mary, or James Is NullRecords with no entry Like “Acc?ss”‘Acc’ followed by any character, followed by ‘ss’ Like “*s”Ends in ‘s’ Like “v*”Starts with ‘v’ <1000Less than Equal to 1000 Like “[A-C]??”Starts with A through C and has two more characters ????Any four characters Len([Surname])= Val(4)Any Surname of 4 characters Right([Surname],2)= “ss”Any Surname ending in “ss” Left([Surname],2)= “ac”Any Surname starting with “ac”

L546 Session 7, IU-SLIS 8 Access Queries: Expressions Using expressions to create a calculated column ► Enter expressions in blank column of query design view NAME: [Field1] operator [Field2] ► Format the display in Format property of the field Examples ► Simple math DiscountPrice: [Discount] * [StandardPrice] ► String Concatenation Name: [FirstName] & “ ” & [Lastname] ► Date & Time math DateDiff(Interval, BeginDate, EndDate)  HireAge: DateDiff(“yyyy”,[BirthDate],[HireDate]) DateAdd(Interval, Number, Date)  RetireDate: DateAdd(“yyyy”,25,[HireDate]) ► Customized Sorting Switch(expr1, value1, expr2, value2, etc.)  Switch([City]=“Seatle”, 1, [City]=“Redmond”, 2, etc.)

L546 Session 7, IU-SLIS 9 Access Queries: Dynamic Criteria Parameterized Queries ► Dynamic query based on varying criteria value e.g. retrieve books written by a given author ► Enter the parameter name in square brackets in criteria Do not use existing field names Can use expressions  e.g. Like "*" & [Last Name] & "*“ Query Criteria from Form Entries ► Use a form to enter query parameter values good for multiple parameter entries 1.Create a parameter query 2.Create a form with unbound input control for each of query parameters 3.Add a command button that will run the parameter query Run Query Action of Miscellaneous Category 4.Reference the form controls that hold parameter values from the query i.e. change the criteria to form controls Parameter name = fully qualified name of form control

L546 Session 7, IU-SLIS 10 Access Queries: Joins Inner Join ► Default join in Access (i.e. Natural Join) ► Returns only the records where joined fields are equal in both tables Left Outer join ► Returns all records from the left table Right Outer join ► Returns all records from the right table

L546 Session 7, IU-SLIS 11 Access Queries: Advanced Types Action Queries ► Append Query Appends table rows to an existing table ► Delete Query Deletes table rows ► Update Query Modifies the values of particular fields for particular records ► Make Table Query Creates a new table from rows of other tables/queries  will overwrite existing table of the same name Crosstab Query ► Performs mathematical operations on intersection of two fields SQL-Specific Queries ► Data-definition Query Defines/Changes the definition of a database object (e.g., create/modify a table) ► Union Query Combines multiple SELECT queries ► Pass-through Query Send command directly to ODBC database server to run server-side SQL

L546 Session 7, IU-SLIS 12 Access Queries: Action Queries Append Query  Appends table rows to an existing table 1. Create a select query. 2. Convert the select query to an Append query Append Tool in Query Type group of Design tab 3. Choose the destination fields for each column in the append query. 4. Run the query to append rows/records. Delete Query  Deletes table rows 1. Create a select query. 2. Convert the select query to a Delete query. Delete Tool in Query Type group of Design tab 3. Run the query to delete rows/records. Update Query  Modifies the values of particular fields for particular records 1. Create a select query. 2. Convert the select query to an Update query. Update Tool in Query Type group of Design tab 3. Set Update To: (and Criteria when appropriate) rows 4. Run the query to update fields/columns. Make Table Query  Creates a new table from rows of other tables/queries 1. Create a select query. 2. Convert the select query to a Make Table query. Make Table Tool in Query Type group of Design tab 3. Run the query to update fields/columns.

L546 Session 7, IU-SLIS 13 Access Queries: Crosstab Query Crosstab Query  Performs mathematical operations on intersection of two fields ► Using the Crosstab Query Wizard 1.Create a select query to join tables (if needed). 2.Click Query Wizard in the Other group of the Create tab. 3.Select Crosstab Query Wizard in the New Query dialog box & click OK. 4.Choose table/query with which to create a crosstab query & click Next. 5.Choose the field(s) whose values will be used as row headings & click Next. 6.Choose the field whose values will be used as column headings & click Next. 7.Choose a field and a function to use to calculate summary values.  The data type of the field that you select determines which functions are available. ► Using the Crosstab Tool 1.Create a select query. 2.Convert the select query to a Crosstab query  Crosstab Tool in Query Type group of Design tab 3.Set Row Headings  Crosstab = Row Heading, Total = Group By, Sum, Avg, etc. 4.Set Column Headings  Crosstab = Column Heading, Total = Group By 5.Set the calculation field and function  Crosstab = Value, Total = Sum, Avg, etc. 6.Set Criteria to filter data (if needed).  Total = Where, Criteria = expression

L546 Session 7, IU-SLIS 14 Access Queries: SQL Queries Data-definition Query  Defines/Changes the definition of a database object ► Create a table CREATE TABLE table_name ( field1 type(size), field2 type(size), …, PRIMARY KEY (field)) ► Modify a table ALTER TABLE table_name ADD/ALTER COLUMN field type(size) DROP COLUMN field Union Query  Combines multiple SELECT queries ► Select queries must have the same fields (i.e., Union compatible) SELECT field1, field2, …. FROM table1 UNION SELECT fieldA, fieldB, …. FROM table2 1. Create the select queries in Design view 2. Copy & paste SQL statements into a union query Pass-through Query  Send command directly to ODBC database server to run server-side SQL 1. Configure the server DBMS as an ODBC data source 2. Create a Pass-through query

L546 Session 7, IU-SLIS 15 MS Access Reports Access Reports ► Allows presentation of table and query data in a customized layout ► Good for data summarization ► Not a tool for data manipulation ► Optimized for printing rather than screen display Report Views ► Design View Provides a detailed view of report structure  e.g., headers/footers for the report, page, groups ► Layout View Useful for modifying appearance and readability of the report  e.g., setting column widths, adding grouping levels ► Print Preview How the report will look when printed  Displays page breaks, report columns, etc. ► Report View For basic viewing the report  Can copy data

L546 Session 7, IU-SLIS 16 Access Reports: Creating Reports Using the Report Tool 1. Select the source (table/query) of the report in the Navigation pane. 2. Click the Report tool in the Reports group of the Create tab. Using the Report Wizard 1. Click the Report Wizard in the Reports group of the Create tab. 2. Follow directions on the Report Wizard pages. Using the Blank Report Tool 1. Click the Blank Report tool in the Reports group of the Create tab. 2. Drag fields from the Field List pane to the report

L546 Session 7, IU-SLIS 17 Access Reports: Sections Report Header ► Appears once at the beginning of the report (before the page header) ► Use for “Cover Page” information e.g., report author, company logo, date Page Header ► Appears at the top of every report page e.g., report title Group Header ► Appears at the beginning of each group ► Use for group name e.g., company name when grouped by company Detail ► Main body of the report (table/query data area) Group Footer ► Appears at the end of each group ► Use for summary information for a group Page Footer ► Appears at the bottom of every page e.g. page numbers, dates Report Footer ► Appears once at the end of the report e.g. report totals

L546 Session 7, IU-SLIS 18 Access Reports: Grouping & Filtering Creating a grouping Level ► Access adds a header & footer corresponding to grouping field’s name e.g. grouped by Category  Category Header, Category Footer ► Option in Report Wizard ► Manual group creation 1.Click Group & Sort tool in Grouping & Totals group of Format/Design tab (Layout/Design view) 2.Click Add a group in the Group, Sort, and Total pane. 3.Select a field to group by 4.Click More to set additional grouping options Filtering Records ► Using Select Query Set filtering conditions in query criteria ► Using Filter Properties set Filter and Filter On properties (Data tab) of a report Dynamic Criteria ► Use Parameter Queries

L546 Session 7, IU-SLIS 19 Access Reports: Counting & Summing Using the Layout View 1. Open a report in Layout View 2. Select the field you want to count 3. Click Totals icon in Groupings & Totals group of the Format tab 4. Select an appropriate summary function 5. Right-click the summary fields and click Set Caption Using the Design View 1. Open a report in Design View 2. Place a Text Box in appropriate section of the report 3. Set the Control Source property of the text box to be an expression using a summary function Summary counts: =COUNT([Field_NAME]) Sums: =SUM([Field_NAME]) 4. Set the Running Sum property if running total is desired