Fundamentals of Database System: Learning Guide # 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 45

FTTI - Training, Teaching and Learning Material

FEDERAL TVET TEACHERS TRAINING INSTITUTE

FUNDAMENTALS OF DATABASE
SYSTEM
na
e r
.C
D
ck
tri
Pa
LEARNING GUIDE # 1

Module Title: Developing Database using SQL


Programming and applying database administration

LO 1: Introduction to Database System

Fundamental of Database System Date: October-2011 Page 1 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

INTRODUCTION Learning Guide # 1

This learning guide was developed to provide you the necessary information regarding the following
content coverage and topics –

 Database Basics
 Opening and designing DB application and principles
 Creating DB objects

This guide will also assist you to attain the learning outcome stated in the cover page. Specifically,
upon completion of this Learning Guide, you will be able to –

 Understand Database Basics


 Open and design database application incorporating basic design principles
 Create database object according to database usage, as well as user requirements
 Modify database object as required

na
Add and modify data in a table according to information requirements


Add, modify and delete records as required
e r
.C
Save and compile database objects

D
Learning Activities
ck
a tri
P
1. Read the specific objectives of this Learning Guide.
2. Read the information written in the “Information Sheets 1- 3”.
3. Accomplish the “Self-check”.
4. If you earned a satisfactory evaluation proceed to “Information Sheet 2”. However, if your rating is
unsatisfactory, see your teacher for further instructions or go back to Learning Activity # 1.
5. Submit your accomplished Self-check. This will form part of your training portfolio.
6. Read the “Operation Sheet” and perform the procedures discussed.
7. Accomplish the “Self-check” in page 13.
8. Do the “LAP test” in page 15 (if you are ready) and show your output to your teacher. Your teacher
will evaluate your output either satisfactory or unsatisfactory. If unsatisfactory, your teacher shall
advice you on additional work. But if satisfactory you can proceed to Learning Guide 2.

Fundamental of Database System Date: October-2011 Page 2 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Information Sheet 1 Database Basics

What Is a Database?
The best definitions are those that require as few words as possible. In the case of databases,
the most concise definition can be broken down to one word: collection. A database is a
collection of related data elements. The three basic elements of a database are as follows:
 Tables
 Columns
 Rows
Tables - also referred to as entities, represent the basic elements of information you are interested
in tracking. For example, a typical business services customers, fills orders, and produces
invoices. It follows, therefore, that a typical database representing a business would have
customers, orders, and invoices tables.
Columns - also referred to as fields, represent the attributes of a table. Consider the customers
table of a business. How would one describe a customer entity? Attributes such as first name,
last name, address, city, state, ZIP Code, phone number, and so on would be appropriate to
store.
n a
Rows - also referred to as records, represent the actual r
e data
data. Whereas fields describe what
C
data is stored, the rows of a table are where the actual is stored.
. the system of tables, rows, and
Modern database management systems manage D
c kthe filing cabinets of invoices in your company’s
columns. Does the word modern in the previous sentence imply that non-modern databases
i
accounts payable department. The filingtrcabinet can be thought of as a table, whereas the
exist or existed? The answer is yes. Consider

a be considered the columns. Finally, each individual


invoice can be considered a row. AlsoPconsider the old card-catalog systems libraries used to
fields of data on the typical invoice can

use. Each card in the catalog contains the same data elements: book title, author, year of
publication, publisher, and so on. It is easy to see that the entire card catalog was the table;
the elements each card contained were the columns; and each card was a row of data.

Fundamental of Database System Date: October-2011 Page 3 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Typical Database Management Systems Used

Today
Many popular database management systems (DBMSs) are in use today. Among the most
popular are these:
 Microsoft Access
 Microsoft SQL Server
 MSDE (Microsoft Data Engine)
 Oracle
 IBM DB2

Microsoft Access is one of two primary database offerings from Microsoft. Access is a
network/desktop-based database. Although feature rich, Access is limited by both the amount of
data it can store and the number of users it can service simultaneously. Currently, the
maximum size an Access database can be is 2 billion bytes (2 gigabytes). The chief benefit of
Access is that it is easy to use. For this reason, Access was chosen to be the database of
choice to illustrate the examples in the book.
na
e r
On the other end of the database scale are products such as Microsoft SQL Server, Oracle,

.C
and DB2. These types of database management systems are capable of trillions of bytes
(terabytes) of data. Furthermore, these types of systems are capable of hosting thousands of
D
users simultaneously. The world’s biggest Web sites and database applications use products
k
like these. Because this is an introductory book on the subject, products such as SQL Server
c
tri
and Oracle are beyond this book’s scope. Please see Appendix E, “Web-Based Resources,” for
information on more advanced resources.

Pa
It is important to note that although this book is using Microsoft Access to illustrate how
databases work, you as the reader are not being shortchanged with respect to features. The
focus of this book is to teach you what databases are and how to use them. At their core, all
databases operate under the same general theory. After you have mastered the
fundamentals illustrated in this book, you will find transferring that knowledge to the more
advanced platforms of SQL Server, Oracle, or DB2 relatively easy.
Up to now, the systems have been described as database management systems (DBMSs).
More accurately, they are relational database management systems. All the databases
mentioned so far are built on the relational model. Understanding what databases are has
two important steps: knowing some key database terminology and understanding the basics
of the relational database model. These steps are the focus of the next two sections.

Fundamental of Database System Date: October-2011 Page 4 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Key Database Terminology

Database
Early in this chapter, a database was described as a collection of related data ele-
ments. More precisely, a database is a collection of related data tables or entities. For
example, a typical database for an organization would consist of a customer, an
order, and order line-item tables. All these tables are related to one another in some
way. In this example, customers have orders and orders have line items. Even
though each table exists on its own, collectively the tables comprise a database.

Tables and Entities


A table represents a “thing” about an organization. Tables also are referred to as
entities. If you want to track or store information about something, chances are it
is a good candidate for being defined as a table. One of the first steps in building a
database involves defining the tables that constitute that database.

Fields, Columns, and Attributes


na
e r
Just as a database is composed of tables, tables are composed of fields. Fields

.C
are also known as columns and attributes. Depending on the text you read, one or

D
more of these terms will be used. Don’t get thrown off track by the use of multiple

k
terminologies because field, column, and attribute all mean the same thing. A
c
tri
good way to think of fields is to think of them as descriptors of tables. For example,

Pa
how would you describe a customer entity? Good examples of fields include first
name, last name, city, state, ZIP Code, phone number, and so on.

