1. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 1
INTRODUCTION
Database
Database is a collection of information related to a particular subject or purpose, such as
tracking customer orders or maintaining a music collection. Using Microsoft Access, you
can manage all your information from a single database file. However, whenever you create an
Access database you need to create different types of files (database objects) where each are
dedicated for some purpose. Access 2003 program is organized into the following parts: Tables,
Queries, Forms, Reports, Pages, Macros, Modules, Groups and Favorites. However, this
manual discusses the first four basic parts. The remaining parts are advanced and require the user
to know programming languages.
Tables: are used to store data. Create one table for each type of information you track.
Queries: are used to find and retrieve the data that meets criteria or conditions you specify.
Forms: are used to easily view, enter and change data directly in a table.
Reports: are used to analyze or summarize your data or present it in a certain way in print.
For example, you might print one report that groups data and calculates totals, and another
report with different data formatted for printing mailing labels.
Pages: is a feature designed to help you easily use the Internet for data access and
management. You need a web browser, such as Microsoft Internet Explorer and modem.
You can create data access pages which are web pages that you can use to add, edit, view or
manipulate current data in a Microsoft Access database or a Microsoft SQL Server
database.
Designing a Database
Before you use Microsoft Access to actually build the tables, forms and other database objects
that will make up your database, it is important to take time to design your database. A good
database design is the keystone to creating a database that does what you want it to do effectively,
accurately, and efficiently.
Basic steps in designing a database
1. Determine the purpose of your database and how it is used
The purpose of the database file, for a hypothetical supermarket, can be to keep track of
transactions made by customers; to produce a bill for each customer when the customer’s credit
level reach some amount, and to produce a monthly report for managers on sales made. Deciding
the purpose of a database will help you which data you want Microsoft Access to store in order to
perform the expected output.
2. Determine the tables you need in the database
Once you have a clear purpose for your database, and got some hint about the information that
should be stored, you can divide the information into separate subjects; such as Customers- to
hold information about all customers and Charges- to hold information about each transactions
made by customers.
3. Determine the fields you need in the tables
Decide individual elements of data (fields) that should be stored in each table. To determine the
fields in a table; decide what you need to know about the people, thing or events recorded in the
table. For instance, information that is needed to be known about customers is: their Name (First
name, Second name), Address (such as Telephone, P.O.Box, and City), and facts needed to be
known about Transactions are: person who made the transaction, item number, unit price,
quantity and date of transaction. When sketching out the fields for each table, keep these tips in
mind:
Relate each field directly to the subject of the table
A
2. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 2
Don’t include derived or calculated data (data that is the result of an expression)
Include all the information you need
Store information in its smallest logical parts (for example, First Name and Last Name
rather than Name)
4. Identify fields with unique values
In order for Microsoft Access to connect information stored in separate tables (for example, to
connect a customer with all the customer’s orders), each table in your database must include a
field or set of fields that uniquely identify each individual record in the table. Such a field or set
of fields is called a Primary Key.
5. Determine the relationship between tables
Now that you have divided your information into tables and identified primary key fields, you
need a way to tell Microsoft Access how to bring information back together again in meaningful
ways. To do this, you define relationships between tables.
6. Refine your design
After you have designed the tables, fields and relationships you need, it’s time to study the design
and detect any flaws that might remain. It is easier to change your database design now, rather
than after you have filled the tables with data. Use Microsoft Access to create your tables, specify
relationships between the tables and enter a few records of data in each table. See if you can use
the database to get the answers you want. Create rough drafts of your forms and reports and see if
they show the data you expect. Look for unnecessary duplication of data and eliminate them.
7. Enter data and create other database objects
When you are satisfied that the table structures meet the design goals described here, then it’s
time to go ahead and add all your existing data to the tables. You can then create any queries,
forms and reports that you may want from these data.
8. Use Microsoft Access analysis tools
Microsoft Access includes two tools that can help you to refine your database design. The Table
Analyzer Wizard can analyze the design of one table at a time, can propose new table structures
and relationships if appropriate and can restructure a table into new related tables if that makes
sense. The Performance Analyzer can analyze your entire database and make recommendations
and suggestions for improving it. The wizard can also implement these recommendations and
suggestions.
Creating a Database
Microsoft Access provides two
methods to create a database. You
can create a Blank Database and
then add the tables, forms, reports
and other objects later. This is the
most flexible method, but it
requires you to define each
database element separately. Or
you can use a Database Wizard to
create in one operation the
required tables, forms and reports
for the type of database you
choose. This is the easiest way to
start creating your database. Either
way, you can modify and extend
your database at any time after it
has been created.
3. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 3
When you create a file using Ms Access 2003, it is slightly different from Word or Excel 2003.
Before creating the database, you have to give first file name and specify the location.
4. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 4
TABLES
t the heart of all Access operations there is data stored in tables. A table is a container for
data about a particular subject, such as about customers. Each record in a table contains
information about a person, a thing or an event, such as about a specific customer. The records in
a table are made up of fields, such as Name, Father Name and Phone.
You can have many tables in your database, each storing information about different subjects (or
things). Each table can contain data of many types, including text, numbers, dates and pictures.
The table object is the only part of the Access system that actually stores data. All other objects,
such as queries, forms and reports depend on data stored in table(s). Hence, before creating other
objects for your database, such as queries or forms, you must create tables. Tables organize data
in columns (called fields) and rows (called records).
Create table on design view:
When you first create a table, it is an empty container for data. You design the table to contain
specific type of data you want to store such as names and addresses. After you save your table, it
is ready for you to enter data into it. For each field to be included in a table you are expected to
specify field name and data type. You can also specify field description, which is optional.
These three characteristics of a field are described below
1. Field Name- is the name by which the field is identified. Examples of field names are Name,
Age, Salary etc. Each field in the same table must have a unique name. Field
Name can be up to 64 characters long and can contain any type of characters
except periods (.), exclamation marks (!), and brackets ([]). Also, Field Names
must not start with space.
2. Data Type- defines the type of data to be stored in the field being defined. Access supports
ten data types:
Text ...........................are used for storing text information (alphabets) up to 255 characters in
length. Use this data type for short text entries such as names and
addresses.
Memo........................are used for storing large blocks of text up to 64,000 characters (about 20
pages) in length. Use this type of field when you want to enter large blocks
of text, such as remarks or notes.
Number.....................are used for numeric data that can be used in mathematical calculations
Date/Time.................to store dates and times.
Auto Number ...........use this type when you want the value of a field to be automatically
incremented (increased by one starting from 1) whenever you add a new
record to a table.
Currency...................used for those fields with monetary values. Calculations will be accurate up
to 15 digits to the left side of the decimal point and four digits to the right
of the decimal, such as Salary.
Yes/No.......................this data type is used for recording logical values: yes/no, true/false, or
on/off.
OLE Object..............this data type enables you to store documents, spreadsheets, graphics,
drawings, sounds and other information created in Microsoft Windows
applications, such as Microsoft Excel.
Hyperlink .................use this type of field to store hyperlinks (locators to other data).
Lookup wizard.........use this field to create a field that allows you to choose a value from
another table or from a list of values using combo box.
A
5. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 5
3. Description- is an optional descriptive text that you can add for a field you create. This
description will appear down at the bottom of the Access Startup window when
the field is clicked. A description can be used as a guideline for users, and its
length can be up to 255 characters long including spaces.
Switching between views in a table:
Tables have two views: Design view and Datasheet view. You use Design view to create and
modify the structure of a table. You use Datasheet view to view, add, delete, and edit data in a
table.
Setting Field Properties
In addition to the three items (Field Name, Data Type and optionally Description) every field
has a set of Properties. A Property is a characteristics of an object that you use to specify how
you want data stored, handled and displayed. Properties you can set for a field, however, are
dependent on its data type. The bottom part of the Table Design window is where you enter
details about field properties. Access provides fifteen properties, even if those available for a field
depend on its data type. Field properties available in Microsoft Access and their description are
given below:
Property Description
Field Size...................... Sets the maximum allowable number of characters stored in a field.
Format .......................... Affects how a field data is displayed; you can use pre-defined formats or
specify your own
Decimal Places ............. Sets the number of digits to the right of a decimal in a numeric field
Input Mask.................... Formatting characters for data entry. Specially used when the data
entered in the field has a pre-defined structure; you can use pre-defined
masks or customize your own.
Caption ......................... Field label to be used in a form or report.
Default Value ............... Value entered in a field when records are created
Validation Rule............. Are expressions used by Access to determine whether or not the data to
be entered is valid or not.
Validation Text............. Text that appears when invalid data is entered into a field.
Required ....................... Setting that forces a user to make an entry in a field
Allow Zero Length....... Setting that defines whether zero-length strings are permitted.
Indexed......................... When this property is set to Yes for a field, Access creates and maintain
an index of values entered into the field.
Unicode Compression .. When this property is set to Yes, any character whose first byte is 0 is
compressed when stored and uncompressed when it is retrieved.
Data type – Number
Field Properties:
Field Size: For a number field, the Field Size property determines the range of values that can be
stored in the field and whether the field can contain fractional values. By default, Microsoft
Access sets the Field Size property to Double for fields with the Number data type, so the field
can store any practical value.
The following table lists the Field Size settings for Number fields and the range of values they
allow.
6. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 6
Field Size
Setting Range
Decimal
Places
Storage
Size
Byte 0 to 255 None 1 byte
Integer -32,768 to 32,767 None 2 byte
Long
Integer
-2,147,483,648 to 2,147,483,648 None 4 byte
Single -3.402823E38 to -1.401298E-45 for negative values and
from 1.401298E-45 to 3.402823E38 for positive value
7 4 byte
Double -1.79769313486231E308 to -4.94065645841247E-324
for negative values and from 1.79769313486231E308 to
4.94065645841247E-324 for positive value
15 8 bytes
It is a good idea to limit the field size to the smallest setting you need, since Microsoft Access
works faster with smaller field sizes. For example, for a field that stores only small integers, you
should choose Byte. For a field that stores large integers, such as invoice numbers, you should
choose Integer or Long Integer.
If you want to store numbers with decimal places, you must set the field size to Single or Double.
For a field that stores monetary values, however, you should choose the Currency data type, not
the Number data type.
Format: Microsoft Access can display values such as numbers and dates in many formats. For
example, Microsoft Access can display numbers with a currency symbol or with a specified
number of decimal places. The format affects only how a value is displayed, not the value stored
in the table. To specify the display format which Microsoft Access uses for data in a field, you set
the Format property. If you don’t set the Format property, Microsoft Access displays values in
General format, and the data appears exactly as you enter it.
Microsoft Access uses a field’s display format in table and query datasheets and copies the format
to new forms and reports. Existing forms and reports aren’t affected when you change a field’s
display format. To match the change you have made, you must also change the display format for
existing controls that are bound to the field.
Microsoft Access can display a wide range of international formats. To help ensure consistency
among applications, Microsoft Access uses the settings from the Windows Control Panel for the
number and date/time formats.
Decimal Places: If you don’t specify a format, or if you specify the General Number format,
Microsoft Access displays numbers with thousands separator or other formatting. If you want
numbers in a field to have a thousand’s separator, choose the Standard or Currency setting.
The following table shows the formats available for fields with the Number or Currency data
type and the way they display data by default in a form or datasheet.
Field Size – Double
With this Format This Number Is displayed this way
General Number 1234.5 1234.5
Currency 1234.5 $1,234.50(U.S) 1,234.50(U.K)
Fixed 1234.5 1235
Standard 1234.5 1,234.50
Percent 0.824 82.40%
7. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 7
Scientific 1234.5 1.23E+03
The General Number format displays just the number of decimal places necessary for each
value. If you specify a format other than General Number, such as Fixed, you can specify the
exact number of decimal places you want to display by setting the Decimal Places property.
When the Decimal Places property is set to Auto, the default, Microsoft Access displays the
default number of decimal places for the display format (0 for fixed, 2 for other formats).
Data type – Date/Time Formats
The following table shows the formats available for fields with the Date/Time data type and the
way they display data in a form or datasheet.
Field Properties – Format
With this format Dates and times are displayed this way
General Date 1/3/92 4:30:00PM
Long Date Friday, January 31,1992
Medium Date 31-Jan-92
Short Date 1/31/1992
Long Time 4:30:00PM
Medium Time 04:30PM
Short Time 16:30
Input Masks for Data Entry
The other field property of Access 2003 is Input Mask. If all the values you enter in a field are to
have the same format, you can simplify data entry by creating a pattern called an input mask. An
input mask automatically shows literal display characters in a field. When you enter data into the
field, you don’t have to enter these characters, even if they are to be stored in the field; instead,
you fill in the blanks in the input mask. For example, if all the phone numbers you enter in a field
have the same format, you can use an input mask so that you don’t have to enter the parentheses,
spaces, dots, or dashes for each phone number. Instead, you can just type numbers in the blanks
in the input mask.
Creating an input mask
To create an input mask, you set the Input Mask property for a field in a table or query or for a
control on a form or report. You can use the Input Mask wizard to help you set this property, or
you can type a setting directly into the property sheet. After you set the Input Mask property, new
data you enter must fit the input mask. Existing data in the field is not changed, but if existing
values don’t fit in the input mask, they are displayed without the mask.
To set your own input mask, you enter mask characters and literal display characters for the input
mask property. Mask characters determine how many blanks are in the mask, what you can enter
in the blanks, and how the input mask appears and works.
The following table explains how Microsoft Access interprets some characters in an input mask.
Mask
Character
Use in Input Mask for
9 Digit only (0 – 9) (entry not required)
? Letter (A – Z) (entry not required)
a Letter or digit (0 – 9 or A – Z) (entry not required)
C Any character or space (entry not required)
. , : ; - / Decimal point, thousands, date, and time separators (depend on settings in the
International section in Windows Control Panel))
< Causes characters to the right to be converted to lower case (Small letters)
8. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 8
> Causes characters to the right to be converted to upper case (Capital letters)
Literal characters you use are displayed in the mask as you enter them. The following table shows
some useful input masks and the type of values you can enter into them when you use data type:
text.
Input Mask Sample Value
(999) 999-9999 (206) 555-0248
(999) 999-???? (206) 555-TELE
999-9999a999 555-7000,015-0248B453
999-99-9999 539-88-3736
>??????999?9 GREENG339M3, MAY R 452B7
>?9?9?9 T2F8M4
>?<?????????????? Solomon Zelalem
Tele: 99-99-99 Tele: 12-20-33
Field Property – Default Value
If you know that certain field often has the same value, you can set a default value that appears in
the field whenever you add a record in a form or datasheet. For example, if most orders you enter
are for a single item, you could set the default value for the Quantity field to 1.
To specify a default value for a field, you set its data type to text and define Default Value
property. Once you set a default value for a field, it’s used whenever you add a record in a table.
(Setting a default value has no effect on existing data).
Whenever you set a default value for a field, you’ll usually specify a constant value (such as 1 or
WA) as a field’s default. However, you can also specify an expression for the Default Value
property. For example, you can enter =Date( ) or =Now( ) to insert the current date or time into a
field. Expressions you enter as default values can’t include any control or field references or user-
defined functions.
Default value for data type: Date/Time:
Suppose that you want the Order Date field in an Order table to be filled with the current date
whenever you add an order. In design view, set the Default Value property for the Order Date
field to =Date( ).
Each time you add a new record to the Order table, the current date (the computer’s system date)
appears in the Order Date field. This date is just default; you can change the value to another
date if necessary.
Field Property: Required
If you want a field to contain a value for every record, you can set the Required property for the
field to Yes. If this property is set to Yes, Microsoft Access doesn’t allow a null value to be
stored in the field. For example, you might want to require that an employee’s first and last name
always be entered before the record is saved. When you try to save a record that doesn’t contain a
value in a required field, Microsoft Access displays a message and doesn’t save the record until
you fill in the field.
Field Property: Validation Rules
Access validation rules are used to limit values to be entered in a field. Microsoft Access
automatically validates values based on a field’s data type; for example, Microsoft Access doesn’t
9. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 9
allow text in a numeric field. You can set more specific rules for data using Validation Rule
property for the field.
When you set the Validation Rule property, you specify requirements for data that is entered into
a field. For example, you can specify that numbers entered into a certain field be less than 100.
Microsoft Access doesn’t let you enter data that breaks a field’s validation rule.
When you make an entry that breaks the validation rule you’ve specified, you’ll want a message
to tell what has happened. You specify the message text by setting the field’s Validation Text
property. Microsoft Access displays the text you specify when an entry in the field breaks the
validation rule. For example, if your validation rule requires that values entered be less than 100,
you can set the Validation Text property to display this message: “You must enter a value less
than 100”. The message you create should always make it apparent why a value entered is not
allowed.
Entering a validation expression
You specify validation rules as expressions. The expression tells Microsoft Access how to
determine whether a value is allowed in a field. Expressions range from simple expressions such
as <=0 to more complex ones such as “USA” Or “UK” Or “Canada”.
Typing an expression is a quick way to set the Validation Rule property. For complex
expressions, however, it may be easier to use the Expression Builder. To use the Expression
Builder, click the Validation Rule property box, and then click the Build button to the right of
the property box. Microsoft Access displays the Expression Builder dialog box. For more
information on the Expression Builder, search Help for “Expression Builder”.
The following table shows examples of common validation rule expressions. Note that you must
place number signs (#) around date values.
Validation Rule setting Validation Text setting
<>0 Value must be a nonzero value
0 or >100 Value must be either 0 or over 100
Like “K???” Value must be four characters beginning with the letter K
<#1/1/92# Date must be before 1992
>=#1/1/91# And <#1/1/92# Date must be in 1991
Creating Indexes
If you often search a table or sort its records by particular field, you can speed up these operations
by creating an index for the field. Microsoft Access uses indexes in a table as you use an index in
a book: to find data, it looks up the location of the data in the index.
You create an index on a single field by setting the Indexed property. The following table lists
the possible settings for the Indexed property.
Index Property Setting Meaning
No Don’t create an index on this field (or delete existing index)
Yes (Duplicates Ok) Create an index on this field
Yes (No Duplicates) Create a unique index on this field
If you create a unique index, Microsoft Access doesn’t allow you to enter in a filed a value that
already exists in the same field for another record. Microsoft Access automatically creates a
unique index for primary keys, but you may want to prohibit duplicate values in other fields, as
well. For example, you can create a unique index on a field that stores serial numbers so that no
two products have the same serial number. For more information on unique indexes, search Help
for “Indexed”.
10. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 10
Customizing Tables
After you create a table, it is possible to modify the table structure, i.e. you can add new fields,
remove unwanted fields, change field names or field types, etc.
Primary Keys and Indexes
Primary Keys
The power of a relational database system such as Microsoft Access comes from its ability to
quickly find and bring together information stored in separate tables using queries, forms and
reports. In order to do this, each table should include a field or set of fields that uniquely identify
each record stored in the table. This information is called the Primary Key of the table. Once you
designate a primary key for a table, to ensure uniqueness, Microsoft Access will prevent any
Duplicate or Null values from being entered in the primary key fields.
Indexes
An Index helps Microsoft Access to find and sort records faster. Microsoft Access uses indexes
in a table as you use an index in a book: to find data, it looks up the location of the data in the
index. The primary key of a table is automatically indexed, and you can’t index a field whose
data type is Memo, Hyperlink, or OLE Object.
Defining Relationships
About relationship in a database
After you have set up different tables for each subject in your database, you need a way of telling
Microsoft Access how to bring that information back together again. The first step in this process
is to define Relationships between your tables. After you’ve done that, you can create queries,
forms, and reports to display information from several tables at once.
A relationship works by matching data in key fields usually a field with the same name in both
tables. In most cases, these matching fields are the primary key from one table which provides a
unique identifier for each record, and a foreign key in the other table.
There are two types of relationships:
1. One-to-many relationships: is the most common type of relationship. In this type of
relationship a record in Table A can have many matching records in Table B, but a record in
Table B has only one matching record in Table A. (See the following tables).
Table A. Customer file (one record per customer)
Table B. Purchased items file (one record per item)
Cust No Name Father Name Phone P.O.Box
1001 Muluwork Metaferia 11-48-43 80544
1002 Arega Nigissie 18-90-66 63522
1003 Richard Reitz 55-89-00 45763
Cust No Item Type Quantity Unit Price Date
1001 Pen 3 10 12/10/96
1002 Pen 1 12.50 11/05/95
1003 Pen 2 33.25 13/06/97
1001 Pencil 1 9 22/09/98
1002 Pencil 2 12 19/06/97
1001 Note Book 3 9 24/06/99
11. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 11
2. One-to-one relationship: each record in Table A can have only one matching record in Table
B, and each record in Table B can have only one matching record in Table A. This type of
relationship is not common, because most information related in this way would be in one table.
Defining relationships:
You define a relationship by adding the tables you want to relate to the Relationships window,
and then dragging the key field from one table and dropping it on the key field in other table. The
kind of relationship that Microsoft Access creates depends on how the related fields are defined:
A one-to-many relationship is created if only one of the related fields is primary key or has a
unique index.
A one-to-one relationship is created if both of the related fields are primary keys or have
unique indexes.
To view existing relationship:
The relationship existing between two tables is displayed as a line connecting the tables.
WORKING WITH DATA
n table Datasheet view you can add, edit or view the data in a table. You can also check the
spelling and print your table’s data, filter or sort records, change the data sheet’s appearance, or
change the table’s structure by adding or deleting columns. In table Design view, you can create
an entire table from scratch or add, delete, or customize an existing table’s fields. You open a
table in either view from the Database Window. To switch between views of an opened table,
you can click the Design view or Datasheet view button from the toolbar.
You can also enter and edit data into a table using a Form which usually provides more facilities
for such operations than a datasheet. This chapter discusses how to enter, edit, and manipulate
data using Datasheet view.
Finding, Replacing and Sorting Data
When you are viewing records from a large table, it can be a big challenge to navigate through
records and find just the data you want. Perhaps you want to find a specific record, or you want to
view only certain records. Or you may want to view records in certain order.
Sorting Data:
You can sort records in datasheet view, either in ascending or descending orders.
QUERIES
A query is a database object that you create to look for particular information in the database.
After you have created a query, you apply it to the data stored in table(s) and/or to the data that is
resulted by queries. You use queries to view, change, and analyze data in different ways. In using
queries, you have a great deal of flexibility.
With queries you can:
Choose fields: You don’t have to include all fields of a table in your query
I
12. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 12
Choose records: You can specify criteria that records must meet to be included in a
selected result. For example, you may be interested in seeing sales figures only for a certain
month.
Sort records: You can view records in a specific order. For example, you can list customer
records alphabetically by customer name.
Select records from different tables: You can use a query to answer a question about data
from more than one table and see the result in a single datasheet.
Perform calculations: You can perform calculations and view them in new fields, called
calculated fields.
Update tables: You can modify, delete or append a group of records all at once using
action queries.
Types of Queries
Queries can be broadly classified into two types: Select Queries and Action Queries.
I. Select queries
A select query retrieves data from one or more tables and displays the results in a Datasheet
where you can update the records. You can also use a select query to group records and calculate
sums, counts, averages and other types of totals.
II. Action queries
An action query is a query that makes changes to many records in just one operation. There are
four types of action queries:
1. Delete query
Deletes a group of records from one or more tables. For example, you can use a delete query to
remove products that are discontinued or for which there are no orders. With delete queries, you
always delete entire records, not just selected fields within records.
2. Update query
Is used to update/change a group of records in one or more tables. For example, you can raise
prices by 10 percent for all dairy products, or you can raise salaries by 5 percent for the people
within a certain job category. With an update query, you can change data in existing tables.
3. Append query
Adds a group of records from one or more tables to the end of one or more tables. Append queries
are also helpful for:
Appending fields based on criteria. For example, you might want to append only the names
and addresses of customers with outstanding orders.
Appending records when some of the fields in one table don’t exist in the other table.
4. Make-Table queries
Creates a new table from all or part of the data in one or more tables. Make-table queries are
helpful for:
Making a backup copy of a table
Creating a history table that contains records. For example, you could create a table that
stores all your old orders before deleting them from your current Orders table.
13. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 13
These bound controls get their data from the Product
Name and Unit Price fields in the Products table.
This calculated control uses the following expression
as its data source: = [Unit Price]*0.75. You specify
the expression in the Control Source property box.
Unbound controls such as this rectangle and
freestanding label don’t have data source
FORMS
ike a paper from that you fill out with a pen or pencil, a Microsoft Access Form identifies
the data that you want to collect. However, it also gives you a way to enter data into your
tables, display it for review, and print it for distribution.
Forms let you view, enter, edit, and print data in a way that is easier to use than a Table or
Datasheet. You use Forms to present or input one record at a time. For example, you can use a
Form to enter information about new transaction made by a customer in the Charges table. You
can easily switch between a Form and Datasheet to change between viewing at one record and so
many records at a time. Variety of design elements such as titles, pictures, lines, and color can be
used in creating Forms. These are the major advantages of using Form than a Table or Datasheet.
Among the purpose of Access Forms, the following are major ones:
Produce a form that looks like a paper form you are familiar with;
Present your data in an attractive way with fonts and other graphical effects such as color
and shading;
Display data from more than one table; and
Perform calculations using existing data from table(s).
Working with Controls on Forms
All the information on a form is contained in Controls. Controls are objects on a form that
display data, or decorate the form. For example, you can use a text box on a form to display data,
or a line or rectangle to separate and group controls to make them more readable. Controls are
formed from field names in the original table.
Microsoft Access includes the following types of controls, which are all accessible through the
toolbox in form design view: text box, option group, option button, check box, toggle button,
combo box, list box, command button, image control, bound object frame, unbound object frame,
subform/subreport, page break, line and rectangle.
Controls can be bound, unbound or calculated. A bound control is tied to a field in an
underlying table or query. You use bound controls to display, enter, and update values from fields
in your database. A calculated control uses an expression as its source of data. An expression can
use data from a field in an underlying table or query of a form, or from another control on the
form. An unbound control doesn’t have a data source. You can use unbound controls to display
information, lines, rectangles and pictures. The following illustration shows examples of bound,
unbound, and calculated controls.
Labels
You use labels on a form to display descriptive text such as titles, captions or brief instructions.
Labels don’t display values from fields or expressions; they are always unbound and they don’t
change as you move from record to record. A label can be attached to another control. When you
L
14. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 14
Type a text directly in a combo box
When you click a
value in a list box
create a text box, for example, it has an attached label that displays a caption for that text box.
This label appears as a column heading in the Datasheet view of a form.
When you create a label using the Label tool, the label stands on its own; it isn’t attached to any
other control. You use stand alone labels for information such as the title of a form or for other
descriptive text. Stand-alone labels don’t appear in Datasheet view.
Text Boxes
You use text boxes on a form to display data from a table, or query. This type of text box is called
a bound text box because it is bound/linked to data in a field. Text boxes can also be unbound.
For example, you can create an unbound text box to display the results of a calculation, or to
accept input from a user. Data in an unbound text box isn’t stored anywhere.
Combo Boxes
In many cases, it is quicker and easier to select a value from a
list than to remember a value to type. A list of choices also
helps to ensure that the value that is entered in a field is
correct. Combo box displays a list from which to choose
your data. You can also type new values as well as
select values from a list using combo box.
When you enter text or select a value in a combo box in a Form
view, if the combo box is bound, the entered or selected value is
inserted into the field that the combo box is bound to.
Combo boxes have a Limit To List property that you can use to control whether any value can be
entered in the list or only text that matches one of the values in the list.
Advantage of a combo box is that you can type the first few characters of a value in the combo
box to quickly find that value. Also, you can control whether any value can be entered in the list
or only text that matches one of the values in the list.
Form Properties
In Microsoft Access, you use properties to determine the characteristics of tables, queries, fields,
forms, and reports. Every control on a form has Properties as well. Control properties determine
the structure, appearance, and behavior of a control as well as the characteristics of the text or
data it contains. You set properties using the property sheet. For example, the formatting property
sheet for a Total Sales control can be set to Currency.
To set properties for a form, section, or control:
Working with Sections
Sections of a form: You increase the effectiveness of a form by adding sections, which are
designated elements of the form design. Access has five section types for forms, which you can
use in any combination (see the following figure). For example, if you want to use a form to both
enter and print data, you can add a header that appears only in Form view and another that
appears only when the form is printed. You can adjust the size of the sections in your form, and
set properties for them. Within a section, you can add any controls you want. The type of form
you want to create determines which sections you use and what information you put into each
section. Some common uses for these five sections are described below.
15. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 15
1. Form header: Displays the title for the form. When a form is displayed in a Form view, the
form header appears at the top of the screen. When a form is printed, the form header appears
at the top of the first page. A form header does not appear in datasheet view.
2. Page header: Displays information such as title, column headings, or any information you
want at the top of every page. A page header appears only on printed forms.
3. Detail section: Displays records. You can display one record per screen or page or as many
as will fit
4. Page footer: Displays information such as date, page number, or any information you want at
the bottom of every page. A page footer appears only on printed forms.
5. Form footer: When a form is displayed in a Form view, the form footer appears at the
bottom of the screen. When a form is printed it appears on the last page.
You can increase the effectiveness of a form by adding one or more sections. Most forms have
just detail section, but a form can also include form header, page header, page footer, and form
footer sections.
Notes:
Form headers and footers appear at the top and bottom of a form in Form view and at the
beginning and end of a printed form. Page headers and footers appear at the top and
bottom of each printed page but they don’t appear in Form view.
If you remove a header and footer, Microsoft Access deletes the controls in the header
and footer.
You can only add a header and footer as a pair. If you don’t want both a header and a
footer, you can resize the one you don’t want so that it has no height, or you can set its
Visible property to No. You can also set the Display When property of a form header and
footer to specify when you want the header and footer to be displayed Always, in Print
Only, or on the Screen Only.
To create a calculated control:
Switchboard
A switchboard is a form that opens other forms and reports in a database. You use the
Switchboard Manager to create, edit and delete a switchboard.
Form Header
Page Header
Form Footer
Detail Section
Page Footer
16. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 16
REPORTS
Report is information you have organized and formatted to fit your specifications. A report gives
you a way to retrieve and present data as meaningful information that you can use and distribute.
With Access you can design reports that present information the way you want. You can use many
different design elements, such as text, pictures, lines, boxes and graphs in creating a report. Examples
of reports are mailing labels, invoices, and sales summaries.
Reports are also an efficient way to print information that you use regularly. You can create a design for
a report and then save it so that you can use it over and over again. If your reporting needs change, you
can adjust the report design or create a similar report based on the original report.
With Access you can create reports that:
Organize and present data in groups;
Calculate running totals, group totals and percentage of totals; and
Present your data in an attractive format with pictures, lines, and special fonts.
Switch between views of a report
Reports have three views: Design view, Print Preview, and Layout Preview. You use Design view to
create a report or change the structure of an existing report. You use Print Preview to view the report’s
data as it will appear on every page. You use Layout Preview to view the report’s layout, which
includes just a sample of the data in the report.
Preview a report
Previewing a report shows what it looks when your report is printed on a paper. You can take a quick
look at the layout, which includes just a sample of the data in the report. Or you can verify the data by
reviewing every page in the report.
Layout Preview is fast way to check the layout of a report because Microsoft Access uses just enough
data from the underlying table or query to show you what the report will look like. If you want to
review the exact data that will appear in a report, use Print Preview.
To print a report:
Before you print a report for the first time, you might want to check the margins, page orientation, and
other page setup options.
Add a page break to a report
In reports, you use a page break control to mark where you want to start a new page within a section.
For example, if you want a report’s title page and introductory message printed on separate pages, place
a page break in the report header after the controls that you want to appear on the title page and before
the controls for the second page.
Working with Sections
The information in a report can be divided into sections. Each section has a specific purpose, and prints
in a predictable order on the page and in the report.
In Design view, sections are represented as bands, and each section that the report contains is
represented once. In the printed report, some sections may be repeated many times. You determine
where information appears in every section by placing controls, such as labels and text boxes.
A
Report Header
Page Header
Detail Section
Page Footer
Report Footer
17. Introduction to MS- Access 2007
Abenezer Computer Training Center Batu 0921361791 Page 17