+ All Categories
Home > Documents > Course Book Access TDAC Creating Qu Fo Re10

Course Book Access TDAC Creating Qu Fo Re10

Date post: 07-Aug-2018
Category:
Upload: 40below
View: 221 times
Download: 0 times
Share this document with a friend

of 102

Transcript
  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    1/102

    Access:

    Creating queries,forms and reports

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    2/102

    Access: Creating queries, forms and reports TDAC

    IT Learning Programme ii

    How to Use This Course Book

    This handbook accompanies the taught sessions for the course. Each sectioncontains a brief overview of a topic for your reference and then one or moreexercises.

    The Exercises

    Exercises are arranged as follows:

    A title and brief overview of the tasks to be carried out

    A numbered set of tasks, together with a brief description of each

    A numbered set of detailed steps that will achieve each task

    Some exercises, particularly those within the same section, assume that you havecompleted earlier exercises. Your lecturer will direct you to the location of filesthat are needed for the exercises. If you have any problems with the text or the

    exercises, please ask the lecturer or one of the demonstrators for help.This book includes plenty of exercise activities more than can usually becompleted during the hands-on sessions of the course. You should select some totry during the course, while the teacher and demonstrator(s) are around to guideyou. Later, you may attend follow-up sessions called Computer8, where you cancontinue work on the exercises, with some support from IT teachers. Otherexercises are for you to try on your own, as a reminder or an extension of thework done during the course.

    Writing Conventions

    A number of conventions are used to help you to be clear about what you need to

    do in each step of a task.

    In general, the word pressindicates you need to press a key on the keyboard.Click, chooseor selectrefer to using the mouse and clicking on items on thescreen (unless you have your own favourite way of operating screen features).

    Names of keys on the keyboard, for example the Enter (or Return) key, are shownlike this ENTER.

    Multiple key names linked by a + (for example, CTRL+Z) indicate that the first keyshould be held down while the remaining keys are pressed; all keys can then bereleased together.

    Words and commands typed in by the user are shown like this.

    Labels and titles on the screen are shownl ike th is

    .

    A button to be clicked will lookl ike th is

    .

    The names of software packages are identified like this, and the names of files tobe used

    l ike this .

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    3/102

    TDAC Access: Creating queries, forms and reports

    iii IT Learning Programme

    Software Used

    Access 2010

    Windows

    Files UsedD e p a r t m e n t A s s e t s .a c c d b

    E v e n t P l a n n e r . a c c d b

    I n v e n t o r y T o y L i b r a r y .a c c d b

    P e n d l e t o n P r o d u c t s . a c c d b

    Revision Information

    Version Date Author Changes made

    1.0 July 2004 Pamela Stanworth Created1.1 November 2004 Pamela Stanworth Corrections

    1.2 November 2005 Pamela Stanworth Updated for new H:/

    1.3 November 2006 Pamela Stanworth Portfolio link etc.

    1.5 September 2009 Pamela Stanworth &Michael Vanden Boom

    Revised for Access 2007

    2.0 February 2012 Pamela Stanworth Revised for Access 2010

    2.1 January 2013 Pamela Stanworth Updated for IT Services

    Copyright

    Pamela Stanworth makes this document and the accompanying PowerPointpresentation available under a Creative Commons licence: Attribution-NonCommercial-ShareAlike CC BY-NC-SA. [email protected]

    Screenshots in this document are copyright of Microsoft.

    The Oxford University logo and IT Services logo are copyright of OxfordUniversity and may only be used by Oxford University members in accordancewith the Universitys branding guidelines.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    4/102

    Access: Creating queries, forms and reports TDAC

    IT Learning Programme iv

    Contents

    1 Introduction ............................................................................... 1

    1.1. What You Should Already Know ......................................................... 1

    1.2. What You Will Learn ........................................................................... 1

    1.3. What isAccess? ................................................................................... 1

    1.4. Where Can I Get A Copy? ................................................................... 2

    1.5. Using Office 2010 ............................................................................... 2

    2 Getting Started .......................................................................... 4

    2.1. Some Database Vocabulary ................................................................ 4

    2.2. Using the Database Files for ITLP Exercises Access 2010............ 4

    Exercise 1: Opening a database file .......................................................... 4

    3 Queries ...................................................................................... 5

    3.1. Using Queries ..................................................................................... 5

    3.2. Creating A Select Query ..................................................................... 5

    Exercise 2: Creating select queries ........................................................... 9

    3.3. Creating a Query in Design View ....................................................... 9

    Exercise 3: Creating a query in Design View ........................................... 13

    3.4. Setting Query Criteria ....................................................................... 13

    Exercise 4: Setting criteria in a query ..................................................... 15

    3.5. Editing a Query Design ..................................................................... 15

    3.6. Finishing ........................................................................................... 17

    Exercise 5: Rearranging a query .............................................................. 17

    4 Creating Forms ....................................................................... 18

    4.1. Creating a Form Instantly ................................................................ 18

    Exercise 6: Using a form and creating an instant form ......................... 18

    4.2. Using the Wizard to Create a Form Based on a Table .................... 18

    4.3. Using the Wizard to Create a Form Based on a Query .................... 19

    4.4. Using the Form ................................................................................. 21

    4.5. Managing Forms ............................................................................... 21

    Exercise 7: Creating a form using the wizard .......................................... 21

    5 Design Changes on a Form ..................................................... 22

    5.1. Switching Between Views of a Form ................................................ 22

    5.2. Themes on a Form ........................................................................... 22

    5.3. Editing Labels .................................................................................. 23

    5.4. Moving and Resizing Form Objects ................................................ 23

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    5/102

    TDAC Access: Creating queries, forms and reports

    v IT Learning Programme

    Exercise 8: Design changes on a form .................................................... 24

    5.5. Selecting Multiple Objects ............................................................... 24

    5.6. Arranging and Aligning Form Objects in a Layout ......................... 24

    Exercise 9: Using a layout on a form ...................................................... 25

    6 Formats and Properties of Form Objects ............................... 26

    6.1. Using Buttons for Formatting Controls and Labels ........................ 26

    6.2. Data Formats in a Form Control ..................................................... 26

    6.3. Conditional Formatting ................................................................... 27

    Exercise 10: Formatting controls and labels on a form ......................... 27

    6.4. Property Sheet ................................................................................. 27

    6.5. Form Properties ............................................................................... 28

    6.6. Changing the Record Source of a Form Including Queries ......... 29

    Exercise 11: Using the Property Sheet .................................................... 29

    7 Creating Reports ..................................................................... 30

    7.1. Creating a Report Instantly .............................................................. 30

    Exercise 12: Creating a report instantly ................................................. 30

    7.2. Using the Wizard to Create a Report Based on a Table .................. 30

    7.3. Using the Wizard to Create a Report Based on a Query ................. 33

    7.4. Using the Report .............................................................................. 34

    7.5. The Mailing Label Wizard (Optional) ............................................. 34

    7.6. Managing Reports ............................................................................ 36

    Exercise 13: Creating a report using the wizard ..................................... 36

    8 Design Changes on a Report ................................................... 37

    8.1. Switching Between Report Views .................................................... 37

    8.2. Themes on a Report ......................................................................... 37

    8.3. Page Layout ...................................................................................... 37

    Exercise 14: Design changes on a report ................................................ 38

    9 Working With Controls and Labels on a Report .................... 39

    9.1. Control or Label? .............................................................................. 39

    9.2. Editing a Label ................................................................................. 39

    9.3. Moving and Resizing Controls in a Layout ..................................... 39

    9.4. Gridlines Around a Layout .............................................................. 40

    Exercise 15: Working with controls and labels on a report ................... 40

    10 Formats and Properties in a Report ..................................... 41

    10.1. Formatting a Label or Control Using Buttons ................................ 41

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    6/102

    Access: Creating queries, forms and reports TDAC

    IT Learning Programme vi

    10.2. The Report Background ................................................................. 42

    10.3. Property Sheet for Individual Controls ......................................... 42

    10.4. Properties of a Section or Whole Report ....................................... 43

    10.5. Changing the Record Source of a Report Including Queries

    (Optional) ............................................................................................... 43

    Exercise 16: Formats and properties in a report .................................... 44

    11 Ordering Data in a Report ..................................................... 45

    11.1. Grouping Records Using the Report Wizard .................................. 45

    11.2. Sorting in a Report ......................................................................... 45

    Exercise 17: Sorting and grouping records in a report ........................... 46

    11.3. Summarising Data in a Report, Using the Report Wizard ............ 46

    Exercise 18: A report with summary calculations .................................. 49

    12 What Next? ............................................................................ 50

    12.1. Downloadable Course Materials and More the ITLP Portfolio .. 50

    12.2. Databases: Concepts of database design ....................................... 50

    12.3. Access Courses Which Precede This .............................................. 50

    12.4. Access Courses Which May Follow This ........................................ 50

    12.5. Computer8 ...................................................................................... 50

    12.6. IT Services Help Centre ................................................................. 50

    Appendix 1: Viruses and Security Levels inAccess.................... 51

    Why Worry About Viruses? ..................................................................... 51

    Scanning for Viruses ................................................................................ 51

    Access 2010and Virus Security ............................................................... 51

    Access 2003and Virus Security ............................................................. 55

    Further Help with Security and Trust Center Settings .......................... 56

    13 Appendix 2: Student Exercises ............................................. 57

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    7/102

    Access: Creating queries, forms and reports

    1 IT Learning Programme

    1IntroductionWelcome to the course

    Access

    :Creating Queries, Forms and Reports

    .

    This handbook accompanies the course delivered by Oxford University ITServices, IT Learning Programme. Although the exercises are clearly explained so

    that you can work through them yourselves, you will find that it will help if youalso attend the taught session where you can get advice from the teachers,demonstrators and even each other!

    If at any time you are not clear about any aspect of the course, please make sureyou ask your teacher or demonstrator for some help. If you are away from theclass, you can get help by email from your teacher or from [email protected]

    1.1.What You Should Already Know

    This session is one of a series that cover the important aspects of using MicrosoftAccessto build and manage a database.

    We will assume that you have already attended the courseAccess: Building a

    database

    (or equivalent), and that you are familiar with creating tables withsuitable fields, and using objects in anAccessdatabase to add or edit data,running forms, queries and reports that have already been created.

    You do not need to know anything about creating a query, form or report.

    The computer network in the ITLP teaching rooms may differ slightly from thatwhich you are used to in your College or Department; if you are confused by thedifferences, ask for help from the teacher or demonstrators.

    1.2.What You Will Learn

    In this session we will cover the following topics:

    Designing and running a query to select data from a database table

    Editing a query and setting criteria

    Instant forms and reports

    Creating forms and reports using a wizard

    Simple design changes on forms and reports in Layout View

    Working with individual controls on forms and reports

    Grouping and summarising data on a report

    RelatedAccesssessions, should you be interested, are described in Part 12.4below.

    1.3.

    What isAccess?

    Accessis database management software. It enables you to build and maintain adatabase.

    Access 2010is part ofMicrosoft Office 2010(only in the Professional, Ultimate,and Enterprise editions for Windows).Accessis not available for Macintoshcomputers (Mac users may tryFileMaker Pro).

    AnAccessdatabase consists of the data held in a number of tables, plus a number

    of other objects which are used to manage the data. All these are saved together ina single file. In this course, we will deal with tables, forms, queries and reports.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    8/102

    Access: Creating queries, forms and reports

    IT Learning Programme 2

    A database applicationmay be built using forms, menus, control buttons andprogram code that respond to events.

    1.4.Where Can I Get A Copy?

    If you have a copy ofMicrosoft Office Professional 2010, then you already have a

    copy ofAccess 2010. If you are unable to find it on your computer, it may nothave been installed and you should talk to your IT support contact (or the ITServices Help Desk).

    1.5.Using Office 2010

    If you have previously used another version of Office, you may find Office 2010looks rather unfamiliar. Office 2010: Whats New is a self-study guide coveringthe Ribbon, Quick Access Toolbar and so on. This can be downloaded from theITLP Portfolio at http://portfolio.it.ox.ac.uk (look in theAccesscategory).

    For anyone who prefers not to use a mouse to control software, or who finds akeyboard method more convenient, it is possible to control Office 2010

    applications without using a mouse. Pressing ALTonce displays a white box witha letter or character next to each visible item on the Ribbon and title bar (shownin Figure 1).

    Figure 1

    Keystrokes to Control Ribbon Tabs and Title Bar(Press ALTto show these)

    After you have typed one of the letters/characters shown, the relevant Ribbon tab

    or detail appears, with further letters/characters for operating the buttons andcontrols (shown in Figure 2).

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    9/102

    Access: Creating queries, forms and reports

    3 IT Learning Programme

    Figure 2

    Further Keystrokes to Control Buttons

    The elements of a dialog can be controlled, as usual with Windowsapplications,by using TABto navigate between items or by typing the underlined charactershown beside an item.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    10/102

    Access: Creating queries, forms and reports

    IT Learning Programme 4

    2Getting Started

    2.1.Some Database Vocabulary

    A collection of database information is organised into one or more tables. Youmay think of each table in a grid layout.

    Each row of the table is known as a record. There must be one record for eachitem included in the table for example, the records may be the employees in adepartment, the books in a library or the individual wall paintings in an ancientcave. The order of the records is not important: indeed it is often useful to changethe order the records are shown in, when analysing the data.

    Each column of the table is known as afield. Each field contains a different pieceof information about the record items for example, an employees date of birth,a books author or the dimension(s) of a wall painting. All the entries in onecolumn must have the same data type e.g. all text or all integer numbers.

    The set of tables, along with the queries, forms and reports used to manipulate

    them, are saved together in oneAccessfile.The importance of designing the set of tables correctly, with appropriate fieldscollected together in tables, and with relationships joining the tables, has beendiscussed in the course

    Access: Building a database

    .

    2.2.Using the Database Files for ITLP Exercises Access 2010

    Please note thatAccess 2010only trusts files if they have been saved in a TrustedLocation. The network

    dr ive

    H:\

    , used for most IT Learning Programme courses,has been designated an Access Trusted Location. If you make copies of the filesfor these exercises, and save them on your own computer in a location that is nottrusted, you may not be able to carry out all the activities described.

    Appendix 1 discusses the question of virus protection and trusting locationsfurther.

    Exercise 1: Opening a database file

    Now look at this exercise (page 57).

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    11/102

    Access: Creating queries, forms and reports

    5 IT Learning Programme

    3Queries

    3.1.Using Queries

    A query is used to investigate and manipulate data that has been entered into thetables that make up a database.

    A query may be used to:

    Sort records

    Select only some fields

    Select only some records using criteria

    orCollect related data from several tables

    3.2.Creating A Select Query

    3.2.1.A Query To Select Records In One Table

    Suppose you have a database file open, with a table already created and filled withsuitable data.

    Figure 3

    Table Design

    It may be interesting to present only some of the fields from the table, to startconsidering the significance of the data. A query can be created to do this, basedon the table.

    Queries that have already been created are listed in the Navigation Pane on theleft-hand side of the screen. If you do not see the queries, select

    Object Type

    (under

    Navigate To Category

    ), then go back to this menu and make sureAll

    Access Objects is selected as well.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    12/102

    Access: Creating queries, forms and reports

    IT Learning Programme 6

    Figure 4

    Showing All Access Objects (including Queries, if any)

    3.2.2.Using the Query Wizard

    TheQuery Wizard

    is started by selecting on theCreate

    tab of the Ribbon,

    then selecting Simple Query Wizard from the list. The wizard takes you step bystep through creating a new query. Here you specify the table it is to be basedupon, and choose which fields are to be included.

    Figure 5

    The Query Wizard

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    13/102

    Access: Creating queries, forms and reports

    7 IT Learning Programme

    In the next part of the wizard, the query is given a name.

    Figure 6

    The Query Wizard, continued

    3.2.3.Naming Queries and Other Objects in a Database

    By convention, query names always begin with qry . Similarly, table names beginwith

    tbl

    , form names begin withf rm

    and report names begin withrpt

    . These

    Reddick naming conventions can be found athttp://mvps.org/access/general/gen0012.htm .

    Although it is possible inAccessto include spaces in object names, it is goodpractice to avoid them. This is because when an object name is included in anexpression (perhaps in a calculation), then any spaces are difficult forAccesstoparse and you must remember to enclose the object name in [square brackets]every time. If there are no spaces, then the names of queries, forms etc are notambiguous and expressions are easier forAccess(and people) to read. This alsoapplies to the names of fields and controls.

    Designers may use a mixture of lower case and capital letters, or may use somepunctuation symbols to make object names and field name easy to understand.

    Examples might be tblStudentApplications or qryLateReplies , orfrmSimple_Address_List

    .

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    14/102

    Access: Creating queries, forms and reports

    IT Learning Programme 8

    3.2.4.Query Results

    After the wizard finishes, the query results are presented in Datasheet View, bydefault.

    Figure 7

    Query Results in Datasheet View

    Each time the query is run,Accessre-queries the raw data in the table andpresents up-to-date results.

    Only those fields chosen in the query wizard are shown. All records are shown(until we set some criteria, as discussed below). The data in this view canbeedited changes made here will affectthe underlying data in the table.

    3.2.5.Looking at the Query in Design View

    Click on theHome

    tab of the Ribbon to switch from Datasheet View to

    Design View.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    15/102

    Access: Creating queries, forms and reports

    9 IT Learning Programme

    Figure 8Simple Query in Design View

    In Design View, all tables that are used in the query are shown at the top. In thedesign grid below, field names are chosen and set in order.

    3.2.6.Switching Query Views

    The View button is now visible on the Home tab or the Query Tools Design tab,

    and it has changed appearance to . This will switch back to Design View.

    Use to close the query. You will be prompted to save any changes to the query

    design (recall that any edits or additions to data are saved without comment asyou move between records).

    Exercise 2: Creating select queries

    Now look at this exercise (page 58).

    3.3.Creating a Query in Design View

    3.3.1.Relationship Between Two Tables

    If the data in separate tables is related, then relationships must be set up betweencorresponding fields. This was discussed in a separate course, Access:Database Structure

    , which considers the wider question of definingrelationships for a whole database (see Part 12.1).

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    16/102

    Access: Creating queries, forms and reports

    IT Learning Programme 10

    A query based on two or more related tables will look for records in one tablewhich correspond to records in the other table. For example, each person in anaddress book will be associated with the household where they live.

    In this way, a one-to-many relationship can be represented, without duplicatingdata between records. For example many members of a household may live at one

    address, but each has their own birthday.3.3.2.Creating a Query With Two Tables

    To create a new query in design view, choose from the Create tab on the

    Ribbon. The empty query design grid is shown, with theShow Table

    dialogwhere you can select from the available tables (and queries).

    Figure 9

    Adding Tables to Query Design

    In the query design grid, lines appear between the tables for any joins that have

    previously been set up.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    17/102

    Access: Creating queries, forms and reports

    11 IT Learning Programme

    Figure 10

    Two Tables With a Join, in Query Design Grid

    3.3.3.

    Adding Fields to a Query

    The required fields can be added into the empty columns in the design grid, usingdifferent methods:

    Drag a field name from a table field list and drop it in an empty column

    Double-click a field name in a table field list it will appear in the nextempty column

    Click at the top of an empty column to display an arrow button; click thisto activate a drop-down list, then choose a field name from the list

    Add as many fields as are needed, from either or both tables, in any convenient

    order.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    18/102

    Access: Creating queries, forms and reports

    IT Learning Programme 12

    Figure 11

    Building a Query With Two Tables

    If necessary later, add a further table by clicking and choosing the table name

    in theShow Table

    dialog.

    3.3.4.Running a Query Based on Two Tables

    Click or (for select queries, the two buttons are equivalent) to run the

    query.Accesscollects current data from the tables and presents them as adatasheet.Accesscompares the records in both tables, looking at the field in eachwhich is used in the join relationship. Any value of that field which arises in bothtables is deemed a match, and that record is included in the results dataset.

    Figure 12

    Results of a Query From Two Tables

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    19/102

    Access: Creating queries, forms and reports

    13 IT Learning Programme

    Exercise 3: Creating a query in Design View

    Now look at this exercise (page 60).

    3.4.

    Setting Query Criteria

    Criteria can be set in the query design grid, to limit which records are included.

    3.4.1.Criteria With Equals

    On the row labelled Criter ia , text or a simple number can be entered under thefield to be limited. When the query is run, only those records which have thecriteria value will be included in the results dataset presented.

    Figure 13

    A Query with Text Criteria

    3.4.2.Changing Criteria in a Query Design

    Add further criteria by typing in theCriter ia

    row.

    Remove criteria by deleting in theCriter ia

    row: click in the criteria expressionand use DELETEor BACKSPACE.

    3.4.3.Criteria With Comparison Operators

    Calculated expressions can be used as criteria. Use , =, Betweenforcomparison expressions.

    UseNotfor not equal to. Use Is Nullfor no value entered (beware that if a spaceis typed in a field, this will not count as a null entry, so users should bediscouraged from doing this).

    For example:

    >t in a LastName field, to find those people whose surnamesbegin with t or later in the alphabet

    >=18 in anAge

    field, to find only those who are of voting age

    Is Null in anEmployeeNumber

    field, to find those whose companynumber did not get filled in

    Not UK in a Country field, to find overseas clients

    Complex expressions can be built, using brackets (and )to maintain clarity.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    20/102

    Access: Creating queries, forms and reports

    IT Learning Programme 14

    Figure 14

    Criteria Using Comparison Operators

    3.4.4.Access Edits Punctuation in Criteria

    Accessmay add punctuation to your criteria, such as quote marks around textor #hatches# around dates.

    Figure 15

    Setting Date Criteria

    3.4.5.Wildcard Symbols in Criteria

    Including a ?symbol in an expression allowsAccessto select all values which matchthe expression, but allowing any single character in the position marked by ?.

    # allowsAccessto match any single numerical digit

    * allows any characters or digits, in any quantity, at the positionmarked by *

    For example:

    J?lly will find Jolly, Jelly, Jillybut not Jenelly

    am* will find amicable,Americanand ambut not agenor a

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    21/102

    Access: Creating queries, forms and reports

    15 IT Learning Programme

    3.4.6.Yes/No Criteria

    In a field which has the Yes/No data type, criteria may be set. Enter YesorNointhe criteria line. Alternatively, enter 0(equivalent toNo) but note that theequivalent to Yesis -1.

    3.4.7.

    Multiple Criteria: AND and ORSetting several criteria on the same row narrows down the results of a query: youare permitting only those records which satisfy all the criteria (this is a logicalAND).

    Figure 16

    Multiple Criteria (AND)

    Setting criteria on separate rows widens the results of a query: you are permittingthose records which satisfy any of the criteria (this is a logical OR).

    Figure 17Multiple Criteria (OR)

    Exercise 4: Setting criteria in a query

    Now look at this exercise (page 62).

    3.5.Editing a Query Design

    3.5.1.Removing a Field

    Click the field name at the top of a column, then delete using DELETEor

    BACKSPACEkeys. Note you are only removing the field name from the querydesign, not deleting data from the underlying table.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    22/102

    Access: Creating queries, forms and reports

    IT Learning Programme 16

    3.5.2.Rearranging Columns

    Select a field by clicking on the narrow grey bar at the top of the column. Thendrag the column to the desired position and drop.

    Figure 18

    Selecting a Field

    3.5.3.Adjusting Column Width

    Drag the divider between two column headings to make one column wider ornarrower. Note this changes the column width in Design View. For wider columnsin Datasheet View, drag the column dividers there.

    3.5.4.Hiding/Showing A Field Column

    In theShow

    row, clear the checkbox under a field to omit that field from thequery results. Check the box to show that field again.

    3.5.5.

    Sorting Query ResultsIn the

    Sort

    row, chooseAscending

    orDescending

    in the column of the field youwish to sort by. When the query is run, the records will be presented sorted bythat field value.

    If more than one column has a Sort, then results will first be sorted by theleftmost marked field, then sorted by the next marked field, and so on workingfrom left to right.

    Figure 19

    Sorting Families by LastName and then by Birthday (Age)

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    23/102

    Access: Creating queries, forms and reports

    17 IT Learning Programme

    3.6.Finishing

    Close the query by clicking , saving when prompted.

    The query name appears on the list in the Navigation Pane. Delete a query ifnecessary by selecting the query name and pressing DELETE,agreeing to the

    confirmation dialog.

    Exercise 5: Rearranging a query

    Now look at this exercise (page 65).

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    24/102

    Access: Creating queries, forms and reports

    IT Learning Programme 18

    4Creating FormsIn addition to tables and queries, the Navigation Pane also displays a list of any

    forms that have been created (using the Navigation Pane options menu , make

    sure thatObject Type

    andAll Access Objects

    are selected).

    Forms can make data entry easier for you or other users of the database. A form isused for working on the data that is saved in the tables.

    Figure 20The Navigation Pane Listing Forms

    4.1.Creating a Form Instantly

    Accesscan create a form based on an existing table or query. This is the quickestway to generate a form. First, you must select a table or query in the Navigation

    Pane. Then click on the Create tab of the Ribbon.

    A new form is created, using all the fields in the selected table/query and a defaultchoice of layout. The new form opens in Layout View.

    If you want to enter data using this form, switch to Form View by clicking

    (on theHome

    tab).

    When ready, close the form by using . You are prompted to give it a name note that the suggested name will be the same as the table name it was based on,so you should ensure that the prefix is changed to

    f rm

    before saving.

    Exercise 6: Using a form and creating an instant form

    Now look at this exercise (page 67).

    4.2.Using the Wizard to Create a Form Based on a Table

    Another way to generate a form is to use the wizard. is found on

    theCreate

    tab of the Ribbon.

    The wizard takes you through the steps to choose the fields, layout, andappearance of the form.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    25/102

    Access: Creating queries, forms and reports

    19 IT Learning Programme

    The first step is to select the table which contains the data required. Its fields thenappear, listed in the

    Available Fields

    box.

    Here you can choose which of these fields are required in the form, by selecting afield name and clicking

    >

    or double-clicking a field name. This transfers thefield name into the right-hand list of Selected Fields. Clicking >> will transfer

    all available fields. Use < or

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    26/102

    Access: Creating queries, forms and reports

    IT Learning Programme 20

    Figure 22

    Form Wizard Based on a Query

    Depending on the structure of the data, the wizard may ask how you want to viewyour data. This is discussed in more detail in the later IT Learning Programmecourse

    Access: Designing Forms and Reports

    (see Part 12.4).

    Figure 23

    Form Wizard Based on a Query, continued

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    27/102

    Access: Creating queries, forms and reports

    21 IT Learning Programme

    4.4.Using the Form

    Form names appear in the Navigation Pane. Double-clicking a form name opensit in Form View, showing one or more records. Here you can navigate betweenthe fields and records, and view, edit or add data.

    Figure 24

    A Form Created Using the Wizard, Shown in Form View

    4.5.Managing Forms

    Close the form from Layout View by clicking . If the form design has beenchanged, you will be prompted to save. You are saving changes to the formdesign, not changes to the stored data (which was saved automatically as youworked).

    The name of the form appears in the Navigation Pane.

    Delete any unwanted form by selecting its name in the Navigation Pane, pressingDELETE, and then agreeing to the confirmation dialog.

    Exercise 7: Creating a form using the wizard

    Now look at this exercise (page 68).

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    28/102

    Access: Creating queries, forms and reports

    IT Learning Programme 22

    5Design Changes on a Form

    5.1.Switching Between Views of a Form

    There are a number of ways to view a form once it is open. These are found usingthe first button at the left end of the Home tab (and also the Form Layout Tools

    tab when available). The face of this button varies, including , so it can

    be used to toggle between Form View and Layout View.

    If you click on the arrow below the button image, however, you can see a list ofViewing options. You should choose the view based on what you need to do withthe form:

    Form View is the default view where you edit the data.You cannot change the layout of the form.

    Layout View allows you to rearrange and change theappearance of the form.Sample data is visible (so you can get an idea of whatthe form will look like in Form View) but is noteditable.

    Design View allows the most detailed design changes.No data is displayed. This view is covered in anothercourse (see Part 12.4).

    We will focus on Layout View for the remaining work in this course.

    5.2.Themes on a Form

    When you switch to Layout View, three new Ribbon tabs appear, entitledForm

    Layout Tools

    . Not surprisingly, theDesign

    tab gives you control over the designof the whole form.

    You can easily change the whole look of the form (fonts, colours, borders, etc.) by

    using the Themes Gallery. Clicking on theDesign

    tab displays a gallery of

    theme designs. Selecting one of the options will re-format many of the elementson the form.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    29/102

    Access: Creating queries, forms and reports

    23 IT Learning Programme

    Figure 25

    Themes Gallery

    5.3.Editing Labels

    A form that is created as an instant form or using the wizard has a plain label

    connected to each control.

    In the first instance, these labels use the field names (e.g. LastName or Address1)or the caption if one has been defined in the table design.

    You may now prefer to modify the text in a label, so that it describes the fieldmore clearly (e.g. Students Surname, Address Line 1).

    The text in labels can be easily edited: click the label once to select it (notice theorange outline that appears around the object). Click a second time, inside thebox, to see a flashing insertion point. Work with this as you would inword-processing: remove text using DELETEor BACKSPACE, then re-type the textas needed. Click outside the label object when finished.

    If you want to completely remove a label from the form, click the label once toselect it and then press DELETE.

    5.4.Moving and Resizing Form Objects

    The two main types of elements on a form are controls and labels. Thecontrols

    are boxes where the user of the form will actually enter data (corresponding to aparticular field in a table). In Layout View, these boxes are displayed with sampledata inside.

    Most field controls have an associated label to identify the information whichshould be given in the control. Additional labels are sometimes used to display atitle or other information on the form.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    30/102

    Access: Creating queries, forms and reports

    IT Learning Programme 24

    Figure 26A Form With Text Controls and Labels

    You can select a control or label by clicking on it. An orange border will appeararound the object. You can then move the object by dragging and dropping, orresize the object by dragging an edge. A selected object can also be moved aroundusing the arrow keys (up, down, left, right).

    Exercise 8: Design changes on a form

    Now look at this exercise (page 69).

    5.5.

    Selecting Multiple Objects

    If you want to move or resize multiple items at once, first select a series of itemsby holding down SHIFTwhile clicking on the individual controls or labels. Thendrag to move or resize. This is especially helpful if you want to move a controlwith its label to a new location, or want to make sure that several controls are thesame size.

    5.6.Arranging and Aligning Form Objects in a Layout

    For a regular, neatly-aligned look, form objects can be organised into alayout

    , by

    selecting the relevant controls and labels and choosing or on theArrange

    tab.

    Figure 27

    A Form with a Stacked Layout

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    31/102

    Access: Creating queries, forms and reports

    25 IT Learning Programme

    Figure 28

    A Form with a Tabular Layout

    A layout on a form is a predefined grid-like structure, which manages all theelements as a set. Buttons for rearranging and moving items in a layout areprovided on the A r r a n g e tab.

    Figure 29

    Buttons for Working in a Layout on a Form

    When working on controls in a layout, it is usually necessary to select the relevantcolumn or row first, before trying to change a height, width or position: use

    and .

    Note that if a form was created using the Instant Form tool (as described in Part4.1), the controls may be fixed into a layout automatically.

    Layouts like this are discussed in more detail in the later ITLP courseA c c e s s :

    D e s i g n i n g F o r m s a n d R e p o r t s (see Part 12.4).

    Exercise 9: Using a layout on a form

    Now look at this exercise (page 71).

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    32/102

    Access: Creating queries, forms and reports

    IT Learning Programme 26

    6Formats and Properties of Form ObjectsFor this course, we will focus on working with a form in Layout View. Other viewsare discussed in a later course.

    6.1.

    Using Buttons for Formatting Controls and LabelsRemember that in Layout View some sample data is shown in the controls, tohelp you with the layout, but you cannot edit the values here. You can modify theformatting of a control or label using buttons on the Ribbon.

    For each of these, start by selecting the control(s), then click a button.

    A variety of popular formats can be applied, by using buttons on the F o r m a t tab:

    Figure 30Popular Formatting Buttons

    Familiar buttons are used for changing the appearance of text in a selected

    control, such as (bold) (italic) and (underline).

    Drop-down list boxes change the font or font size .

    Alignment buttons will change the way text is aligned horizontally

    within its box. The appearance of any object may be changed using further

    buttons for colours, border styles etc.

    The Paste Formatting button can be used to pick up the formatting of one

    object and paste it onto another object.

    Improve the colour and appearance of a control using and

    which includes colours, line thickness etx.

    6.2.Data Formats in a Form Control

    There are some additional options available for individual field controls. If thecontrol displays numerical data, you can change the number format, for examplespecifying the number of decimal places to display, or displaying the value as apercentage.

    Figure 31

    Options for Number Format

    Similarly, a variety of formats are available for displaying dates and times.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    33/102

    Access: Creating queries, forms and reports

    27 IT Learning Programme

    6.3.Conditional Formatting

    With conditional formatting, the formatting for the control changes, dependingon the value of the control contents, record by record. For instance, the textcolour might be set to be green whenever the value in the field represents a pass(score exceeds, say, 60%) and to be red if the value represents a fail. Formatting

    the controls like this could help important data stand out on the form.

    Figure 32

    Conditional Formatting for a Control

    Exercise 10: Formatting controls and labels on a form

    Now look at this exercise (page 73).

    6.4.Property Sheet

    The behaviour and appearance of a control can be changed by editing itsproperties in the Property Sheet.

    If the Property Sheet is not visible, clicking on theD e s i g n

    tab will show it.

    When an object is selected, its properties are listed in the Property Sheet, and theselected object is named at the top of the sheet, for confirmation.

    Overtype the previous value, or choose from a drop-down list if offered.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    34/102

    Access: Creating queries, forms and reports

    IT Learning Programme 28

    Figure 33Layout View of a Form, Showing the Property Sheet

    The Properties are divided using tabs, and they include:

    Format

    properties some of these properties may have been set usingtoolbar buttons, see above

    Data

    properties here a default value and/or validation rule can be set,and the control source is specifiede.g. Enabled=Yes means the user can place the focuson a control using the mouse or keyboard;

    Locked=Yes means the user cannot alter the valueset in a control

    Event properties a procedure or macro can be set to take place on acontrol event, such as when it is clicked or when itsvalue is updated

    Other

    properties these include whether the control can be reached bypressing TAB, and the text that appears in the status baror on a control tip

    6.5.Form Properties

    The background colour of the form itself can be changed, by clicking the formbackground then using to choose a colour.

    To select the form as a whole, click the Form Selector the bar along the left edgeof the form or use the drop-down at the top of the Property Sheet. The PropertySheet then displays the properties of the form.

    Form properties include:

    Caption alternative text to appear on the title bar in Form View

    Scroll bars display vertical, horizontal or both or neither

    Record selectors show or hide them

    Dividing lines between Detail and Header/Footer

    Min/max buttons enable either or both

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    35/102

    Access: Creating queries, forms and reports

    29 IT Learning Programme

    Auto center the form is automatically displayed at the centre of thewindow

    ... and a range of form events.

    6.6.Changing the Record Source of a Form Including Queries

    When a form is created using the wizard or the Instant Form tool, the tablenominated becomes the record sourceof the form: the place whereAccesswillseek values to display in the field controls.

    Usually the record source need not be changed. However, if the form is to displayvalues based on a different source, then this property of the form can be changedin the Property Sheet.

    It is common to base a form on a query, if fields are to be drawn from more thanone table. In this case, the query must be set as the record source, by choosing thequery name as the record source property.

    Figure 34

    Changing the Record Source of a Form

    Exercise 11: Using the Property Sheet

    Now look at this exercise (page 74).

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    36/102

    Access: Creating queries, forms and reports

    IT Learning Programme 30

    7Creating ReportsA report is another way to present information taken from a table or query. Datacannot be edited in a report; instead, a report provides a snapshot of the data atthe time the report is run. The data is often displayed in a layout suitable forprinting, with several records on a page and summary calculations added.

    A report that is well designed helps the user to read and interpret the data muchmore easily than by looking at the same information in the table. As usual,available reports are listed in the Navigation Pane.

    Figure 35

    The Navigation Pane Listing Reports

    7.1.Creating a Report Instantly

    Starting from a selected table or query, a report can be created automatically, by

    selecting the required table or query in the Navigation Pane, then choosing

    from theCreate

    tab of the Ribbon.

    A new report is created, using all of the fields in the selected table/query and a

    default choice of layout. The new report opens in Layout View for editing: is

    used to switch to Report View.

    When you close the report, you are prompted to give it a name note that thesuggested name will be the same as the table name it was based on, so you shouldchange the prefix tbl to rpt before saving.

    Exercise 12: Creating a report instantly

    Now look at this exercise (page 77).

    7.2.Using the Wizard to Create a Report Based on a Table

    on theCreate

    tab of the Ribbon will start the wizard.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    37/102

    Access: Creating queries, forms and reports

    31 IT Learning Programme

    The first part of the wizard is for choosing the table the report is to be basedupon. Then fields are chosen from those available: the field name is selected, then>

    and>>

    are used to move field names from left to right (and

    . Press ENTERto move onto a new line in the label, and type othercharacters as needed.

    Figure 42

    Assembling Fields Onto a Label

    Finally, set a sort order if wanted, and give the report a name.

    It is a good idea to preview the report before printing on real sheets of stickers.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    42/102

    Access: Creating queries, forms and reports

    IT Learning Programme 36

    Figure 43

    Preview of a Labels Report

    7.6.Managing Reports

    Close the report by clicking . If the report design has been changed, you will be

    prompted to save.

    The name of the report appears with any others in the Navigation Pane.

    Delete any unwanted report by selecting its name in the Navigation Pane,

    pressing DELETE, and then agreeing to the confirmation dialog.

    Exercise 13: Creating a report using the wizard

    Now look at this exercise (page 77).

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    43/102

    Access: Creating queries, forms and reports

    37 IT Learning Programme

    8Design Changes on a Report

    8.1.Switching Between Report Views

    There are a number of ways to view a report. You should choose a view based onwhat you need to do with the report.

    Report View is the default view where you review thedata in the report.

    Print Preview is used to view the report as it will beprinted (with pagination).

    Layout View allows you to rearrange and change theappearance of the report. Sample data is visible but isnot editable.

    Design View allows the most detailed design changes.No data is displayed. This view is covered in another

    course (see Part 12.4).

    As with Forms, we will focus on Layout View for the remaining work in thiscourse.

    8.2.Themes on a Report

    When you switch to Layout View, four new Ribbon tabs appear, entitledR e p o r t

    L a y o u t T o o l s

    .

    You can easily change the whole look of a report (fonts, colours, borders, etc.) by

    clicking on the D e s i g n tab. Selecting one of the options from the ThemesGallery will re-format many of the elements on the report.

    8.3.Page Layout

    In Layout View (or in Print Preview), you can control printing options using pagesetup. Choose the

    P a g e S e t u p

    tab amongR e p o r t L a y o u t T o o l s

    . Here you canchange the paper size and change the orientation between portrait and landscape.

    Clicking on launches the P a g e S e t u p dialog with additional options.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    44/102

    Access: Creating queries, forms and reports

    IT Learning Programme 38

    Figure 44

    The Page Setup Dialog

    If you need to add (or change the format of) page numbers for a printed report,

    insert page numbers using

    on theD e s i g n

    tab.

    Figure 45Inserting/Formatting Page Numbers

    Exercise 14: Design changes on a report

    Now look at this exercise (page 79).

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    45/102

    Access: Creating queries, forms and reports

    39 IT Learning Programme

    9Working With Controls and Labels on a Report

    9.1.Control or Label?

    A control is the box where data from a field is shown. Most controls are bound toa particular field in the table or query that the report is based on.

    A label is the piece of text which may appear close to a control, stating what iscontained there. Typically, the label is the field name or a more human-readablevariant of the field name.

    Typically, labels are put in the headers and footers of a report, where they act asbanners across the edge of the paper or as column headings. Controls in thedetailsection of the report show the data values from the records and fields.

    9.2.Editing a Label

    The label text for column headings or the report title can be edited directly inLayout View by clicking the label once to select it (notice the orange outline that

    appears around the object) and then clicking a second time inside the box to see aflashing insertion point. Use this as you would in word-processing: remove textusing DELETEor BACKSPACE, then re-type the text as needed. Once you havemodified the text, you can resize the label to fit the new contents.

    If you want to completely remove a label from the report, click the label once toselect it and then press DELETE.

    9.3.Moving and Resizing Controls in a Layout

    In Layout View, you can select a control or label on a report by clicking on it.Because information in a report is often structured in a grid format known as alayout1, you will notice that an orange border appears around the object, and a

    lighter orange border appears around any other related objects (for instance,other controls which display data from the same field). Any changes will affect allof the controls with the light orange outline.

    Figure 46

    Selecting a Control (With Others in the Same Field)

    1Layouts were mentioned earlier in this course, when editing forms (part 5.6)

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    46/102

    Access: Creating queries, forms and reports

    IT Learning Programme 40

    You can drag a control to move it (along with other controls in the same layout).Dragging a control sideways changes the order of the columns, and dragging acontrol up or down changes the spacing between the rows in the report. You canalso drag the edge of the control to resize all of the selected textboxes.

    Clicking in the left or right margin of the report selects an individual record.

    Figure 47

    Selecting a Record

    Working with structured layouts like this is discussed in more detail in the laterITLP course Access: Designing Forms and Reports (see Part 12.4).

    9.4.Gridlines Around a Layout

    If the report displays information in a layout, you may want to display gridlines asa guide within the layout. In that case, it is helpful to click inside the layout andthen click on the square handle (at top left) to select the entire layout.

    Clicking on the Format tab displays gridlines between each row, each

    column, or both.

    Figure 48

    Options for Gridlines in a Layout Table

    Exercise 15: Working with controls and labels on a report

    Now look at this exercise (page 81).

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    47/102

    Access: Creating queries, forms and reports

    41 IT Learning Programme

    10Formats and Properties in a Report

    10.1.Formatting a Label or Control Using Buttons

    The Formattab gives you control over the appearance of a selected reportelement.

    As discussed in Part 9 above, when you click on an individual control in LayoutView, you often select an entire column or collection of controls (i.e. all of thecontrols related to a single field). Any formatting changes are applied to all of therelated controls.

    Using the buttons on the Format tab, you can also change the font name, size,style (bold, italic, underline), alignment (left, centre, right), text colour andbackground colour of the selected label(s).

    Figure 49

    Formatting the Appearance of a Label or Control

    In addition to changing its appearance, if a control displays numerical or datedata, you can change the number or date format. For example you might specifythe number of decimal places to display, display the value as a percentage, orchange to a short date form.

    Figure 50

    Options for Number and Date Format

    You can also set up conditional formatting by choosing on the Format tab.

    Conditional formatting changes the appearance of a control, depending on thevalue of the control contents. Formatting controls in this way could helpimportant data stand out on the report.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    48/102

    Access: Creating queries, forms and reports

    IT Learning Programme 42

    Figure 51

    Conditional Formatting for a Control

    10.2.

    The Report BackgroundThe background colour of the report itself can be changed, byfirstclicking the

    report background thenusing to choose a colour (choose with some care, if

    the report is to be printed on paper).

    10.3.Property Sheet for Individual Controls

    Further changes can be made to the behaviour or appearance of parts of a report,by changing properties in the Property Sheet. The Property Sheet is displayed

    using .When an object is selected, its properties are listed in the Property Sheet and theselected object is named at the top of the sheet, for clarity.

    Select a control or section of the report, to see its properties listed in the PropertySheet. These can be changed independently.

    Figure 52

    Properties of a Text Box Control

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    49/102

    Access: Creating queries, forms and reports

    43 IT Learning Programme

    The Property Sheet is divided into tabs. Some of the properties on theFormat

    tabcan also be changed using buttons on the Ribbon. A property can be changed byovertyping the value in the Property Sheet, or by choosing from a drop-down listif one is offered.

    OtherFormat

    properties include:

    Visib le the control can be present on the report, but made not visiblefor convenience or temporarily

    Can Grow the control or section adjusts vertically to show all the data itcontains

    Can Shrink

    the control or section shrinks vertically to remove all sparelines when its data is displayed

    Further properties are shown in theData

    andOther

    tabs (there are no eventsassociated with individual controls on a report, because a report is intended to beprinted on paper rather than operated in a window).

    10.4.

    Properties of a Section or Whole ReportClick a section (Detail, Header or Footer) to see its properties listed in theProperty Sheet. Another way to see the properties of some part of a report,including the report itself as a unit, is to choose using the drop-down list at thetop of the Property Sheet.

    Format properties of a section includeForce New Page

    : set this toAfter

    in aFooter, to ensure that the next data group is placed on a new page when printing.

    Data properties include setting a Filter and/or Sort order for a report.

    A useful property of the report is theCaption

    , which is the text that appears inthe title bar when the report is run (it is usually desirable to change this from the

    default which may be a table or query name that is no longer appropriate).

    10.5.Changing the Record Source of a Report IncludingQueries (Optional)

    When a report is made using the wizard, the table containing the required databecomes the record sourceof the report the place whereAccesswill seek valuesto display in the field controls.

    Usually this need not be changed. However, if the report is to display valuesbased on a different source, then this property of the report can be changed in theProperty Sheet.

    It is common to base a report on a query, if fields are to be drawn from more thanone table. In this case, the appropriate query must be set as the record source, bychoosing the query name as the Record Source.

    If a report is fairly simple, it may be more convenient to create a new one usingthe wizard, basing the report on a query at the outset.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    50/102

    Access: Creating queries, forms and reports

    IT Learning Programme 44

    Figure 53Changing the Record Source of a Report

    Exercise 16: Formats and properties in a report

    Now look at this exercise (page 82).

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    51/102

    Access: Creating queries, forms and reports

    45 IT Learning Programme

    11Ordering Data in a Report

    11.1.Grouping Records Using the Report Wizard

    In the Report wizard, you can choose to group together all records which have thesame value in a particular field. For instance, grouping by LastName will collectall the records for the Jones family together, with the label Jones printed justonce before this set of records.

    Figure 54Grouping by a Field

    Select the field name in the left-hand list, and click > to add it as a groupinglevel. The effect is previewed on the right-hand side.

    11.2.Sorting in a Report

    When a new report is created using the wizard, a sort order can be set, so thatrecords appear in alphabetical/numerical order by one or more fields. Choose a

    field name to sort by, then click to select or beside

    each sorting field.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    52/102

    Access: Creating queries, forms and reports

    IT Learning Programme 46

    Figure 55

    Setting the Sort Order in Report Wizard

    Figure 56

    A Report with Grouped and Sorted Records

    If you do not get the grouping and sorting that you want, it is often easiest todelete the report and run the wizard again.

    Exercise 17: Sorting and grouping records in a report

    Now look at this exercise (page 84).

    11.3.Summarising Data in a Report, Using the Report Wizard

    If the data includes one or more numerical fields,Accesscan make summarycalculations or running totals. This may be, for example, calculation of Sum,Maximum or Minimum Value for each field value and then a grand total or

    overall value for the whole dataset. This can be set up using the wizard, at thetime of creating a report.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    53/102

    Access: Creating queries, forms and reports

    47 IT Learning Programme

    The first parts of the wizard is used as above, specifying the table or querycontaining the data, and choosing appropriate fields, then choosing suitable viewsand grouping for the data.

    Figure 57

    Starting the Report Wizard

    In the sort order part of the wizard, appears if the data issuitable.

    Figure 58Summary Options Button Appears (when data is suitable)

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    54/102

    Access: Creating queries, forms and reports

    IT Learning Programme 48

    TheSummary Options

    dialog offers checkboxes for various summarycalculations (depending on the data fields present).

    Figure 59

    The Summary Options Dialog

    Finally the wizard the creates the report.

    Figure 60

    Report With Running Summary Calculations

    The report generated by the wizard may be rather congested, and includeunfriendly labels with text like Summary for ToyMake = BeyBlades

    (4 detail records)

    . You may want to re-word or even delete the summary labels.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    55/102

    Access: Creating queries, forms and reports

    49 IT Learning Programme

    You may also re-position some controls, and use formatting to emphasize thesummary calculations (e.g. making the labels/values bold).

    Exercise 18: A report with summary calculations

    Now look at this exercise (page 85).

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    56/102

    Access: Creating queries, forms and reports

    IT Learning Programme 50

    12What Next?Now that you have some basicAccess skills you may want to develop themfurther. IT Learning Programme offers a range of resources for study andteaching.

    12.1.

    Downloadable Course Materials and More theITLP Portfolio

    These course materials are available through the ITLP Portfolio, athttp://portfolio.it.ox.ac.uk .

    Each course pack includes the course handbook in pdf form and a zip folder of theexercise files that you need to complete the exercises. Archive versions of thecourse book may also be useful if you use an earlier version of the software.

    The ITLP Portfolio helps you find articles, videos, resources and weblinks forfurther IT study. For some resources, you will be asked for your Oxford (SSO)username and password.

    12.2.Databases: Concepts of database design

    This course takes you through the steps required to create a good relationaldatabase design from concept to implementation. The course does not use anyparticular software, so it will help you create a well-designed database structurewhich you can later build using the database software of your choice.

    12.3.

    Access Courses Which Precede This

    Access: Building a database

    12.4.Access Courses Which May Follow This

    Access: Designing forms and reports

    Access: Analysing data

    Read about the content of these courses in the IT Learning Programme Catalogueat www.it.ox.ac.uk/itlp/courses/catalogue

    12.5.Computer8

    We encourage everyone to work at their own pace. This may mean that you dontmanage to finish all of the exercises for this session. If this is the case, and youwould like to complete the exercises while someone is on hand to help you, comealong to one of the Computer8 sessions that run during term time. More details

    are available from www.it.ox.ac.uk/courses/

    12.6.IT Services Help Centre

    In the IT Services Help Centre, you can use the facilities to work through theexercises in this booklet, or use any of the applications that are available. TheHelp Centre is also a good place to get advice about any aspect of using computersoftware or hardware.

    For Help Centre opening times, visit www.it.ox.ac.uk/help/gettinghelp/ andfollow links to the General Helpdesk, or contact them by email [email protected].

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    57/102

    Access: Creating queries, forms and reports

    51 IT Learning Programme

    Appendix 1:Viruses and Security Levels inAccess

    Why Worry About Viruses?A virusis malicious code that may arrive from another computer, and copy itselfonto your hard disk. Depending on the taste of the person who devised it, it maybe just a joke, or it may destroy data or system files. Some viruses sendthemselves on to other people via your email setup.

    A virus may infect your computer while you are connected to the internet, or itmay arrive attached to an email or on a contaminated removable disk, and it maytake the form of a macroin anAccessdatabase file. It is essential to makeprovision for your computer to be scanned frequently for any viruses which mayhave arrived.

    Versions 2003 and 2010 ofAccesshandle this threat in different ways, so make

    sure you have made suitable settings for your own computer.

    Scanning for Viruses

    Virus Scanning Software

    You should install and use virus-checking software such asSophos(supported byIT Services). Other popular virus-checkers include McAfee VirusScanand NortonAntiVirus. Contact the IT Services Online Shop or visit www.it.ox.ac.uk for moreinformation about obtainingSophosat no cost or low cost for Universitymembers.

    A typical virus-checker scans your computer disks according to a preset schedule.For instance, it may be set to check the hard disk every time you start Windows,or twice a week, or to scan every document on opening. The program detects anyviruses, then alerts you and gives the options of deleting the file, putting it inquarantine or perhaps fixing it.

    Keeping the List of Viruses Up-to-date

    A virus-checking program must be kept up-to-date. It is important to connectfrequently to the virus-checking centre (this is typically done via their Internetwebsite). The virus list on your computer is then updated with all viruses knownto date, with any antidotes.

    Access 20102and Virus Security

    Access 2010considers any database file (such as.accdb

    or .mdb

    ) as a potentialroute for virus infection. It starts by disabling any automatic content, and thenasks you to decide whether to enable it.

    This applies to content such as macros and some Control Wizards and ActiveXControls.

    Information about the other levels of protection, and further options for the wayAccesshandles macros, is given in

    Access Help

    .

    2Access 2007 handles viruses in a similar way to Access 2010

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    58/102

    Access: Creating queries, forms and reports

    IT Learning Programme 52

    Security Warning Message

    When you open a database file usingAccess 2010, a Security Warning messagemay appear in a white/yellow bar near the top of the window.

    Figure 61

    Security Warning Message When a Database File is Opened

    If you do not expect to use any automatic features, you can safely ignore thismessage and continue work.

    Enabling Automatic Content For Just One Visit

    Enable Content

    on the Security Warning bar gives you the opportunity toenable any automatic content that may be present: only do this if you are surethat the database file comes from a safe source and does not contain any virus orother hostile code.

    Note that the decision toEnable this content

    is effective for this session only. Ifthe database is closed, then the decision will need to be repeated each time it isopened. This may be a convenient and cautious approach to take.

    Trusted Locations inAccess 2010

    Some locations (folders, drives or devices) can be nominated asTrusted

    Locations

    :Accessthen considers any database files found there to be trusted,and their automatic content is permitted to run.

    So you may find it convenient to nominate a folder or area on your computer oryour network as being Trusted byAccess. Then make sure that all yourAccessdatabase files are saved there.

    This decision may be reached in consultation with colleagues and other users ofthe database, and with your local IT support contact. Some departments have apolicy about where computer files of different kinds should be saved.

    For example, in the ITLP teaching rooms, the students files are provided for youon a drive known as H:\ , and this has been set as a Trusted Location in theinstalled copies ofAccess. IT Learning Programme computers haveSophosvirusprotection software which is kept up-to-date. If you are in an ITLP teaching room,you can rely onSophosto manage the virus scanning.

    The program files forAccessare placed in a Trusted Location, by default.

    When to Trust a Location forAccess 2010

    You should only consider doing this if you do need to use automatic content suchas macros, and if you have made very good alternative arrangements to protect

    the computer from virus attack.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    59/102

    Access: Creating queries, forms and reports

    53 IT Learning Programme

    If you are using a University or College-owned computer, take advice from yourlocal IT Support Staff before making a location Trusted. Ensure that you havereputable virus scanning software installed, and that you keep its files of knownviruses up-to-date (i.e. it checks at least weekly by connecting to the softwareprovider and downloading the latest lists). Then confirm that the software isconfigured to scan every file as it is opened.

    Only once this is in place can you rely on the virus scanning software to do thevirus scanning, and useAccessto manage your database files.

    Finding theAccessTrust Center

    You may decide to setAccessto Trust a folder or computer storage area. This isdone in the

    Trust Center

    , which is among theAccess Options

    (found on the

    Fi le menu) .

    In the left-hand column of theAccess Options

    dialog, choose theTrust Center

    category. This reveals the button on the right.

    Figure 62The Trust Center With the Trust Center Settings Button

    How to Trust a Specific Location withAccess 2010

    Trusted Locations (found in the category list on the left) shows which locationshave already been treated as trusted. Here you can or

    . Beware that if you add a location to this list, you are no longer

    protected from active content saved in that location.

    If the location where you plan to save your databases is on a network drive, checkAllow Trusted Locations on my network

    in the same dialog. You shouldconsult the IT support contact who is responsible for the network, before doingthis.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    60/102

    Access: Creating queries, forms and reports

    IT Learning Programme 54

    Figure 63The List of Trusted Locations

    You may also decide to trust subfolders within the chosen location there is acheck box for this in the Trusted Location dialog.

    Figure 64Trusting Subfolders in a Trusted Location

    Once a folder has been Trusted, save all database .accdb files there.

    Sandbox Mode

    Note that these choices makesAccessrun in a controlled and limited way, knownas sandbox mode. In sandbox mode,Accesswill run a reasonable range ofcommands and functions. Occasionally, some macros created using olderversions ofAccessmay need to be re-written using revised commands which arenow permitted.

    In sandbox mode, some commands are disabled because they are deemedpotentially unsafe, and could be used maliciously to damage your files or system.A user can only disable sandbox mode by changing keys in the Windowsregistry,which is not a task for the inexperienced to attempt (if you are not perfectlyfamiliar with working in the Windowsregistry, dont experiment: ask someonewho has experience, as there is a risk of making the computer unusable).

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    61/102

    Access: Creating queries, forms and reports

    55 IT Learning Programme

    Access 2003and Virus Security

    Security Levels Available

    Access 2003considers any .m d b

    file as a potential route for virus infection.

    By default, theAccessSecurity Level is set to M e d i u m . This means that openingalmost any .m d b

    file will trigger a series of warning dialogs, asking the user forconfirmation about opening the file and/or offering to block unsafe expressions.

    Figure 65

    Warning Dialog With Medium Security Level

    With theL o w

    setting,Accessdoes not intervene when you open a file, assumingyou have made other provision for virus scanning.

    With theH i g h

    setting, almost any .m d b

    file cannot simply be opened for usewithout intervention byAccess.

    When to Set a Lower Security Level with Access 2003

    Computers in IT Services haveSophosvirus protection software which is keptup-to-date. If you are in an ITLP teaching room, you can set Accessvirus securitylevel to Low, and rely onSophosto manage the virus scanning.

    If you are using another computer, take advice from your local IT Support Staffbefore setting a lower Security Level. Ensure that you have reputable virusscanning software installed, and that you keep its files of known viruses up-to-date (i.e. check at least weekly by connecting to the software provider anddownload the latest lists). Then confirm that the software is configured to scanevery file as it is opened.

    Only once this is in place can you rely on the virus scanning software to do the

    virus scanning, and useAccessto manage your database files.

    The Security Level Dialog

    Before attempting to open any files inAccess, you may decide to set the SecurityLevel to

    L o w

    .

    ChooseT o o l s | M a c r o | S e c u r i t y

    to display theS e c u r i t y

    dialog, then choose theS e c u r i t y L e v e l

    tab. ChooseL o w

    , then clickO K

    . You may be prompted to closeAccessand restart, to make the change effective.

    Note: do not use the menuT o o l s | S e c u r i t y

    look carefully forT o o l s | M a c r o | S e c u r i t y

    .

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    62/102

    Access: Creating queries, forms and reports

    IT Learning Programme 56

    Figure 66Setting the Security Level to Low

    Further Help with Security and Trust Center Settings

    There is a range of further settings available through the Trust Center. Read moreabout this inAccessHelp.

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    63/102

    Access: Creating queries, forms and reports

    57 IT Learning Programme

    13Appendix 2: Student Exercises

    Exercise 1

    Opening a database file

    Start Access 2010

    Open an existing database file View the list of queries

    All the files for these exercises have been provided for you on a network drive.Your area of the drive is called d r i v e H : \ This drive has been set up as an Access Trusted Location

    Task 1

    StartAccess from theS t a r t

    menu

    Step 1

    Start the computer if necessary

    Step 2

    Click on theT a s k B a r

    at the bottom of the

    screen

    In theS t a r t

    menu, explore the folders and look for theM i c r o s o f t O f f i c e

    folder

    ChooseA c c e s s

    Step 3

    If you are prompted for any user information, just clickon

    O K

    Step 4

    (On your office or home computer you are likely to start

    the program using anAccessicon on the Desktop)

    Task 2

    OpenD e p a r t m e n t

    A s s e t s . a c c d b

    It has been placed in yournetwork drive

    H : \

    (or inanother place as directed byyour teacher)

    Step 1

    ChooseF i l e | O p e n

    Step 2

    Navigate to the network drive calledd r i v e H : \

    Alternatively, navigate to a drive and folder as directedby your teacher

    All the files you need for this course will be found here

    Step 3

    Locate the file calledD e p a r t m e n t A s s e t s . a c c d b

    Open the file by selecting the filename then clicking

    Step 4

    If a security warning bar appears, stating that certaincontent in the database has been disabled, then readAppendix 1

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    64/102

    Access: Creating queries, forms and reports

    IT Learning Programme 58

    Task 3

    Use the Navigation Pane inthe database window

    Step 1

    Select next to the title on the Navigation Pane (on

    the left-hand side of the screen)

    SelectO b j e c t T y p e

    (underN a v i g a t e T o C a t e g o r y

    )

    Step 2

    Select again and chooseA l l A c c e s s O b j e c t s

    (underF i l t e r B y G r o u p

    )

    Task 4

    Look at the list of tablesand queries in theNavigation Pane

    Step 1

    Notice that the names of tables and queries that havealready been created are listed in the Navigation Pane

    Exercise 2

    Creating select queries using the wizard

    Creating a select query using the wizard

    Saving the query

    Running the query and look at the results

    Switching between Design View and Datasheet View

    Task 1

    Continue work inD e p a r t m e n t

    A s s e t s . a c c d b

    Step 1

    Ensure that the fileD e p a r t m e n t A s s e t s .a c c d b

    isopen (if necessary, open it by choosing

    F i l e | O p e n

    )

    Task 2

    Use the wizard to create aquery based on t b l A s s e t s ,including these fields:Asset Description, Make,Model and Date Acquired

    Step 1

    Click on theC r e a t e

    tab of the Ribbon

    SelectS i m p l e Q u e r y W i z a r d

    and click

    Step 2

    In the list of available tables, choose the table calledt b l A s s e t s

    Step 3

    Double-click on the fields called A s s e t D e s c r i p t i o n ,M a k e

    ,M o d e l

    andD a t e A c q u i r e d

    to place these fieldsin the right-hand list

    Step 4

    Click to move through the wizard

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    65/102

    Access: Creating queries, forms and reports

    59 IT Learning Programme

    Task 3

    Save the query

    Name itq r y A s s e t s

    Examine the results of

    q r y A s s e t s

    Step 1

    When asked by the wizard, give a suitable name for thenew query: qryAssets

    Make sureO p e n t h e q u e r y t o v i e w i n f o r m a t i o n

    isselected

    Step 2

    Click

    Step 3

    The query runs [44 records] and the results arepresented in Datasheet View

    Notice that all records are included, but only those fieldsyou requested

    Task 4

    Switch between DesignView and Datasheet View

    Close the query

    Step 1

    Use on theH o m e

    tab to switch to Design View

    Step 2

    In Design View, notice the table of assets with a list of allthe available fields, in the top pane

    In the design grid (lower part), notice the fields thathave been chosen and set out in columns

    Step 3

    Use on theH o m e

    tab or theQ u e r y T o o l s

    D e s i g n tab, to switch to Datasheet View

    Step 4

    When ready, close the query using

    (if you have made no changes to the query design, youwill not need to save on closing)

    Leave the file open, showing just the Navigation Pane

    PracticeTask 5

    Create another query basedon the tablet b l D e p a r t m e n t s

    List every department byname, along with the nameof the Head of Dept and acontact phone number

    Save the query with asuitable name (with theprefix q r y )

    Step 1

    Click on theC r e a t e

    tab of the Ribbon, select

    S i m p l e Q u e r y W i z a r d and click

    Step 2

    Select the tablet b l D e p a r t m e n t s

    Choose the fieldsD e p t N a m e

    ,D e p t H e a d

    ,C o n t a c t T e l N u m

    Step 3

    Save the query asq r y C o n t a c t i n g H e a d s o f D e p t

    Examine the resulting data

    Step 4

    Close the query

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    66/102

    Access: Creating queries, forms and reports

    IT Learning Programme 60

    Exercise 3

    Creating a query in Design View

    Starting a new query

    Adding tables in Query Design View

    Adding fields

    Running a query based on two or more tables

    Saving and closing the query

    Task 1

    Continue work inD e p a r t m e n t

    A s s e t s . a c c d b

    Step 1

    Ensure thatD e p a r t m e n t A s s e t s . a c c d b

    is open

    Close any tables or queries that may be open using

    Task 2

    Start a new query in DesignView

    Add two tablest b l A s s e t s

    and

    t b l D e p a r t m e n t s

    These tables are alreadyrelated by a join usingD e p t I D

    Step 1

    Click to display the Design View with theS h o w

    T a b l e

    dialog

    Step 2

    Chooset b l A s s e t s

    andt b l D e p a r t m e n t s

    by selecting

    the table name and clicking or double-

    clicking a table name.

    Repeat until you have both the required tables in thedesign grid behind(do not worry if you collect some extras, they can be

    deleted later)

    Step 3

    Click to use the design grid

    If an unwanted table has appeared, click it once to select

    it then press DELETEto delete

    Step 4

    Notice that the two tables are shown in the top pane,with a line joining the

    D e p t I D

    fields

    The top pane can be resized by dragging the divider

    between the two panes

    Task 3

    Choose fields and set themup in the design grid:

    Asset ID

    Description

    Step 1

    Set up a field in the first column of the design grid:

    Select the field nameA s s e t I D

    in the list fort b l A s s e t s

    Drag the field name to the top of the first empty columnin the grid

  • 8/21/2019 Course Book Access TDAC Creating Qu Fo Re10

    67/102

    Access: Creating queries, forms and reports

    61 IT Learning Programme

    Step 2

    The next fields you need areA s s e t D e s c r i p t i o n

    ,M a k e

    andN e x t M a i n t D a t e

    from thet b l A s s e t s

    Set these up in the design grid, perhaps by double-clicking a fieldname, or by clicking at the top of an

    empty column and picking a fieldname from the menuthat drops down

    Step 3

    The final field,C o n t a c t T e l N u m

    , must be taken fromthe related table

    t b l D e p a r t m e n t s

    Task 4

    Run the query

    Examine the results

    Step 1

    Click or to switch to Datasheet View

    The query is run (Accessinterrogates the data in thetables at that moment)

    Any records which appear in both tables withcorresponding

    D e p t I D

    values are presented

    Only those fields you selected in the query design arepresented

    Step 2

    The data canbe edited in the query

    For example, suppose that asset number 15, a Watkinsbar code reader, should next be serviced on 1 January2016

    Locate that record, move into theN e x t M a i n t D a t e

    field, and type the required date to change the date inthis list

    You have changed the value in the underlying table,t b l A s s e t s

    Task 5

    Close the query

    Save it, giving a suitablename

    Step 1

    Close the query by clicking , saving any changes

    when asked

    When


Recommended