Normalization
When creating a database, defining tables and fields is not enough. The optimal
number of tables and the optimal construction of tables are determined through a
process called normalization. The process of normalization entails creating numerous
smaller tables as opposed to a smaller number of monolithic tables. One of the pri-
mary goals of normalization is to reduce data redundancy. The topic of normaliza-
tion is discussed in Chapter 4, “Database Design Continued: An Introduction to
Normalization.”

Rows and Records


Each table in a database contains zero or more rows. Rows are also referred to as
records. For example, say every customer for a company has a distinct record in the
table that holds customer data. Therefore, each order for a specific customer com-
prises one record in the table that holds order data.

Fundamental of Database System Date: October-2011 Page 5 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Primary Key

An expression that uniquely identifies a record from all other records is called a primary key.

Database-Related Career

Database Administrator
A database administrator (DBA) is often the gatekeeper of data in an organization.
Normally, all requests for data structure changes, new stored procedures, and so
on are filtered through a DBA. The DBA ensures that an organization’s databases
are properly maintained and perform optimally. Through time, as a database
matures and grows, a database’s current implementation often must be
reanalyzed. A DBA plays a central role in this process.

When a new application for an organization is being developed, the developer of


a
that application consults the DBA to learn about the technical details of a database.
n
e r
Although an applications developer might want to make a change to a database,

.C
other applications probably use the same database. It is up to the DBA to ensure
that a requested change by a specific application is compatible with other applica-
D
ck
tri
tions. If it is not, the DBA needs to be able to suggest viable alternatives.

Database Applications Programmer


P a
Perhaps you are an experienced
programmer who has not worked with data
before. With the addition of database skills to your arsenal, you will be ready to
tackle the world of developing database applications. Unlike other types of software
applications, database applications directly impact the operations of a business.

To develop a database application for a business, you must first understand the
business. This is wholly different from developing a utility that can deal with a
specific aspect of a business. Database applications tend to deal with an entire
business or an entire segment of a business. If you are experienced at developing
utility-based applications, database applications will initially pose some new
challenges. These

new challenges exist because the requirements are different. A question you might
have at this point is, “How are the requirements different?” Consider the following:
Utility-based programs that do one thing tend to be finite. How they do things today
is how they will do things tomorrow. Databases, on the other hand, grow as a busi-
Fundamental of Database System Date: October-2011 Page 6 of 45
Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
ness grows. Furthermore, as the business environment changes, the requirements
of a database application change as well. The need to track new information,
new report requests, and so on (all to one degree or another) requires changes to
the underlying database. It has been said that a database application is never
finished because a business never stops changing.

Database Analyst

Perhaps you do not develop programs. Rather, you are somebody who
understands the business and the data related to a business. A key position in
the mix is that of a database analyst. Database analysts are key players in
the design of a database. It

is important to note that the disciplines of developing applications and designing


databases differ. The first, and most important, step in developing a database appli-
cation is designing the database. Nothing else can occur until this first step is com-
plete.

na
e r
.C
D
ck
tri
Pa

Fundamental of Database System Date: October-2011 Page 7 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Information Sheet 2 Introducing MS Access Database

Database

A database can best be described as a way of storing large amounts of information. The data
can be retrieved and we can even ask questions of the data and get answers. For example: You may
want to know how many Students enrolled in every occupational level.

Ms Access is a database management tool that enables one to store relevant data.
This also has the capabilities to retrieve, sort, summarize and report results immediately
and effectively. It can combine data from various files (tables) through creating
relationships, and can make data entry more efficient and accurate through the use of
forms.

Microsoft Access (MS Access) enables one to manage all important information from a
single database file. Within the file, one can use the different objects:

 Tables - A table is a collection of data about a specific topic, such as products or suppliers.
a
Using a separate table for each topic means that you store that data only once. This results in
n

a more efficient database and fewer data-entry errors.
e r
.C
Queries - You use queries to view, change, and analyze data in different ways. You can also
use them as a source of records for forms, reports, and data access pages.

D
Forms - A form is a type of a database object that is primarily used to enter or display data in a
k
database. You can also use a form as a switchboard that opens other forms and reports in the
c
tri
database, or as a custom dialog box that accepts user input and carries out an action based

Pa
on the input.
 Reports - A report is an effective way to present your data in a printed format. Because you
have control over the size and appearance of everything on a report, you can display the
information the way you want to see it
 Modules - A module is essentially a collection of declarations, statements, and procedures
stored together as one named unit to organize your Microsoft Visual Basic code. Microsoft
Access has two types of modules: standard modules and class modules.
 Data access pages - A data access page is a special type of Web page designed for viewing
and working with data from the Internet or an intranet— data that is stored in a Microsoft
Access database or a Microsoft SQL Server database. The data access page may also include
data from other sources, such as Microsoft Excel.

In MS Access, data is stored once in one table, but can be viewed from multiple locations.
When the data is updated in a Table, Query or Form, it is automatically updated everywhere it
appears.

Establishment of Ms Access database


All Ms Access databases files are saved with extension .mdb. A database should have a
separate table for every major subject, such as Students records, Students grades, etc..

Fundamental of Database System Date: October-2011 Page 8 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Production data or Treatment information. Data should not be duplicated in multiple tables.
Microsoft Access provides three methods to create a database

 Database Wizard (though easy, the wizard offers limited options to customize the database)
 Using a template (This method works best if one can find and use a template that closely
matches the specific requirements)
 Creating a database directly (This is the most flexible method, but it requires one to define
each database element separately).

Basic Database Concept: In studying MS Access, it is but necessary to understand some basic
elements of a database before proceeding to it.

Database Elements:

 Data are raw facts. It tells the truth about something; a person, a place, an object, etc.
Example:

Name (1) “Noel” is a data. “Noel” is my name, so it tells something about a


person. “Noel” is a Name
Noel

(2) “Male” is Noel’s gender.


n a
So it tells something about “Noel”. Noel is
Gender
Male.
e r
.C
Male

D
Information is a collection of data (raw facts) which is contained in 1
file (table in Access)
c k
Example:
tr i
IDNumber LName
a
FName

PNoel
Mname Gender Bday Address

MOE-0001 Cuevas Pancho Male 11-05-1978 Aratkilo

(this is an information about a person named “Noel”)

Example of a table (file):


IDNumber LName FName Mname Gender Bday Address

MOE-0001 Cuevas Noel Pancho Male 11-05-1978 Aratkilo

MOE-0002 Panganiban Mark Perez Male 11-05-1978 Magadanga


File
MOE-0003 Cerna Patrick Santos Male 11-05-1978 Aratkilo

