+ All Categories
Home > Documents > Introduction to Ms Access 2003

Introduction to Ms Access 2003

Date post: 07-Apr-2018
Category:
Upload: vmsumalatha2002
View: 215 times
Download: 0 times
Share this document with a friend

of 47

Transcript
  • 8/3/2019 Introduction to Ms Access 2003

    1/47

    INTRODUCTION TO MS ACCESS 2003

    Contents

    1 Introduction 1

    2 Some Theory 1

    2.1 What is a Database? 1

    2.2 Where does Microsoft Access 2003 fit in? 2

    2.3 Steps in Designing and Building a Database 2

    3 Case Study 2

    3.1 About the Educational Institutions 3

    3.2 About the orders 3

    3.3 Analysis 3Doc 5.131 Ver 2 Introduction to Access 2003 3.4 Data Types

    4 Creating a database 5

    5 Working with tables 7

    5.1 Creating Tables 7

    5.2 Entering Data into a table 8

    5.3 Sorting Data 9

  • 8/3/2019 Introduction to Ms Access 2003

    2/47

    6 Queries 11

    6.1 What are Queries? 11

    6.2 Query Wizard 11

    6.3 Adding criteria to a query 12

    6.4 Joining tables in a query 12

    6.5 Calculated criteria 14

    6.6 More practice at working with queries 14

    7 Forms 15

    7.1 What are forms? 15

    7.2 Create a form with Form Wizard 16

    7.3 Entering Data with a form 16

    7.4 Modify the form design 16

    7.5 Create an object on a form 18

    7.6 More practice at working with forms 19

    8 Reports 19

    8.1 Modifying a report 20

    8.2 More practice at working with reports 21

    8.3 Mail Merge 21

    9 Relationships 22

  • 8/3/2019 Introduction to Ms Access 2003

    3/47

    9.2 Types of relationships 23

    9.3 A sample database 23

    9.4 Finding out More about Database Design 24

  • 8/3/2019 Introduction to Ms Access 2003

    4/47

    1 Introduction

    The aims of this training material are:

    To introduce basic techniques for creating a database using the

    Microsoft Access 2003 relational database management system

    (RDBMS). In this introductory material we will not cover the more

    advanced features ofMicrosoft Access 2003 such as macros and modules.

    These topics are necessary for the development of full-blown applications

    To demonstrate the need for requirements analysis before attempting

    a database design. Before you create a document with a word-processor,

    you need to do some planning of the content and appearance. For a

    simple document you may begin typing straight away. However, adatabase needs much more planning before you even think of using a

    RDBMS such as Microsoft Access 2003

    To build a simple database. You will start by learning about the topics

    needed to build a single table database, that is the simplest type of

    database, such as a list of names and addresses. Topics include what is a

    database, steps in designing and building a database, Tables, Forms and

    Reports and Queries

    To become familiar with using some ofWizards that are provided with

    Microsoft Access 2003

    To introduce terminology commonly used in database design and in

    the Windows 2000 environment. In order to understand the on-line help

    d th f th di d t b f ili ith th

  • 8/3/2019 Introduction to Ms Access 2003

    5/47

    2 Some Theory

    2.1 What is a Database?

    A database is a simplystructuredcollection of data, with the emphasis very

    much onstructured. Everyone encounters databases in their daily lives, even

    if they are not in electronic form. Telephone books, diaries, and mailing

    order catalogues are all instances of databases.

    Computerised databases are created, stored, manipulated and maintainedusingDatabase Management Systems (DBMS); DBMS are the programs or

    groups of programs through which we gain access to databases. In the

    personal computer world, DBMSs are often referred to as database packages

    or database applications.

    Depending on the way data is modelled, we have relational, network,

    hierarchical, and object-orienteddata models. The data model defines how

    real-world data is represented in the database. DBMSs are typically tied to

    one type of data model.

  • 8/3/2019 Introduction to Ms Access 2003

    6/47

    Microsoft Access 2003 is based on the relational model and is therefore a

    relational DBMS, or RDBMS.

    Relational databases are built up ofTables. The column headers in the tableare calledfields. The rows of data in the table are called records. RDBMSs

    are extremely fussy and insist that each recordis uniquely identified by one

    or morefields. We will see when we design tables how a unique identifier or

    key is used.

    2.2 Where does Microsoft Access 2003 fit in?

    You should consider building your database with Microsoft Access 2003 if

    your data structures can be represented by the relationalmodel. This is

    true of most business applications, and the sample databases provided

    with Microsoft Access 2003 demonstrate this. Microsoft Access 2003 can

    be used for quite large, complex database applications. However, even if

    your data structures are quite simple, and could be easily held in a card

    index, you may want to consider using Microsoft Access 2003, as it works

    well with Word. If you frequently need to send out mail shots then

    Microsoft Access 2003 is particularly suitable for use with the mail merge

    tool in Word

    There are more specialist databases available for bibliographic databases

    (ITS supply Endnote in workstation rooms). Contact ITS Reception/Help

    Desk on our website for information on available documentation

    If the data contained in your tables is mostly numeric data, then you are

    probably better off using a spreadsheet program such as Excel.

    Spreadsheet programs are specifically designed to handle numeric data

    2.3 Steps in Designing and Building a Database

  • 8/3/2019 Introduction to Ms Access 2003

    7/47

    Decide what real world things ( entities) you need to store information

    about. For example Employees, Products, Customers, Orders. Entities are

    represented by tables in the database

    Decide what facts ( attributes) you need to know about each entity, e.g. an

    Employees date of birth, salary. Attributes are represented by fields in

    the tables

    Decide on the relationshipsbetween the entities in the database; i.e. what

    attributes do they have in common. Relationships are formed in the

    database between entities that have common attributes. They have

    common fields in the related tables. For example, customerFred Bloggs

    can place an order for product eggs. So the Orders table has

    relationships with Customers table and Products table

    Decide what information you need to extract from your data. This will

    allow you to design the queries

    Design Forms that will allow users to enter data values for running queries

    or entering data

    Design Reports that will print information extracted from the database

    To illustrate what this means, we will examine a sample case study, and then

    build a very simple database to provide the required functions.

    3 Case Study

    The database that you are going to build is to hold the records of theSoftware Made Simple company. The company sells training material to

  • 8/3/2019 Introduction to Ms Access 2003

    8/47

    institutions. They need to keep details of the Institutions that they deal with

    and the orders that they place.

    3.1 About the Educational Institutions

    The details SMS need to know about each institution are:

    A unique identifier for each institution

    The number of students in the institution this helps to know the potential

    size of the market for their products

    The educational sector whether pricing is covered by special deals for

    certain types of institutions

    The name, address, phone, fax, email of the institution. For simplicity we

    will include only the institution name in our sample database

    The company deals only with a named contact at each institution. SMS

    needs to know who this person is

    3.2 About the orders

    The training material is provided either as printed books or on a CD-ROM.

    For each order SMS need to know

    The institution code. This links each order to the institution that placed it

    The order number. This uniquely identifies the order

    If the order is for books then they need to know the number. Since all the

  • 8/3/2019 Introduction to Ms Access 2003

    9/47

    The value of the order

    The order type i.e. whether it is for books or CD-ROM

    CD Renewal date. Sites buy an annual licence to make copies of the

    material on the CD-ROM so SMS need to know the renewal date

    3.3 Analysis

    The important thing at this stage is not your knowledge of computers, but an

    understanding of the problem. As this is not a course in Systems Analysis,

    the analysis has been done for you, so that you can practise using Microsoft

    Access 2003 straight away. TheEntities about which to keep information are

    Institutions and Orders, so we will start with two tables in our database.

    Since the institution is represented by the site contact, the table representing

    the institution will be called Contacts. We will call our other table Orders.Tables are structured into fields (columns) and records (rows). All records

    must have the same fields, though as we shall see in this example there may

    be instances where a field is redundant in some records but not in others.

    The Attributes (i.e. the details that we need to know) of a Contactare the

    institution code, the number of students, the name of the institution, the

    educational sector and the contacts forename and surname. Since the

    contact is representing an institution the institution code must be unique

    The attributes of an Orderare the order number, which must be unique,

    the institution code, the value of the order and the order type (CD-ROM

    or books). For book orders we need the number of books and for CD-

    ROM orders we

  • 8/3/2019 Introduction to Ms Access 2003

    10/47

    need the licence renewal date. For CD-ROM orders the number of books

    field is redundant. For book orders the renewal date is redundant.

    However, we must include the field for all records to maintain a

    consistent structure

    In order to identify the Relationshipbetween an institution (represented in

    the database by its Contact) and its orders we will give each institution a

    unique identifier in the Contacts table. We will include this identifier as a

    field in the Orders table. It is good practice, when designing a database,

    to use unique identifiers. In our example each contact is uniquely

    identified by the institution code. There are good reasons for this. The

    contact might change in the future. In order to link an institution to the

    orders it has placed we need to maintain consistency. Even if the contact

    name changes the institution code remains the same so we still know

    where to send the order. In addition, there may be several institutions

    with contacts named (say) John Smith

    3.4 Data Types

    (SMS 2.10)

    Having decided what tables we need, and what fields we need in the tables

    we need to decide what type of data we are going to put in each field. Is it,

    for example, a number, a date, or some text. When you are building a

    database from scratch you will usually make use of the Microsoft Office

    2003 autonumber to allocate a unique identifier for each record. Note

    however that if you are building a database to contain data that already exists

    with a unique identifier (e.g. Student number, National Insurance number,

    bank account number), you should use your existing unique number in

    preference to an autonumber.

    The field that uniquely identifies a record in a database is called the

  • 8/3/2019 Introduction to Ms Access 2003

    11/47

    Table 1 Fields for Contacts table Field Name Data Type

    Surname Text

    Forename Text

    Edu Sector Text

    Institution Text

    Num Students Number

    Institution Code Autonumber

  • 8/3/2019 Introduction to Ms Access 2003

    12/47

    Table 2 Fields for Orders Table Field Name Data Type

    Institution Code Number

    Order Num Autonumber

    Num Books Number

    Value NumberOrder Type Text

    CD Renewal Date: dd/mm/yy

    4 Creating a database

    Microsoft Access 2003 also provides wizards. Wizards are software tools that help

    you with a programmes features. However, in this document you will learn how to

    create your database from scratch, so that you are better able to match the database

    to the requirement. SMS guide 2.4 describes how to create a database using a

    wizard.

    Exercise 1 Starting Microsoft Access 2003 on ITS workstations

    At the Windows log in prompt, type your username in the Username box. Press

    the TAB key to move to the Password box, and type your password. Then

    press the ENTER key or click on OK Wait a few minutes while Windows 2000

    checks your username and password, and allocates your network resources

    Click on the Startbutton on the taskbarat the bottom of the screen. The Start

    Menu will appear

    Click on Programs on the Start Menu

  • 8/3/2019 Introduction to Ms Access 2003

    13/47

    Click on Microsoft Office on theProgram menu and then on Microsoft Access

    2003

    Exercise 2 Create a new database

    On the menus, choose File New

    Select Blank Database from the task pane on the right-hand side of the screen

    In theFile New Database dialogue box make sure that you have selected the My

    Documents folder on yourN: drive, and replace db1.mdb in the Filenamebox

    with sms contacts.

    Click on Create

    You have now created a file that will become the database. Unlike programs such

    as WordandExcel,Access saves the objects that you create and the data that you

    enter automatically to this file.

    When you create a new database it will look something like Figure 4-1.

    On the left of the window are buttons representing various database objects.

    Select the class of object that you wish to work on by clicking on the button.Tables are the foundation of the database; just as you start building a house by

    laying the foundations you start building a database by creating the tables. The

    first time that you use the database the table button is selected by default

  • 8/3/2019 Introduction to Ms Access 2003

    14/47

    On the right of the window you will see a list of tasks that you can perform on

    the selected class of object. If a wizard matches your requirements, then it is the

    simplest way to create a table (see SMS section 2.7). In this document we will

    learn how to create a table from scratch

    Figure 4-1 New database

    5 Working with tables

    5.1 Creating Tables

  • 8/3/2019 Introduction to Ms Access 2003

    15/47

    In the analysis section we looked at the tables needed, what fields should appear in

    the tables and what data types those fields should have. It is important to realise

    that we are talking about the data structures in the database. We are not talking

    about the data values which will ultimately be contained in the tables. For example

    the field forename is a part of the contacts table data structure. When we enter

    names (Tony, Eleanor, Nurinder) we are entering data values into the table.

    Exercise 3 Create a table

    Select Create table in Design view and click on the Newbutton

    In the New Table window select Design View and click on OK

    Enter the field names and data types that we discussed in the analysis section.

    (Surname, Forename, Edu Sector, Institution, Num Students, Institution Code)

    By default the field type is text. Use the TAB key to move between fields

    To change the data type display the data type menu. To do this:

    eitherclick in the data type field, then click on the drop down arrow that

    appears in the right of the

    orpress the ALT+DOWN ARROW keys together

    Choose the data type that you require. Your table structure should look like

    Figure 5-1

    Figure 5-1 Contacts Table in Design View

  • 8/3/2019 Introduction to Ms Access 2003

    16/47

    Choose Save As from the File menu and save your table as Contacts

    When Microsoft Access 2003 asks if you want to create a primary key now click

    on Yes

    5.2 Entering Data into a table

    Exercise 4 Entering data into a table

    Click on the datasheet viewbutton (see right). It is situated at the right hand end

    of the tool bar. You do not need to enter the Institution Code as it is an

    autonumber Access will do it for you. Note that if you make a mistake and

    delete a record Microsoft Access 2003 will not reuse a number; your numbers

    may therefore be different to those given in the examples. You should use your

    numbers inyourdatabase.

    Enter the data values shown in Table 3. You can use the TAB key to movebetween fields. Use the BACKSPACE or DELETE key to correct mistakes

    Table 3 Data values for Foren Edu Institu Num Institu

  • 8/3/2019 Introduction to Ms Access 2003

    17/47

    Contacts table Surname ame Sector tion Studen

    ts

    tion

    Code

    Taylor Tony School Callow

    Grammar

    500 1

    Blake Victor Univer

    sity

    Lermo

    uth

    120000 2

    Ambrose Guy Univer

    sity

    Mawle

    y

    8000 3

    Patterson Peter Colleg

    e

    North

    Cambe

    r

    8000 4

    Keenan Penny School Abdul

    Kamee

    r

    600 5

    Wright Eleano

    r

    Colleg

    e

    Callow 1000 6

    Waverley David Univer

    sity

    Newbri

    dge

    160000 7

    James Philip School Robert

    s High

    700 8

    Su Chi Hong School Southfi

    elds

    Tech

    700 9

    Patel Nurind

    er

    Univer

    sity

    Westch

    ester

    150000 10

    Clarke Lenny School Wyre

    High

    800 11

    Patrick Roger School Westm

    outh

    800 12

  • 8/3/2019 Introduction to Ms Access 2003

    18/47

    Parkinson Helen School Schofi

    eld

    Tech

    900 13

    Mathews Karen University

    Waverley

    9000 14

    Quentin Terry Colleg

    e

    Eastma

    n

    7000 15

    Walters Trudy Univer

    sity

    Aberda

    re

    100000 16

    Peabody Ruth Univer

    sity

    Bradbu

    ry City

    9000 17

    Young Alice Univer

    sity

    Folkla

    nds

    140000 18

    Lomar Shiree

    n

    Univer

    sity

    Persho

    re

    12000 19

    Booth Charlie Colleg

    e

    Truma

    n

    5000 20

    Cazinaska Dimen Colleg

    e

    Trowb

    ury

    5000 21

    5.3 Sorting Data

    (SMS Section 4.0)

    Each record in the contacts table is stored in the order in which it was entered. You

    will often want to view it in a different order for example sorted by date or

    alphabetic order.

  • 8/3/2019 Introduction to Ms Access 2003

    19/47

    Exercise 5 Sorting Data

    Click in the Surname field to select it

    Click on the Sort Ascending button (see right) to sort the records in ascending

    alphabetic order. What is the seventh surname in the list?

    5.4 More Practice on working with tables

    Now practice using the techniques that you have just learnt to create another table,

    enter and sort data.

    Exercise 6 Create Orders Table

    Make the sms contacts database window the active window (either by clicking

    on it or choosing it from the Window menu)

    Using the techniques that you learnt in Exercise 3 create a table called Orders,

    with the field names and data types shown on the right

    Note that the date for renewing CD licences (CD Renewal) needs to be expressed

    in Short Date format. To change the format select the CD Renewal field, click

    in the Format field in the Field Properties section of the table design view

  • 8/3/2019 Introduction to Ms Access 2003

    20/47

    window. Click on the down arrow to display the format menu and choose the

    option that you want see Figure 5-2

    Save the table as Orders

    Figure 5-2 Field Property

    Exercise 7 Entering & Sorting Orders Data

    Using the technique that you learnt in Exercise 4 enter the data shown in Table 4

    into the Orders table. As Order Num is an autonumber there is no need to

    enter it yourself

    Table 4 Orders Data

    Institution Code

    Order

    Num

    Num

    Books

    Value Order

    Type

    CD

    Renew

    al

    8 1 200 1,190.

    00

    Books

  • 8/3/2019 Introduction to Ms Access 2003

    21/47

    14 2 540 3,213.

    00

    Books

    11 3 0 170.0

    0

    CD 31/12/0

    117 4 0 720.0

    0

    CD 05/05/0

    2

    20 5 0 720.0

    0

    CD 01/08/0

    2

    16 6 0 720.0

    0

    CD 04/08/0

    2

    13 7 0 170.0

    0

    CD 01/07/0

    2

    4 8 3200 19,04

    0.00

    Books

    5 9 100 595.0

    0

    Books

    1 10 53 315.0

    0

    Books

    2 11 0 720.00

    CD

    9 12 0 170.0

    0

    CD 04/03/0

    2

    10 13 0 720.0

    0

    CD 05/06/0

    2

    15 14 0 720.0

    0

    CD 20/10/0

    2

    12 15 20 119.0

    0

    Books

    7 16 0 720.0

    0

    CD 19/11/0

    1

    3 17 340 2,023. Books

  • 8/3/2019 Introduction to Ms Access 2003

    22/47

    00

    6 18 0 720.0

    0

    CD 25/01/0

    2

    21 19 0 720.0

    0

    CD 27/02/0

    2

    19 20 0 720.0

    0

    CD 18/12/0

    1

    18 21 44 261.0

    0

    Books

    12 22 50 298.0

    0

    Books

    3 23 400 2,380

    .00

    Books

    1 24 352 5,095

    .00

    Books

    8 25 32 190.0

    0

    Books

    12 26 70 416.0

    0

    Books

    Sort the table in ascending order on the Value field. What is the fourth value?

    6 Queries

  • 8/3/2019 Introduction to Ms Access 2003

    23/47

    6.1 What are Queries?

    You use queries to view, change, and analyze data in different ways. You can also

    use them as the source of records for forms and reports. The examples that we will

    build today is called a Select Query because we are selecting fields and records

    from the database.

    The steps in designing a query are:

    Decide on the type of query to design

    Add the tables that contain the fields to be displayed

    Add the fields which contain the data to be displayed

    Add any criteria you want to use. Criteria are instructions that you use to tell

    Access which records to display. When you come to design your own

    databases you should use the on-line help to search for examples ofcriteria

    expressions

    6.2 Query Wizard

    A query creates a dynamic subset (called a dynaset in database terminology) ofthose records in the underlying tables that satisfy the criteria specified in the

    query.

  • 8/3/2019 Introduction to Ms Access 2003

    24/47

    The next task is to create a query that finds all the records in the Contacts table.

    We will then see how to apply criteria to the query to return dynasets.

    Exercise 8 Create a simple select query

    In the database window select the Queriesbutton

    Double click on Create query by using wizard. The query wizard starts

    In the box labelled Tables/Queries select Table: Contacts from the drop down

    menu

    Click on >> to move allthe fields from the Available fields list to the Selected

    fields list

    Click on Next >

    In the next step select Open the query to view information (it should be

    selected by default) and click on Finish. Your query will return data and should

    display the data that you entered into the contacts table

    In the above example you moved all the available fields from one table. However,

    if you only need some fields

    Click on the field name in the

    Available fields list

    Click on > to move it to the Selected fields list

    Repeat this for all the fields that you need

  • 8/3/2019 Introduction to Ms Access 2003

    25/47

    If you need fields from another table or query select the other table or query from

    the Table/Query list

    If you change your mind about a selected field, select it in the Selected fields list

    and click on < to return it to the Available fields list.

    6.3 Adding criteria to a query

    You enter criteria in the criteria cell, that is the intersection of a row and a column.

    You may use a text value as a selection criteria; e.g. a persons surname or you

    may use mathematical values e.g. >=10

    Exercise 9 Select a contact

    In the query window switch to design viewby clicking on the Design viewbutton

    on the tool bar In the Criteria Row and Surname column type Parkinson.

    Your query should look like Figure 6-1

    Figure 6-1 Select Query example

  • 8/3/2019 Introduction to Ms Access 2003

    26/47

    Run the query by clicking on the Run button on the toolbar at the top of the screen

    (see right)

    Close your query by clicking on the close button (x) at the top right corner of the

    query window. (When asked if you want to save changes click on No.)

    6.4 Joining tables in a query

    You can also create a query that uses more than one table. For example, if we want

    to find all the orders made for institutions with more than 10,000 students we need

    to know the institution and number of students, which is held in the Contacts

    table, and the order numbers which are held in the Orders table. The institution

    code in

  • 8/3/2019 Introduction to Ms Access 2003

    27/47

    both tables allows us to link together the information. In database terminology it

    identifies a relationshipbetween the tables.

    When working with several tables, designers often use the Table.Field notation to

    clarify the specification. In the following exercise you will see this notation used;

    for example Contacts.Institution Code refers to the Institution code field in the

    Contacts table.

    Exercise 10 Joining tables in a query

    In the database window double clickon Create Query in Design view

    In the Show Table window click on contacts, then click on add to add the table

    to the query.

    Do the same fororders, then click on Close

    A query design window appears. Add the following fields by double clicking on

    the field name

    Contacts.Institution Code (i.e the institution code field from the contacts

    table)

    Contacts.Institution

    Contacts.num students

    Orders.Institution code

    Orders.Order num

    In the Criteria row, Num students column type >10000

  • 8/3/2019 Introduction to Ms Access 2003

    28/47

    Save as Large Institutions Query. Your query in design view should look like

    Figure 6-2

    Figure 6-2 Joining tables query

    Run the query. The results should look like Figure 6-3

    Figure 6-3 Results of Large Institution Query

  • 8/3/2019 Introduction to Ms Access 2003

    29/47

    Close Large Institutions Query

    If you do not want to display a field then clear the check box in theShowrow in

    the designer view.

    The records are sorted in ascending order by Institution code. In design view

    you can choose to sort on a different field by clicking in the Sort row of the

    column for your chosen field. You can select a sort order from the drop down

    menu.

    6.5 Calculated criteria

    You can group records based on fields that have the same value. You can calculate

    mathematical functions such as totals or averages. To do this you need to add the

    Totals row to the design view window.

    Exercise 11 Calculate the sector Average

    In the database window open a new query in design view

  • 8/3/2019 Introduction to Ms Access 2003

    30/47

    Using the techniques that you learnt in Exercise 10, add the contacts table, then

    add the fields Edu Sector and Num Students

    Click on the Totalsbutton on the toolbar (hint: it looks like a ). A totals row

    appears in the QBE grid

    In the Edu Sector field choose Group By from the totals menu

    In the num students field choose Avg (average) from the totals menu

    Run the query

    Save the query as Sector Average Query

    7 Forms

    7.1 What are forms?

    Forms provide an alternative and more accessible way of presenting and entering

    data than using a datasheet. The form permits the viewing of a single record at a

    time, and the design of the form may be easily customised to suit your

    requirements.

    Other advantages of forms are:

    they are familiar, as they are similar to a paper form

    it is often quicker to enter data using a form rather than the datasheet

  • 8/3/2019 Introduction to Ms Access 2003

    31/47

    data can be presented in a more attractive and accessible manner and can include

    graphs and pictures

    Each form is based on either a table or a query. In order to create a form that uses

    fields from more than one table you will need to create a query that contains all the

    necessary fields. The quickest way to create a form is by using the form wizard.

    7.2 Create a form with Form Wizard

    We will create a columnar form based on the contacts table, using the Form

    Wizard. The contacts table is the record source of the form, i.e. the source from

    which it retrieves data.

    Exercise 12 Create a form with Form Wizard

    In the database window select the Formsbutton

    Double click on Create form by using wizard. The form wizard starts

    In the box labelled Tables/Queries select Table: Contacts from the drop down

    menu

    Click on >> to move allthe fields from the Available fields list to the Selected

    fields list then click on Next >

    Select columnar layout and click on Next >

    Select standard style and click on Next >

  • 8/3/2019 Introduction to Ms Access 2003

    32/47

    Type Contacts Form in the title box, select Modify the form design and click

    on Finish

    7.3 Entering Data with a form

    To enter data using the form you simply type the data into the boxes, using the

    mouse or clicking on the TAB key to move to the next field.

    7.4 Modify the form design

    In Access jargon everything is called an object. Tables, Forms, Queries and

    Reports are all Objects. The labels, boxes, text boxes and other items on a form or

    report are a special type of object known as a control. Before you can do anything

    with an object you have toselectit, by clicking on it when you are in design view.

    On Forms and Reports you can make Multiple Selections; that is you can selectseveral objects at once.

    All objects haveproperties that you can edit.

    If you cannot see the properties window then click the rightmouse button and

    choose Properties from the menu that drops down. The properties window is

    displayed (see right). In the title bar is the name of the object that you have

    selected (theform in this example).

  • 8/3/2019 Introduction to Ms Access 2003

    33/47

    To change a property click in the relevant field. Some properties will display a

    drop down arrow, allowing you to choose a value from a menu. For other

    properties you will need to type a value.

    To select several objects located next to each other, hold down the SHIFT key

    and click on each object in turn.

    To select several objects that are not next to each other hold down the CTRL key

    and click on each object in turn

    You may have used a similar technique when selecting files with Windows

    Explorer. Windows applications use consistent techniques for performing

    tasks. The techniques explained above work equally well for selecting emails

    in Outlook and selecting files in Windows Explorer

    All Windows applications require you to select an object before you try to do

    anything with it. For example, you must select a block of text in Word before

    you can copy it

  • 8/3/2019 Introduction to Ms Access 2003

    34/47

    Exercise 13 Modify a form

    The form should now be in design view. If it is not then switch to design viewby

    clicking on the Design viewbutton on the tool bar

    Click on the label Surname. Hold down the SHIFT key and click on the other

    labels (forename, edu sector, Institution, Num Students and Institution

    code). Your form should now look like Figure 7-1

    Figure 7-1 Selected objects on a form

    Still holding down the SHIFT key display the properties window (as explained

    above). The properties window should have the title Multiple Selection

    If the Format tab is not on top click on it to select it

  • 8/3/2019 Introduction to Ms Access 2003

    35/47

    Click to select Fore Color (scroll down the window if you cannot see it). A

    continuation button (), appears (see right). Click on it to see the choice of

    colours

    Select a suitable shade of red and click on OK

    Click on the form and you will see that the text labels are now red

    Select Save from the file menu to save your design

    7.5 Create an object on a form

    You can add objects such as labels to your forms. These objects are known as

    controls.

    You create controlsby clicking once on an object from the Toolbox (see right) and

    clicking and dragging the mouse pointer to draw it on the form. When you point

    (do notclick) to a control the name of the control appears as a small yellow label.

    If you cannot see the Toolbox then, in form design view, select toolbox from theview menu.

    We will start by creating a simple label on the form. However, some controls are

    more sophisticated. For example you can use a combo box to display a menu of

  • 8/3/2019 Introduction to Ms Access 2003

    36/47

    items that the user is allowed to select (see SMS section 5.3). You can use a

    calculation as the control source from which a text box takes its data.

    Exercise 14 Add a control to a form

    Make sure that you have the Contacts form open in design view. Position the

    mouse pointer between the headersection and the detailsections on the form

    (see Figure 7-2). The pointer will change to a bar with a double arrow across it

    Figure 7-2 Header/Detail sections

  • 8/3/2019 Introduction to Ms Access 2003

    37/47

    Drag the detail section down so that a gap of about 1cm appears between the form

    header and detail sections.

    Click on the label tool on the tool box to select it. To find the tool move the

    cursor along the tool barwithout clickingon the buttons. You will see a label

    appear to indicate the function of the button. This is calledHover Help

    Click in the space that you created between the header and detail sections, then

    drag to draw a box. In the box type Software made Simple Contacts

  • 8/3/2019 Introduction to Ms Access 2003

    38/47

    In the Format section of the properties box set the Text alignproperty to center,

    font size to 10 and font weight to semi bold. Set the fore colour to a colour of

    your choice

    Save your changes

    8 Reports

    Reporting is the way in which you choose to present the contents of your database

    as printed pages.

    Reports enable you to select which fields will be printed out and what data

    should be included. Reports can also summarise data in various ways

    Microsoft Access 2003 gives you the opportunity to design the layout of a

    particular report, including the position of headings, labels and the data itself

    along with graphics such as pictures and logos

    Reports can take their data from tables or existing queries or you may create a

    query especially for the report

    In order to create a report that uses fields from more than one table a query

    should be created which contains all the necessary fields. For example you

  • 8/3/2019 Introduction to Ms Access 2003

    39/47

    could create a report based on the Large Institutions Query that you created,

    which uses data from the contacts and orders tables

    The best way to create a report is by using the report wizard

    We will use the Contacts table to create a report grouping the fields by Edu

    Sector. We will sort on Institution and Surname fields in ascending order, and

    display the report in landscape format.

    Exercise 15 Create a report

    In the database window select the Reportsbutton

    Double click on Create report by using wizard. The report wizard starts

    In the box labelled Tables/Queries select Table: Contacts from the drop down

    menu

    Click on >> to move allthe fields from the Available fields list to the Selected

    fields list

    Click on Next >

    In the grouping window select Edu sector from the list of fields & click on >

    Your window should now look like Figure 8-1

    Click on Next >

  • 8/3/2019 Introduction to Ms Access 2003

    40/47

    Figure 8-1 Group by Edu Sector

    In the sorting window select Institution in the box labelled 1 and Surname in the

    box labelled 2. The sort buttons are already set for ascending order. Click on

    next >

    In the layout window select Stepped layout and landscape orientation. Click on

    next >

    Select a style that you like and click on Next >

    Type the title Contacts Report in the title box and click on Finish

  • 8/3/2019 Introduction to Ms Access 2003

    41/47

    Your report will now appear as aPrint Preview. You can print it by either clicking

    on the printbutton on the toolbar or by selecting print from the file menu.

    8.1 Modifying a report

    (SMS Section 6.2)

    A basic report is divided into three sections Page

    Header

    Contain data that will appear at the

    top or bottom of each page of the

    report. You might use this to

    include information about the

    source of the report, the date it was

    completed or the page number.

    Page Footer

    Detail The most important section since

    any fields added here display the

    actual information from the

    database for every record in the

    table or query on which the report

    is based.

    8.3 Mail Merge

    Although Microsoft Access 2003 is good for producing tabulated reports, there will

    be occasions when you need something more flexible than Access. The Microsoft

    Office suite of programs allows you to combine the data management features of

  • 8/3/2019 Introduction to Ms Access 2003

    42/47

    Access with the formatting and layout features ofWord, using a feature called Mail

    Merge.

    Exercise 16 Mail Merge with Word

    Make sure that the Contacts table is notopen

    In the database window select the Contacts table by clicking on it once do not

    open it

    Move the cursor along the tool barwithout clickingon the buttons. You will see a

    label appear to indicate the function of the button. This is calledHover Help

    When you have located the Office Linksbutton click on it and select Merge it

    with Microsoft Office Word

    In the Mail Word Wizard dialogue box select Create New Document and

    click on OK

    When Microsoft Wordstarts type Dear followed by a space

    You should be able to see the mail merge toolbar if not, choose View

    Toolbars Mail Merge

    Click on the button Insert Merge Fields. You will see a list of fields from your

    contacts table. Double-click on Forename (or click once and click insert). You

    will see a place marker in your document.

  • 8/3/2019 Introduction to Ms Access 2003

    43/47

    Type a space, then insert the merge field surname

    Type the some text in your letter so that it appears as shown below: Dear

    Forename Surname

    Please find enclosed an evaluation copy of the latest version of Software

    Made Simple material on CD-ROM. We can also supply this material in

    book form.

    Yours Sincerely

    Simon Simple

    Use Hover Help to locate the button Merge to New Document. When you click

    on this button Wordwill generate a set of form letters, based on yourAccess

    data source. The names of the people in the contacts table have been substituted

    for the place markers in yourmasterdocument. This document may be printed

    9 Relationships

    9.1 Why use Relationships

    In the first session we discussed the tables needed for the database and introducedthe idea ofrelationshipsbetween the entities (mapped to tables) in the database.

  • 8/3/2019 Introduction to Ms Access 2003

    44/47

    We have seen that by using the Institution Code as the primary key in the

    Contacts table and as aforeign key in the Orders table, it is possible tojoin data

    from the two tables into a dynasetusing the Large Institutions Query.

    In the small sample data base that youve worked with you may wonder why we

    did not combine all the data in one table SMS Orders (Table 5)

    Table 5 SMS Orders Field Name Data Type

    Order Num Autonumber

    Institution Code Number

    Surname Text

    Forename T Edu Sector Text

    Institution T

    Num Students Number

    Num Books Number

    Value Number

    Order Type Text

    CD Renewal Date:

    dd/mm/yy

    Value NumberOrder Type Text

    CD Renewal Date:

    dd/mm/yy

    Consider what would happen if an institution placed many orders. Institutions thatorder books sell them on to the students and re-order each academic year. For each

    order the SMS Orders table would have repeated fields for all the fields shown

    above in italics.

  • 8/3/2019 Introduction to Ms Access 2003

    45/47

  • 8/3/2019 Introduction to Ms Access 2003

    46/47

    matching records in Table A. This type of relationship is only possible by

    defining a third table (called a junction table) whose primary key consists of

    two fields the foreign keys from both Tables A and B. A many-to-many

    relationship is really two one-to-many relationships with a third table.

    A sample database

    We will now use a Microsoft Access 2003 database template to build a rather more

    complicated database than the simple example that we have looked at so far.

    Exercise 17 Create a database using a wizard

    OpenAccess

    Close any databases that you have open and select New from the File menu

    In the task pane, click on under Templates

    Click on the Databases tab

    From the database templates select Event Management and click on OK

    In the File New Database dialogue box click on create

    As the database wizard takes you through the steps click on next > until it is

    finished

  • 8/3/2019 Introduction to Ms Access 2003

    47/47

    After a few minutes Microsoft Access 2003 will create a database. From the Tools

    menu select relationships. You will see that the relationships are rather

    complicated! Let us look in more detail at the relationship between the Events,

    Attendees and Registration tables.

    Events.eventid is related to Registration.eventidby a one to many relationship

    (shown as 1 to ).

    Attendees.attendeeid is related to Registration.attendeeidby a one to many

    relationship (shown as 1 to ).

    The Registration table is the junction table used to model the many to many

    relationshipbetween Events and Attendees. Attendees can attend one or more

    events, events are attended by one or more attendees. Registration relates an

    employee to an event


Recommended