MS Access
MS Access
2
also commonly called a row, and a field is
also commonly called a column.
Setting the Data Type for a Field
Access lets you control how data can be
entered in each table field within your
database. This is done using Data Type.
Description of the Data types
1. Short text: Alphanumeric data (text and
numbers) stores up to 255 characters.
2. Long text: Alphanumeric data. Stores a
maximum of 65,535 ;used to enter long
sentences.
3. Number: Only takes numeric data
4. Date/Time: Stores Dates and times
5. Currency: Use this data type to store
monetary financial data and when you don't
want Access to round values.
6. AutoNumber: Unique values created by
Access when you create a new record.
3
7. Yes/No data. Access uses 1 for all Yes
values and 0 for all No values.
8. OLE Object: Images, documents, graphs,
and other objects from Office and Windows-
based programs.
9. Hyperlink: Web addresses. You can store
links to Web sites or files on your computer.
10. Attachment: You can attach images,
spreadsheet files, documents and charts in
your database.
12. Calculated: Allows you to perform
calculations using the expression Builder.
11. Lookup Wizard: Allows you store data
that is constant and displays it as a menu.
Creating a Blank database
Open Ms Access
Click on Blank Database
4
Click on the folder icon to browse the
location where you want to save your
database.
Give your database a name and click on
create.
Creating tables
1. When you create a new blank database a
table is automatically created.
2. To create a new table click on create tab,
click on table give it a name and save.
Table views
1. Design view: allows you to define the
table fields and set the data types.
2. Datasheet view: Allows you to enter
records into a table.
Keys
Fields that are part of a table relationship are
called keys.
5
1. Primary key: A table can have only
one primary key. A primary key consists
of one or more fields that uniquely
identify each record that you store in the
table.
2. Foreign key: A foreign key contains
values that correspond to values in the
primary key of another table.
Queries
Another database object is called a query. It
helps you to filter records, answer questions
and combine two or more tables.
If you want to pull data from more than one
table you will need to use either the Query
Design command or the Query Wizard.
Types of Queries: there are three types of
queries
1. Select query: A select query is a type
of database object that shows
6
information in Datasheet
view (Datasheet view: A window that
displays data from a table, form,
query, view, or stored procedure in a
row-and-column format. In Datasheet
view, you can edit fields, add and
delete data, and search for data.). A
query can get its data from one or more
tables, from existing queries, or from a
combination of the two. The tables or
queries from which a query gets its data
are referred to as its record source.
2. Action Queries
a. Delete query: Creates a delete query
that removes records from one or more
of the tables listed in the FROM clause
that satisfy the WHERE clause.
7
b. Update query: You use update queries
to add, change, or delete the data in one
or more existing records.
c.Append query: An append query adds a
set of records (rows) from one or more
source tables (or queries) to one or more
destination tables.
d. Make table query: it creates a new
table from all or part of the data in one or
more tables.
3. Cross tab queries-This is a query that
groups data into categories and displays
values in a spreadsheet-like format.
Using Totals, Sorting and Filtering Query
Results
Once you have the results looking how you
want them, you can calculate the totals, sort
8
and filter them to narrow your results down
even further.
Examples of criteria that can be used to
perform searches on a query
1. > < >= <= (= equals to)
2. Between, And, OR, In
3. Is null, is not null
4. Like , not like
5. Not
6. Date ()
Building Table Relationships
There are three types of table relationships.
1. One-to-one relationship: Each record in
the first table can have only one
matching record in the second table and
vice versa.
2. One-to-many relationship: Each record in
the first table can have many matching
9
record in the second table. One customer
can place many orders.
3. Many-to-many relationship: Each record
in the first table can have many matching
records in the second table and vice
versa. A single order can include more
than one product. On the other hand, a
single product can appear on many
orders.
To establish a relationship between tables:
Click Database Tools tab. NOTE: Tables
must be closed in order to establish
relationships.
Forms
Forms are an Access tool that users can
create to make data entry in database tables
easier.
Creating a Form: Click on create tab.
Types of Forms
10
a.Form command: Makes a basic form showing
one record at a time
b. Blank form: Allows you to design your own
form
c.Multiple item: creates a form that shows all
records at once
d. Split form: Creates a form showing one
record on top and includes the datasheet view
of entire source table on the bottom.
e. Form wizard: it walks you through the
process of creating more customized forms
FORM CONTROLS
Controls are objects that display data,
perform actions, and let you view and work
with information that enhances the user
interface. They include text box, labels, check
boxes, list box, combo box, command
buttons etc.
11
Types of controls
1. Bound control: A control whose source of
data is a field in a table or query.
2. Unbound control: A control that doesn't
have a source of data e.g. a label that
displays the title.
3. Calculated control: A control, whose
source of data is an expression or formula.
Reports
A report is an effective way to analyze and
present data using a specific layout.
The layout and formatting of the report can
be manipulated in Layout View.
IMPORTING AND LINKING DATA
Access allows you to bring in data from other
programs into the database file of from one
database file into another.
Theory Questions
2. Give advantages of DBMS
12
3. Give examples of DBMS
4. Explain the two types of database
5. Give and explain three ways of creating a database
6. Mention the database objects
7. Explain all the data types
8. Why do we set data types
9. Give the properties of a primary key
10. Differentiate between a primary key and a foreign key
11. Differentiate between the two table views
12. Give reasons why we relate tables
13. Explain the three types of table relationships giving one
example of each
14. Give the steps of creating table relationships
15. Give the procedure of freezing a column in access
16. Give three types of queries
17. Name and give the functions of the four action queries
18. Give two uses of a form
19. Mention four types of forms
20. Explain three controls used in a form
21. Explain how you can find a single record using a form
22. Give three advantages of creating a report.
23. Give the procedure of importing and exporting files in
Access
13
14