MOE-0004 Hipolito Valder Cruz Male 11-05-1978 Sidiskilo

MOE-0005 Ohmy Diana Antonio Female 11-05-1978 Aratkilo

Fundamental of Database System Date: October-2011 Page 9 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Naming Convention
Is manner of naming files and variables. Having a poor naming convention can only add
confusion, so it's important that you start with a good scheme, and think about what the scheme will
mean to you. Here are the three things to consider in establishing a naming convention:

1. Does my convention make sense to me?


 Is must be simple and understandable to you.
2. Will my convention make sense to other people?
 Time will come that other people will look into your database program, so they must
able to understand it.
3. Can I be consistent in implementing and enforcing my convention?
 All throughout my database work, your naming convention must not change.

General

Here are some basic simple rules when it comes to the name of any object in a database
(including the name of the database itself):
 Do not use spaces in object names. It might seem tempting and cute to have a view named
"Sales By Quarter," but this is a nightmare to deal with programmatically. Instead write it as
“SalesByQuarter” or “SalesByQtr” or “QtrlySales”
na
e r
 Avoid using reserved words. This is easier said than done, as there is a very large list of
current and future reserved words to check against. Example: do not name your file as “Date”

.C
because “Date” is a reserve word in Ms Access.
 Do not use dashes in database names. Dash “-“ was often recognized by a computer as an
D
k
operator (subtraction), so instead of naming your object as “Quarterly-Sales” better name it
c
tri
as QuarterlySales” or better use underscore instead of a dash “Quarterly_Sales”.
 Start object names with a letter. I see table named "2005_Sales" and columns and columns

Pa
named "1", "2," "3," and so on (to represent months). Ms Access might treat it as a number
and not as a filename.
 Keep names short but meaningful. This is self-explanatory and fairly logical, "SlQ" is too
short. “SalesFiguresForCompanyByFiscalQuarter" is just silly.
 Use sensible case. There is little worse than going through a database schema where all the
table names are in ALL CAPS. It’s like Ms Access is yelling at you! Likewise, trying to read a
procedure name like "getallarticlestatisticsbyweek" could drive some people to drink. I like
camel-/Pascal-casing or using underscores, leaning toward the former in most cases:
GetArticleStatsByWeek or getArticleStats_ByWeek.
 Avoid Hungarian notation. The name of the object should make it pretty obvious what type of
data it contains, and if for some reason it does not, then there is always the metadata tables
and/or the documentation you should have written when designing the system. Using
datatype-style prefixes for columns like IContactID (integer) and VEmail (varchar) not only
make the column names harder to read, they also make them less flexible.

Fundamental of Database System Date: October-2011 Page 10 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Information Sheet-3 Creating database objects


Creating DB Tables
Recently, we define it as a file but technically, it was defined as a container or a
worksheet-like container where the collection of data has been stored.

Before we proceed to creating your first table, we need to know first the basic
components of a table:
o Meta Data – Database Structure
o Field – Column – Data
o Fieldname
o Record - Row - Information

Metadata – is a “data about data” or synonymously called table structure that defines
what type of data your data is?

na
Given these data:
e r
.C
(1) “Noel” which is a firstname, we can say that it composes of texts, so we

D
define the firstname to accept text only thus it accepts the value “Noel”

ck
tri
(2) Supposed that “21” is the Age of Noel, then we will define Age as a number,

a
specifically an Integer so it will only accept a value which is an integer.
P
Thus it gave a table structure of:
Field Name Data Type
Firstname Text
Age Integer

Which only means to say that you cannot enter a number value in the Firstname field,
likewise you cannot enter a text value to the Age field. In that case, entering a number value
to a Firstname field would treat it as text. Ex: Richard23. And cannot be used for
computation.

Field – Every column in a table represents a field by which data has been stored.
Field name – This refers to the name of every field.
Records – Every row in a table represents a record, which is a collection of meaningful data.

Fundamental of Database System Date: October-2011 Page 11 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Example of a table : Table name: StudentsTable
7 columns = 7 fields

IDNumber LName FName Mname Gender Bday Address


Row
MOE-0001 Cuevas Noel Pancho Male 11-05-1978 Aratkilo
Record
MOE-0002 Panganiban Mark Perez Male 11-05-1978 Magadanga

MOE-0003 Cerna Patrick Santos Male 11-05-1978 Aratkilo

MOE-0004 Hipolito Valder Cruz Male 11-05-1978 Sidiskilo

MOE-0005 Ohmy Diana Antonio Female 11-05-1978 Aratkilo

Field names
“MOE-0001” is the data for IDNumber field. And IDNumber is a fieldname for that data.

1 Record

na
MOE-0001 Cuevas Noel Pancho Male 11-05-1978 Aratkilo

er
1 Row gives an information. It tells that Noel Pancho Cuevas is a Male whose birthday is on 11-05-

.C
1978 and who lives in Aratkilo.

D
c k
tri
Data Types

Pa

When creating a table, one will need to specify what kinds of data are to be stored in this field.

The different kinds of Ms Access 2003 data types are:

 Text: allows for the storage of any kind of data, characters, digits and special
characters. It has a defect length of 50 characters with a maximum length of 255. It is
normally used to store data such as names, addresses, or any number not used in
calculations, like telephone numbers or zip codes.
 Memo: is used for texts of more than 255 characters such as comments or
explanations. It has a maximum length of 65.536 characters. Access recommends that

Fundamental of Database System Date: October-2011 Page 12 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
to store formatted text or large documents, rather to create an OLE Object field than a
Memo field.

In Access2003 it is possible to arrange or group in a Memo field, but Access only uses
the first 255 characters when it arranges or groups in a Memo field.

 Number: for numerical data used in mathematical calculations. Within the number type
we are able to specify the size property of the field. The types Byte, Integer and Long
Integer allow the storage of numbers without decimals; the types Single, Double and
Decimal allow decimals; the type Replication ID is used for autonumerical codes in
replication databases.
 Date/Time: for the introduction of date and time from the year 100 to 9999.
 Currency: For monetary values and numerical data used in mathematical calculations
in which the data involved contains between one and four decimals. The accuracy is up
to 15 digits to the left of the decimal separator and up to 4 digits to the right of the same.

Access recommends the use of Currency type to avoid the rounding off of numbers in
calculus. A Currency field has an accuracy of up to 15 digits to the left of the decimal
separator and 4 digits to the right. A Currency field occupies 8 bytes of space on disc.


a
Autonumber: a unique sequential number (increasing one by one), or an aleatory
n
fields cannot be updated. e r
number that Access assigns every time it adds a new record to a table. Autonumber


.C
Yes/No: Yes and No values, and fields that contain one of two values (Yes/No,
True/False or Acivated/Disactivated).
D

k
OLE Object: an object such as a Microsoft Excel spreadsheet, a Microsoft Word
c
tri
document, graphics, images, sounds, or other binaries.

Pa
 Hyperlink: text or a combination of text and numbers stored as text and used as a
hyperlink address. A Hiperlink is a text or grafic that you click to go to a file, a location in
a file, a web page on the Internet, or a web page on an intranet.

Tables may be created by either:


 Table wizard
 Design view

Creating Tables using design view


Creation of a table by design view is a user customized way of making data storage tables.
Each field in the design view of a table corresponds to a column in the datasheet view of a table.

Designing a table involves:

 Entering unique names of the columns of the table in the “field name” column of the
design view. Names of fields and objects in Microsoft Access can be up to 64 characters long. They
can include any combination of letters, numbers, spaces, and special characters except a period (.),
an exclamation point (!), an accent grave (`), and brackets ([ ]). They also can't begin with leading
spaces
Fundamental of Database System Date: October-2011 Page 13 of 45
Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

 Primary Key is the unique identification of one record. It will not allow a duplication of the
Primary Key thus make it unique. Define a Primary Key field (You don't have to define a primary
key, but it's usually a good idea. If you don't define a primary key, Microsoft Access asks if you want
Access to create one for you when you save the table)

Forms
A form is a type of a database object that is primarily used to enter or display data in a
database. Most forms are bound to one or more tables and queries in the database. A form's record
source refers to the fields in the underlying tables and queries.

Forms may be created by either:


 Form wizard
 Design view

Creating Forms using a wizard


Creation of a form by using a wizard is the Ms Access pre-defined way of creating a form by
simply following the series of steps and choosing which field and format you would want for your
form.
na
Creating Forms using design view e r
.C
Creation of a form by design view is a user customized way of making data entry forms,

D
Switchboard form and even custom dialog box. Each control in the design view of a form was being
dragged from the control toolbox.
ck
Queries tri
Pa
A query is a derived item in the database meant to answer specific questions that relate to the
information in the database. It is the means to retrieve relevant information in one or more tables.
Queries are handy during data processing.

Queries may be created by either:


 Query wizard
 Design view
 SQL View

Creating Queries using a wizard


Creation of a query by using a wizard is a fastest and easy way to extract information you need
from one or more tables.

Creating Queries using design view


Creation of a query by design view is a user customized way of setting-up criteria to filter the
necessary information you need from one or more tables.

Creating Queries using SQL view


Fundamental of Database System Date: October-2011 Page 14 of 45
Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Creation of a form by SQL view is another option but not normally being use by Ms Access
programmers. It requires an understanding of the Structured Query Language statements.

Reports
Reports provide a means of organizing and summarizing data. Reports are often used to
present an overview highlighting main points and trends. A report can be a simple list, a status report
or a monthly production report.

A report is made from the data available.

Reports may be created by either:


 Report wizard
 Design view

Creating Reports using a wizard


Creation of a report by using a wizard is a fastest and easy way to create a report by following
the series of steps and choosing a pre-defined template for your report.

Creating Reports using design view


a
Creation of a report by design view is a user customized way setting-up your report so to
n
meet the users desired output and format.
e r
.C
D
Macros

ck
tri
Macros in Access can be thought of as a simplified programming language which you can use
to add functionality to your database. For example, you can attach a macro to a command button on

Pa
a form so that the macro runs whenever the button is clicked. Macros contain actions that perform
tasks, such as opening a report, running a query, or closing the database. Most database operations
that you do manually can be automated by using macros, so they can be great time-saving devices.

A macro is essentially a list of actions that you apply to objects to respond to events. Each
action carries out one task. You create your actions in the order you want them to execute. In
addition, you specify the arguments of the actions, giving the program additional information as
needed.

You can set conditions for each action in a macro to determine whether it runs or not. Run a
macro by applying it to the event property of an object. Once the specified event occurs the macro will
run by running the all the specified actions. Actions that have conditions applied to them may or may
not run depending on whether or not they passed the conditional tests.

Once you've created your macros you'll see them listed in the Macros tab in the Database
window. This way you can attach any macro to any event property in your database.

Fundamental of Database System Date: October-2011 Page 15 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Modules

Modules, like macros, are objects you can use to add functionality to your database. Whereas
you create macros in Access by choosing from a list of macro actions, you write modules in the Visual
Basic for Applications (VBA) programming language. A module is a collection of declarations,
statements, and procedures that are stored together as a unit. A module can be either a class module
or a standard module. Class modules are attached to forms or reports, and usually contain
procedures that are specific to the form or report they're attached to. Standard modules contain
general procedures that aren't associated with any other object. Standard modules are listed
under Modules in the Navigation Pane, whereas class modules are not.

Now that you know how to put together a program, you are ready to give it a try. To create a
VBA procedure, you follow many of the same steps you follow when you created macros. The
general steps in VBA programming are as follows:

1. Identify the task you want to accomplish.


2. Plan the steps needed to accomplish that task.
3. Create the programming code necessary to implement the steps.
4. Test the program.
na
5. Refine the program.
e r
C
6. Repeat steps 4 and 5 until the program works correctly.
.
D
You create VBA programming code by using the VBA Editor, which is described in the
following section.
c k
tr i
a
Data Access Pages

P
A data access page is a special type of Web page designed for viewing and working with data
from the Internet or an intranet— data that is stored in a Microsoft Access database or a Microsoft
SQL Server database. The data access page may also include data from other sources, such as
Microsoft Excel.

Using a data access page is similar to using a form: You can view, enter, edit, and delete data
in a database. However, you can also use a page outside a Microsoft Access database, so users can
update or view data over the Internet or an intranet.

Parts of a data access page

 The body - The body is the basic design surface of a data access page. On a page
that supports data entry, you can use it to display informational text, controls bound to
data, and sections.
 Sections - You use sections to display text, data from a database, and toolbars.

Fundamental of Database System Date: October-2011 Page 16 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Two types of sections are typically used on pages that support data entry: group header
and record navigation sections. A page can also have footer and caption sections.

 Group header and footer Used to display data and calculate values.
 Record navigation Used to display the record navigation control for the group level.
A record navigation section for a group appears after the group header section. You
can't place bound controls in a record navigation section.
 Caption Used to display captions for text boxes and other controls. It appears
immediately before the group header. You can't place bound controls in a caption
section.

Each group level in a data access page has a record source. The name of the record source is
displayed on the section bar for each section used for a group level.

Designing different types of data access pages

You design data access pages in Design view in Microsoft Access. The page is a separate file
that is stored outside Access; however, when you create the file, Access automatically adds a

a
shortcut to the file in the Database window. Designing a data access page is similar to designing
n
e r
forms and reports— you use a field list, the toolbox, controls, and so on. However, there are some
significant differences in the way that you design and interact with data access pages as opposed to

.C
forms and reports. How you design the page depends on what it will be used for:

D
k
 Interactive reporting. This type of data access page is often used to consolidate and group
c
tri
information that is stored in the database, and then publish summaries of the data. For
example, a page might publish the sales performance for each region in which you do

Pa
business. Using expand indicators, you can go from a general summary of the information,
such as a list of all the regions and their combined sales total, to specific details on individual
sales within each region. The data access page might provide toolbar buttons for sorting and
filtering the data, as well as for adding, editing, and deleting the data in some or all group
levels.

 Data analysis. This type of data access page may include a PivotTable list, similar to a
Microsoft Excel PivotTable report, that lets you reorganize the data to analyze it in different
ways. The page might contain a chart that you can use to analyze trends, detect patterns, and
compare data in your database. Or it might contain a spreadsheet, in which you can enter and
edit data and use formulas to calculate as you do in Excel.

Fundamental of Database System Date: October-2011 Page 17 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Using data access pages in Internet Explorer

A data access page is connected directly to a database. When users display the data access
page in Internet Explorer, they are viewing their own copy of the page. That means any filtering,
sorting, and other changes they make to the way the data is displayed— including changes they
make within a PivotTable list or spreadsheet— affect only their copy of the data access page.
However, changes that they make to the data itself— such as modifying values, and adding or
deleting data— are stored in the underlying database, and therefore are available to everyone
viewing the data access page.

Note To view and work with the data access page on the Internet or an intranet, users need
Microsoft Internet Explorer 5.01 with Service Pack 2 (SP2) or later.

Using data access pages in Microsoft Access

You can also work with a data access page in Page view in Access. Data access pages can
supplement the forms and reports that you use in your database application. When deciding whether
to design a data access page, form, or report, consider the tasks that you want to perform.

na
e r
.C
D
ck
tri
Pa

Fundamental of Database System Date: October-2011 Page 18 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Information Sheet 4 MS Access 2007

Microsoft Office Access 2007 is part of the Microsoft Office Professional suite which also includes the
industry standard spreadsheet and word-processing software, Excel and Word. Like this other
software in the Office Suite, Access was designed to be used by ordinary people who are not
necessarily IT professionals. Despite being easy to for all of us to learn, it is still a powerful
information management tool. Once you master the basics of database design, you can then move
onto more advanced areas if you wish. For most people, however, just learning the basics is all that is
needed for their requirements.

Learn Access 2007

Although Access 2007 is a powerful database, it can be easily learnt by non-professionals. Access
can be tackled at various levels of proficiency. To begin with you just need to know the simple basics
which can be picked up very quickly, and then build on your knowledge from there.

Before starting the main part of the tutorial, we are just going to familiarize ourselves with the new
look Access 2007 User Interface - or Access Screen.
na
The Access Screen e r
.C
D
The Access 2007 Screen is very different to that in previous versions. The menus have been

k
replaced by the Access 2007 Ribbon; there is the MICROSOFT OFFICE BUTTON instead of the old
c
tri
file menu; and the old database window has been replaced by the Access 2007 NAVIGATION PANE.
There is also a GETTING STARTED screen to create or open a database file when Access is

Pa
launched.

Fundamental of Database System Date: October-2011 Page 19 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Access Ribbon

The ACCESS RIBBON works somewhat differently to the old Access Menus. There is a row of ribbon
tabs with headings such as HOME, CREATE, EXTERNAL DATA, and DATABASE TOOLS. Clicking
on each tab presents you with its own individual ribbon with its own particular icons. Each icon on a
ribbon is contained within a group of icons that perform similar tasks. So, for example, the Create tab
has groups for TABLES, FORMS, REPORTS and OTHER

Microsoft Office Button

The MICROSOFT OFFICE BUTTON is in the top left corner of the Access screen. It replaces the old
Access file menu. So to perform functions such as saving, opening, new file creation, and printing etc,

a
you need to click this button. To the right of this button is the Quick Access Toolbar intended to

r n
provide you with quick access to some of the more common commands used in Access 2007. There
e
are three default icons on this toolbar - save, undo and redo. You can also customise this toolbar to

.C
add additional commands as required.

D
k
Access Navigation Pane
c
tri
Pa

The Access NAVIGATION PANE replaces the old database window. It is here where you will see the
icons for all the tables, forms, queries and reports that you create. When you want to open one of
your database "objects", you just click on one of these icons, and the required object will open in the
main Access window.

Fundamental of Database System Date: October-2011 Page 20 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Operation Sheet 1 Creating Access 2007 Database

Create Access 2007 Database


The first step in creating an Access 2007 database, is to create a blank database file. This is done
from the Getting Started Screen when you launch Access. The file is saved onto one of your PCs
folders (which you specify). The procedure for doing this is outlined below.

Step 1: Launch Access

na
e r
.C
D
ck
tri
Pa

To begin, launch Access by clicking on the desktop icon, or choose Access from the start menu.
This brings up the GETTING STARTED WITH MICROSOFT OFFICE ACCESS screen.

Step 2. Select Blank Database Template

Towards the top left of the screen you will see a "Blank Database" icon. Click this icon to bring up
the Blank Database side bar on the right hand side of the screen. This is where you will enter
details about the database file that you are about to create.

Fundamental of Database System Date: October-2011 Page 21 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Step 3. Enter filename for your Access 2007 database

Begin by entering the name that you want to call the database in the filename textbox.

Step 4. Browse and select folder

Next click the folder icon and browse for a folder to put your database. Once selected you should
see the file path below the textbox.

Step 5. Click Create


na
e r
All you need to do now is click the "Create" command button below, and your database file saves

.C
to the location that you specified, and opens for you to work on.

D
ck
tri
Pa

Fundamental of Database System Date: October-2011 Page 22 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Operation Sheet 2 Creating Access Tables

Access 2007 Tables


How Access stores data in Tables

Like all other databases, Access 2007 stores data in tables. They look a lot like the cells of a
spreadsheet with columns and rows. Each horizontal column represents a table record, and each
vertical column represents a table field. See Table example below:

A simple Table

ID Number FirstName Surname Age


1 John Jones 35

na
2 Tracey Smith 25
3 Anne McNeil
er 30

.C
D
In the example Table above, there are four fields containing information about an individuals ID

k
number, first name, surname and age. Below the field headings there are 3 records containing
c
tri
information or data for each individual. As such, a database table is a list with each column containing

Pa
the same specific sort of information. Each row of information is an individual record that might relate
to a particular person, a business, or a product etc.

When planning a database table, most database designers will decide which column headings or
fields they are going to use. This is the basis of the table structure. The actual data is added later and
is not a part of the design process.

Create Access Table


Step 1. Open database file

If you created a blank Access database in the previous tutorial exercise, you are now ready to create
a new table. Begin by opening your existing database file if it is not already open. Do this by clicking
on the Access desktop icon to bring up the getting started screen again. You should see the file name
that you just created towards the top of the right hand side bar (If you cant see it, click the folder icon
to browse for the file). Click on the file name to bring up your blank database.

If, at this stage, you get a security warning underneath the ribbon, click where it says options, select
the "enable this content" radio button (in the pop-up window), and then click ok.

Your blank database file should now be fully open.

Fundamental of Database System Date: October-2011 Page 23 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Step 2. Create Access Table

Select the CREATE tab on the Access ribbon. Next select the TABLE DESIGN icon from the TABLES
group. This creates a new table.

na
e r
.C
D
ck
tri
Step 3. Create fields in DESIGN VIEW
Pa
This brings up the TABLE DESIGN GRID where you enter each field name and its data type. The first
field we are going to create is the ID field which is going to contain a unique reference number for
each record. Enter the name "ID" into the first column of the first row in the grid. Because we want
Access to automatically generate a unique reference number, select AUTONUMBER from the drop
down list in the data type column. You can also enter a description for each field, but this is not
essential.

On the next row the field is going to be called FIRSTNAME and the data type is going to be TEXT. On
the third row the field name is SURNAME with the data type again being TEXT. And finally, the last
field name is AGE and the data type here is going to be NUMBER.

Before you save the table you will need to choose the Primary Key, which in this case is ID. To do
this, select the ID row by clicking on it, and then simply click the primary key symbol on the Ribbon.

Fundamental of Database System Date: October-2011 Page 24 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
The table design grid should now look like this:

You can now save the table by clicking the save icon on the top left of the screen above the Access
Ribbon. To view your table select DATASHEET VIEW from the VIEWS group under the DESIGN
TAB. This brings up the datasheet view of the table that you have just created. You should see your
field headings running across the top of the table.

na
e r
.C
D
Step 4. Data entry in DATASHEET VIEW
ck
tri
Pa
Although entering data onto the datasheet table is not a part of the design process, the table now
exists as a database object, and you can test it by entering some information into the cells.

Select the first cell in the FIRSTNAME column and enter the name JOHN. For SURNAME enter
JONES, and for AGE enter 35.

NB just ignore the column underneath the heading ADD NEW FIELD. We created all the fields we
needed in design view.

You have now entered the first record in the table - record 1 for John Jones aged 35. You can now
press the return key and the record will save automatically. You are now ready to enter the second
record on the next row - TRACEY SMITH 25. Press return and then fill in the data for the last record
we are going to do for now - ANNE McNEIL 30

Your datasheet table should now look like this:

Fundamental of Database System Date: October-2011 Page 25 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Step 5. Populate the Table

Once you have an Access Table populated with data, you have the option to work with it right away.
Fill all entries to Populated the Table.

Your datasheet table should now look like this:

na
e r
.C
D
ck
tri
Pa

Fundamental of Database System Date: October-2011 Page 26 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Operation Sheet 3 Working with Access Tables

Working with Access Tables


Once you have an Access Table populated with data, you have the option to work with it right
away. Indeed, some people may not go on to create forms, queries, and reports once they
have created their first table. With a single table you can, for example, store, edit, filter,
search, and calculate a set of database records. Now that you have created your first table
and stored a number of records, we will take a look how you go about working with tables.
Step 1. Editing Data
Editing data in an Access table is a relatively simple task. Just click the cell containing the data you
wish to change. Delete or type over the old information and enter new data as required. As you do so
you will notice a pencil symbol appear on the far left of the table on the row you are editing. This
indicates that you are in the process of editing a record and the changes have yet to be saved to the
database table. This symbol will remain while you update any other field in the same row. Once you
move out of the row, the changes will be saved automatically and the pencil will disappear. The thing

a
to remember is that when you edit data in a field, the whole record will be saved once you have
n
finished.
e r
.C
D
ck
tri
Pa

A table record in the process of being edited. Notice the pencil symbol on the left of the table. The cell
being edited is highlighted in orange. Once the new data has been entered and the row is moved out
of, this record will be saved.

Step 2. Filtering Data

The Access Filter is a way of reducing the number of records in a list which do not match a given
criteria. For example, you might want to view all the records for people with the surname 'Smith'. In
this case Smith is the criteria to match. All other records which have records that are not Smith will be
filtered out of the list.

There are a number of ways to use this feature. The way that I have found most effective is to use
the Filter By Form method.

Fundamental of Database System Date: October-2011 Page 27 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Filter By Form

If you look at the Sort and Filter group on the Home tab of the Access Ribbon, you will see a large
filter icon and three smaller icons entitledSelection, Advanced, and Toggle Filter. You need to click
the Advanced icon and select Filter By Form from the drop down list. Access will then open up a
blank datasheet with empty cells underneath your column headings. Click on the empty cell in the
Surname column, and start entering the surname Smith. As you do so, Access suggests surnames
from your list based on the letters that you have typed so far. So once you get to Sm..., Access
completes the rest of the name for you.

The next thing that you need to do is click the Toggle Filter icon on the Ribbon to apply the filter.

Result: a new filtered list is displayed containing all three records from your original table with the
surname 'Smith'.

na
e r
.C
D
ck
tri
Pa
Step 3. Sorting Data

The Sort feature of Access 2007 allows you to reorder a list of data in your table. This can be done
alphabetically or numerically, in ascending or descending order. It is a useful feature when you want
to sort your records into, say, surname order, or maybe in age order, for example.

To sort your records into surname order, click any cell in the surname column of your table. This tells
Access that your records are going to be sorted by this particular field. Next, look for the AZ Icon in
the Sort & Filter group of the Home Ribbon. To sort in ascending order, click the AZ Icon, or to sort
in descending order, click the ZA Icon below. To remove the sort and get your original list back in its
original order, click the Clear All Sorts Icon, which is the lowest Icon of the three.

Fundamental of Database System Date: October-2011 Page 28 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

na
Sorted into alphabetical order by the surname field.
e r
Step 4. Searching Data .C
D
The new search feature in Access 2007 allows you to enter a search term into a small text box at the

ck
tri
bottom of the screen. As you type each letter, the first segment of data matching your search term is
highlighted in the table. If there are a number of records containing your search term, you can click

Pa
the filter button adjacent to the search box to produce a filtered list matching your search criteria.

Access search result - highlighted segment of data matching text entered into the Access Search
Box.

Fundamental of Database System Date: October-2011 Page 29 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Step 4. Calculating Data

The Totals feature of Access 2007 allows calculations to be performed directly on a database table.
At its simplest, the totals feature can be used to count the number of records, or add a column of
numbers in a table. It can also be used to calculate Average, Maximum/Minimumvalues, Standard
Deviation and Variance.

To use this feature, open your table and click the Totals icon which is located in the Records group of
the Home Ribbon. This produces an extra row at the bottom of the table with the word Total in the left
hand column.

To perform a calculation on your table, select which column you want to process, and click the cell for
that column on the new Total row. When the arrow tag appears, click it to produce a drop down list of
functions. We are going to find out the average age in our table, so we shall select the Average
function from this list. The result of our calculation is then displayed in that cell (ie the Age column of
the Total row). If we add an additional record to our table, the totals row will recalculate the result
automatically to take account of the new data. You then have the option to save the table with the
new totals row and any calculation it is set to perform.

na
e r
.C
D
ck
tri
Pa

Access Totals - calculation of average age in list.

Fundamental of Database System Date: October-2011 Page 30 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Operation Sheet 4 Working with Access Forms

Access FORMS are user friendly

In the previous exercise, you created an Access Table and entered three records. However, to get
the most out of Access it makes sense to create a data entry FORM. By doing so you are making
your database more user friendly. It is easier and quicker to enter data onto a form than it is into a
table, not least because you have more control over the layout and labelling of your form. In this
exercise we will learn how to create a FORM that uses your newly created table as the DATA
SOURCE.

Create Access form using form wizard

There are a number of ways to create an Access form. In this exercise we are going to use the
ACCESS FORM WIZARD.

Step 1. Select form wizard

na
r
Open your database if it is not already open. Click the CREATE tab on the ACCESS RIBBON and
then select MORE FORMS from the forms group.
e
.C
D
ck
tri
Pa

A drop down list of form types appears. You need to select FORM WIZARD from this list.

Step 2. Select table and fields

The Form wizard then opens as the pop up window below.

Fundamental of Database System Date: October-2011 Page 31 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

On the first page of the form wizard we select which table we are going to use as the DATA
SOURCE. Since there is only one table in this database so far, it should already be selected for us in
the TABLES/QUERIES combo box.

na
e r
Underneath there is a list of the four fields in your table. You could select each field individually by
highlighting the field name and clicking the single arrow >. We can, however, select all four just by

.C
clicking the double arrow >>. Once they have been transfered into the right hand box they are

D
selected. We can now click NEXT to go to page 2 of the form wizard.

ck
tri
Step 3. Form Layout

Pa

Fundamental of Database System Date: October-2011 Page 32 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

This is where we choose the FORM LAYOUT. We are going to leave this on the default setting of
COLUMNAR. Click NEXT again to move onto page three of the form wizard.

Step 4. Form Style

na
e r
.C
D
k
Here we select a style that from the list box. Preview a style by clicking on its name. This step just
c
tri
determines how the form looks aesthetically. Once you have selected a style to your taste, click

Pa
NEXT again.

Step 5. Form Title

Fundamental of Database System Date: October-2011 Page 33 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
This is the last stage of the wizard. Here we are going to choose the name for our form - lets say
FORM1. We are going to leave the radio button selected for OPEN THE FORM TO ENTER OR
VIEW INFORMATION

All we need to do now is click FINISH and our form should like something like this:

Step 6. Navigate Records via Access Form

As you can see, the form opens with the first record in your original table displayed. You can navigate

na
through each record using the NAVIGATION BUTTON at the bottom left of the form window.

e r
. C
D on the navigation control. To move to the last
ck To
To move to the next record click the right arrow button

i
record click the >| button on the navigation control. move backwards through the recordset use the
left arrow buttons. You could edit any recordrfrom
For now, though, just try navigating througha t three records without changing any data.
the
the form, which will update the data in your table.

P
Step 7. Create New Record via Access Form

Now that you know how to move through the recordset, lets finish off by adding two more records. To
do this click the star button on the right of the navigation control. This should bring up a blank record.
Add JOE for firstname, BROWN for surname, and 39 for age. Click the star again to bring up a new
blank record, and enter SUE MOORE 33. When you have finished click x on the form window to
close.

Fundamental of Database System Date: October-2011 Page 34 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Creating an Access Form from scratch


Step 1: Begin by clicking the Form Design Icon on the Create Ribbon. This opens a blank new form
in Design View.

Step 2: Before we start creating text boxes and other form controls, we are going to bind the form to
an Access Table that has already been created. This is so Access knows where your forms' data is

na
going to come from. We do this by setting the Record Source property. If the property window is not

e r
already open, click the property sheet icon in the Tools group of the Design Ribbon.

.C
D
Step 3: Select the Data Tab of the property sheet. This will display a grid of properties relating to your

k
form's data. It is the Record Source property that we are currently interested in. Click the arrow to
c
tri
display a drop down list of potential database tables and queries that we can use. In this example we

Pa
are going to use the table called tblAccounts, which we will select by clicking.

Fundamental of Database System Date: October-2011 Page 35 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Step 4: We are now in a position to begin adding form Controls such as Text Boxes and Labels.
These are located in the Controls group on the Design Ribbon. We shall now click on the text box
icon and then move then cursor to the area of the form where we would like it to go. Then simply right
click the mouse over this point. This will place the text box control on our form.

Step 5. We shall now set the Control Source property of the text box. This determines which field
from the form's Record Source will be bound to the control. Do this by clicking the arrow to display a
drop down list of field names from the table which we earlier selected as our record source. We shall
choose the Description field. Like in stage 3, simply click the field name in the list to select.

na
e r
.C
D
ck
tri
Pa

Step 6. You can now give your control a meaningful name. This is now displayed anywhere on the
form itself, but it will be the name that you use to reference it later on in the design process. Do this
by clicking the Other tab of the property sheet. The Name property should be at the top of the grid.
Access gives it a default name such as Text1. You can simply type the name Description over this on
the grid.

Fundamental of Database System Date: October-2011 Page 36 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

na
e r
.C
Step 7: We shall now change the Caption property of the label on the left of the text box. Unlike

D
the Name property which we set in the previous stage, theCaption is displayed on the form to provide
k
information to the user. In this case, it is going to tell the user that the information to enter in the text
c
tri
box is going to be "Description". Do this be selecting the label on the design grid by right clicking so

Pa
that it goes orange. Next click the Format Tab on the property sheet and type in "Description" on the
property grid. Alternatively you can click the label on the design grid to select, and then click inside
the label to overwrite the old label caption directly.

You can now repeat this stage, adding as many text box controls as you need.

Fundamental of Database System Date: October-2011 Page 37 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Step 8: We will now finish off the form by entering a title. Do this by clicking on the Label control on
the Controls group of the Design Ribbon. Then choose a position at the top of the grid, and click to
add the label control to our form. We can now add our title text the same way as we entered the
caption in the previous stage. Once we have entered the title caption, we can now increase the font
size and make the text bold. Do this by right clicking the label to select, and entering a new Font
Size of 24, and clicking Bold in the Font group of the Home Ribbon. You will also need to resize the
label by double clicking the the notch on the labels border.

na
e r
.C
D
ck
tri
Pa

Fundamental of Database System Date: October-2011 Page 38 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Operation Sheet 5 Creating QUERY

In this exercises we are going to create an Access 2007 QUERY, which will process the data below
which you have entered into your table.

ID Number FirstName Surname Age


1 John Jones 35
2 Tracey Smith 25
3 Anne McNeil 30
4 Joe Brown 39
5 Sue Moore 33

What we want Access to do is extract all the records in the above table where the persons age is
greater than or equal to 35. Access Queries can do far more than this, of course, but this simple task
should serve as a useful learning exercise.

na
Step 1: Open the Query Design Grid
e r
.C
The first stage is to select the CREATE TAB and then go to the OTHER group on the far right of the
D
ribbon. Then click on the QUERY DESIGN ICON to bring up the query design grid.

ck
tri
Pa

Step2: Select Table for Query

The next stage is to select which table you are going to use in this query. When the query design grid
opened, the SHOW TABLE pop up window should also have opened. If necessary you can open this
window manually by clicking the SHOW TABLE icon in the QUERY SET UP group on the Access
Ribbon.

Fundamental of Database System Date: October-2011 Page 39 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

So far there is only one table in your database - TABLE1. This should be highlighted when the
window opens, but if not, just click on it once. Next click ADD. When you close the pop-up window by
clicking x,you should see a box labelled TABLE1 above the query design grid.

na
Step 3: Select fields from Table
r
In the table1 box, you will see a list of its field names. Weeare going to use all the fields in this query,
so select each one individually by double clicking on their
. C names. You will now see the field names at
the top of each column in the Query Design Grid.
D
c k
tr i
Pa

Fundamental of Database System Date: October-2011 Page 40 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material
Step 4: Enter query criteria

As you may remember, the purpose of our query is to extract records where the persons name is
greater than or equal to 35. To do this we enter the criteria into the appropriate cell of the query
design grid. In this case you need to go to the AGE column of the CRITERIA row, and enter the
formula >=35.

Step 5: Save and Run Query

Click the save icon above the Access Ribbon. When prompted for the query name, just use the
default QUERY1. To run your query, click the RUN icon in the RESULTS GROUP of the Access
Ribbon. You should now be presented with a datasheet displaying your query results - JOHN JONES
35 and JOE BROWN 39.
na
e r
.C
D
ck
tri
Pa

Fundamental of Database System Date: October-2011 Page 41 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Operation Sheet 5 Creating Reports in MS Access

Access Reports Present Data


Access REPORTS are a way of displaying and printing information from your database. Developers
often use Reports to display the results of a Query, which is what we are going to do next.

Like other Access database objects, there a number of ways to create an Access REPORT. We are
going use the REPORT WIZARD. Our task is to display the results of QUERY1 which we created in
the previous tutorial exercise.

Step 1. Open Report Wizard

Begin by selecting the CREATE TAB on the Access Ribbon. Then click REPORT WIZARD from the
REPORTS group to open the pop up window.
na
e r
.C
D
ck
tri
Pa
Step 2. Select Report Data Source and Fields

The first page of the Report Wizard is almost identical to that of the Form Wizard. On this page we
will select QUERY1 as the DATA SOURCE for the Report. This is done by selecting the query from
the list in the TABLES/QUERIES combo box. Then select all fields from QUERY1 by clicking the
double arrow to the right of the text box labelled AVAILABLE FIELDS. The field names will now
appear in the SELECTED FIELDS text box on the right. Click next to go to the second page of the
wizard.

Fundamental of Database System Date: October-2011 Page 42 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Step 3. Report Grouping Levels

na
Page two of the wizard is where you can add grouping levels if required. So we could, for example,
e r
group each person in our report with others of the same age. We dont need to do this for this

.C
particular example, but it is certainly a useful feature that we might want to learn more about
later. But for now, just click next.
D
ck
tri
Step 4. Record Sort Order

Pa
Page three of the wizard is where you determine what order the records are displayed in your
report. So for example you might want to display records in ascending order of age. For this
example, however, we are going to put your records into alphabetical order for SURNAME and
FIRSTNAME. Begin by clicking the top drop down box and selecting SURNAME, and in the box 2
below select FIRSTNAME. This means that records are sorted alphabetically by surname, and if
two surnames are the same, the FIRSTNAME is used to determine which record comes first etc.

Click Next

Fundamental of Database System Date: October-2011 Page 43 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Step 5. Report Lay Out

a
This page of the Wizard is where you set the lay out for your report. There are various lay out
n
r
options, but in our case we shall keep to the default setting of TABULAR.
e
Click next.
.C
D
Step 6. Style
ck
tri
Pa
For style, select Access 2007 from the list and click next.

Fundamental of Database System Date: October-2011 Page 44 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA
FTTI - Training, Teaching and Learning Material

Step 7. Name of Report

Name your report REPORT1 and then click FINISH.

Your access report will now be displayed on the screen, and should look something like this:

Step 8. Save the Report na


e r
.C
D
ck
tri
Pa

Fundamental of Database System Date: October-2011 Page 45 of 45


Federal TVET Teacher Training Institute Author: PATRICK D. CERNA

You might also like