0% found this document useful (0 votes)
17 views31 pages

MS Access Part I

Uploaded by

Kasun Madusanka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views31 pages

MS Access Part I

Uploaded by

Kasun Madusanka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Microsoft ACCESS

(Part-I)

Faculty of Engineering
University of Ruhuna
June 2020 Dr. J.M. Ruwan S. Appuhamy
Introduction
What is MS Access
Access is an electronic relational database application that helps to manage
large amounts of information.

What is a Database
A variety of definitions exist for a database; but
essentially it's a collection of information. A filing
cabinet, a Rolodex, a library card catalog, and even
the Internet are all types of databases.
Most often the word "database" is used to describe a collection of related
"data" (information) stored on computers.
Access provides a mechanism for storing, organizing, accessing,
manipulating and reporting on large quantities of data.
You can create simple databases by creating a Word Table or an Excel
spreadsheet. These can be used to keep data such as names and addresses.
Introduction
Why do we use Microsoft Access?
Microsoft Access is a "relational" database application. Relational means
we can link together sets of data, we can relate the data.
For ex: we can keep track of the patients, the
doctors and when the patients last saw their
doctors, what happened at each visit and so on.
Access allows us to relate our data, without the
repetition that may occur anywhere else.
An electronic database works much the same
way as a manual filing system, except that all
of the information is stored electronically.
Information in a filing system is usually
organized in some logical manner, such as
alphabetically by last name, by product
category, by geographic region, etc.
Information in Microsoft Access is also
organized in a logical manner using TABLES.
Introduction
What it a Database Table?
The database table is the basic unit of storage in Access. Each database will
contain many different tables, and relationships will exist between tables.
For ex; an employee database contains information about each employee of
their company, such as:
 Employee ID  Street Address  Zip Code
 Name  City  Home Phone
 Date of Hire  State  Gender etc.

A typical database table would look something like this:

A collection of fields make up a record. A collection of records make up a


Table. A collection of Tables make up a database.
Getting Started with MS Access 2007
Double click on the Access 2007 icon on the Windows desktop, or
click-on the Start button in the lower left corner of the screen, then
click-on Programs, and then click-on Microsoft Access 2007.

The Getting Started with Microsoft Office Access screen will appear as below.
Creating an Access 2007 Database
We’ll begin with a Blank Database and increase our database knowledge with
each step.
Look at the center of your Access screen. You will see –
Getting Started with Microsoft Office Access. Below the
title you will see a Blank Database button.
Click the Blank Database button.

As soon as you click the Blank Database button, the


right side of your Access screen will change and
look like the image on the left.

Saving Your Work


One of the unique things about Access database is
that it requires you to save your database as soon as
you enter the program.
To choose the Drive, on which you will save your
Access database, click the small folder to the right
of File Name:
Saving Your Work – (cont.)
A New File Database menu screen as below will appear when you click the folder.

Save in: area Disk drives


available

To Save,
File name
(better with no spaces)
Click OK

You will now return to the Getting Started with


Microsoft Office Access screen. On the right side of the
screen you will see your database File Name and below
it, the Drive on which you will create your database.
Click the Create button.
Creating a Table
When you click the Create button your Access 2007 screen will change to the
image below. You will now see Tabs and Ribbons that automatically appear for
the area in Access on which you’re working. Instead of a Menu Bar and drop
down selections, you’ll now see these new features.
Tabs

Ribbon

Groups

When we clicked the Create button Access assumed we desired to create – within
our Employee database – another database – which is called a Table. You’ll
notice that at the top of the above image that the Table Tools and Datasheet Tabs
appeared to assist you. The Ribbon below these Tabs is composed of Groups of
selections you’ll use to assist you as you create your Table.
Creating a Table – (cont.)
On the left of the Table Tools-Datasheet Tab/Ribbon you’ll see a View
button. Click the View button.

When you click the View button the image on the left
will appear. Since we want to create or design a new
Table, we’ll click the Design View selection.

NOTE: Access consists of 4 main database objects: Tables, Queries, Forms, and Reports.
Each object has at least 2 views, Design and Data. The Design View is where we build the
structure of that database object. The Data view is different for each object. Tables and
Queries have a Datasheet View, Forms have a Form View, and Reports have a Report
View, or a Print Preview View.

A Save As menu screen will appear similar to the


image on the right. Type Employee in the Table
Name: area and then click the OK button.
Creating a Table – (cont.)
Now your Access 2007 screen will now change again – to the image below.

Let’s enlarge the upper


left corner of this
image as shown bellow.

Notice that our Table Tools


Tab still appears. However,
because we are now in the
Design process, the lower
Tab/Ribbon has changed to
Design – to assist us with
designing our Table.
Creating a Table – (cont.)
Here, you will notice that the Primary Key button
is “orange” and, in our Employee Table, that it is
also “orange” – with a little key to the left of ID.
In database language this is called “Keying”.

In order to create relationships between tables, the user will need to define a
primary key, or foreign key, for each table in the database.
The primary key will be unique for each and every record. Once a primary key
has been defined, Access will not allow users to enter the same value in a field as
another record. For example, if the user were to define a Personal ID Card
Number field as a primary key, same personal ID card number could not be
entered for two records in the database.
Good Primary Key Not good for the Primary Key
Creating a Table – (cont.)
To “turn off” the Primary Key, click the Primary Key
button. You’ll notice that they Primary Key button is no
longer “orange” and the little key is gone from the left of
ID.
If you want to have a Primary Key, click the Primary
Key button again. Notice, bellow in the “Field properties”
area, “Indexed” is changed to “YES (No Duplicates)”.

Notice, under the Blue Bar at the top of the Design screen there are (3) things:
Field name, Data Type, & Description.

And, in the lower half of the window; Field Properties.


Creating a Table – (cont.)
We’ll be creating the Field Names that make up a database.
This is similar to creating a blank personnel form (on paper) that will be
"filled-in" for each employee (Name, Address, Phone Number, etc.).
The areas that will be filled in are called Fields in a database. When you fill in
all of the fields for a person, the individual "forms" are called records in a
database. There will be a record, or form, for each employee. All the forms,
together, make up a Table (database).

Significant Note:
When creating a database it is always best to “break down” a field into its
“smallest parts.”
For example – Name would break down into First Name, and Last Name (you
could also have Middle, Initial, Title, etc.)
Address would break down into Street Address, City, State, and Zip (you could
also have Apartment Number, etc).
Because we are working in Access 2007 it will be very simple to “put the fields
back together” with a few mouse clicks when we need to do this.
Creating a Table – (cont.)
So let’s create a Employee database.
Look at the image here. Click-in the area or space under
Field Name and type-in FirstName (to replace ID).
Tap Enter or click-in the area to the right under Data
Type. The cursor now moves to the right under Data
Type. Click the down arrow under Data Type on right.

Now we’ll talk about Data Types.


Data Types
Text You may type in any alphabetical/numerical data that you desire - up to a
maximum of 255 characters. As indicated, this is a text field, so you can't do
mathematical calculations. Examples of Text data are: names, addresses,
stock numbers, room numbers, zip codes, etc.
Memo This field is for lots of text. You can have up to 32,000 characters.
Number This field is for numbers where you want to add, subtract, multiply, divide,
average, and do numerical calculations. This field can be a very large size,
so when we get to Field Properties, we'll talk about "sizing" this field so it
doesn't take up too much "space" in storage.
Creating a Table – (cont.)
Data Types (Contd.)
Date/Time Dates and Times. You may format these later, as you may desire.
Currency Dollars ($). You may format these later, as you may desire.
Auto This field is an "automatic" counter that assigns a number each time you put
Number data into a new field.
Yes/No This is for fields where the data will be one of two values, such as
"True/False" or "Yes/No" type of field.
OLE This means "Object Link Embedding" which indicates you can insert a
Object graphic, picture, sound, etc.
Hyperlink This is for fields containing a hyperlink address, such as a website or e-mail
address.
Attachment This is for fields that will contain an attachment, such as a Word document,
Excel file, or bitmap image.
Calculated This is for fields that will be used to perform calculations.
Lookup This is for fields with a limited number of possible selections, where a list
Wizard of possible options can be set for the user to select from a drop down list.
Ex: Provide a drop down list for the various divisions in a company, so that
the user would not have to type the division name for each record.
Creating a Table – (cont.)
We'll leave FirstName as a Text Data Type. To the right under Description you
may make any remarks you feel are appropriate to someone who may want to
know how/why you designed the field as you did.

Now notice in the lower part of the screen, under Field Properties, that a box
appeared when you selected the Text Data Type. This box is "tailored" to the
Text Data Type that you selected above. Your Field Properties should look like
the one below when you finish doing the steps indicated below.
Creating a Table – (cont.)
Field Properties: Click-in each area (to the right of the words).
Field Properties
Field Size Is currently set to 255 characters. That's pretty large for a name. So, click-
in this area and change the number to 25 (you can make this larger or
smaller later if you have to).
Format Now click-in the Format Area. Next tap the F1 function key to activate
Help.

Since you are in the Format area, Help will be "tailored to" this area. When the
Help Window appears, click Format Property.

Now click Text and Memo Data Types. Notice that there are several choices to
make your characters upper or lower case. (< : Force all characters to lowercase,
> : Force all characters to uppercase, etc.)
This gives you an idea of some formats. We'll use one later. Now click-on the
“X” in the upper right corner of the Microsoft Access Help – Format
Property Window to close it.
Creating a Table – (cont.)
Field Properties (Contd.)
Input Mask We'll come back to this feature later.
Caption Look at the Light Blue Help area to the right. It explains about
Caption.
Default Value We'll come back to this feature later.
Validation Rule We'll come back to this feature later.
Validation Text We'll come back to this feature later.
Required Look at the Light Blue Help area to the right.
Allow Zero Length Look at the Light Blue Help area to the right.
Indexed Look at the Light Blue Help area to the right.
Unicode
Look at the Light Blue Help area to the right.
Compression
IME Mode Look at the Light Blue Help area to the right.
IME Sentence
Look at the Light Blue Help area to the right.
Mode
Smart Tags Look at the Light Blue Help area to the right.
Creating a Table – (cont.)
Now we’ll repeat this process and create different Field Names and Data Types.
Type-in the Field Names as indicated below and set them to the Data Types and
Sizes indicated.

Field Name Data Type Size


FirstName Text 25 (Already created)
LastName Text 20
IDNo Text 10
StreetAddress Text 40
City Text 15
Gender Text 1

Now Insert a “ > ” in the Format area to make all gender entries become upper
case (Capitals, i.e. “M” or “F”).
Creating a Table – (cont.)
Now lets interchange the Rows and define “Primary Key” properly as bellow.

Now lets add a “Title” to Field Name and Data Type as a “Lookup wizard”.
You will get the following screen.

Click on “I will type in the values


that I want” and press “Next”.
Creating a Table – (cont.)
Now you will get the screen as bellow and type,
“Prof.”, “Dr.”, “Mr.” and “Mrs.” in Col1 as
shown here.
Click “Next”.

Type the Label name for the column


(Title) and click “Finish”.

Check in “Field Properties”,


“Lookup” to see whether
your “Lookup wizard” has
added or not.
Creating a Table – (cont.)
Now lets interchange the Title Field to the top of the Field Table as bellow.

Now lets add the Field Name,


“FavoriteNo” with Data Type, “Number”
as shown here.
Note, this is the first Number field that we
introduced to our database.

Here we'll learn about Numbers, the Validation Rule and Validation Text.
We'll limit the person's favorite number to a number between 1 and 999. Leave
the Field Size set to Long Integer.
Creating a Table – (cont.)
Now click-in the area to the right of Decimal Places. It currently indicates Auto.
Click-on the little down arrow. Select “0”. This indicates that decimal places are
not allowed in the Favorite Number.

Next, click-in the Validation Rule area. We'll "build" a mathematical expression
that will only allow numbers from 1 to 999. Type in the following expression:
> 0 and < 1000

If someone does not enter a number correctly, an error message will appear.
Now we'll create an appropriate error message. Click-in the Validation Text area
and type-in: “Favorite number must be between 1 and 999”
Creating a Table – (cont.)
Continue entering the following information in the Field Name and Data Type
areas as we did above.
DateHired Date/Time

In Format area click the small down arrow and


choose Short Date.
In the Input Mask area click the three dots (...),
Save the table, and choose Short Date again,
click Next>, click Next> again, then click Finish.
(This will insert a “ / ” between the day, month,
year).

Your Field Properties should look like the image below.


Creating a Table – (cont.)
Continue entering the following information in the Field Name and Data Type
areas as we did above.
PhoneNo Text

In the Input Mask area click the three dots (...), Save the table, and choose
Phone Number, click Next>, click Next> again, then click Finish. (This will
insert a “ ( _ _ _ ) _ _ - _ _ _ _ _ ” to the Phone number field)

You will see some “special” numbers written in the


Input Mask area for PhoneNo. When you begin to
enter data in this field, you’ll see how this works.
Creating a Table – (cont.)
Continue entering the following information in the Field Name and Data Type
areas as we did above.
Salary(Rs) Currency

In Format area click the small down arrow and choose Standard (If you use
“Currency”, the values are in $).
In the Decimal Places Field Properties area click-on the small down arrow and
select 0 – this indicates “no cents”. Type a 0 (zero) in the area of Default Value.
This will indicate 0 income if no Salary figure is entered.
Creating a Table – (cont.)
Continue entering the following information in the Field Name and Data Type
areas as we did above.
ApplicationReceived Yes/No

We’ll make this a “Yes/No” or “check box” field. When we begin entering data in
the database, you’ll see how this “box” works.

Now that we have created our


EmployeeData Database and Employee
Table. It would be a good time to Save the
last few changes.
Entering Data in the Database
At this point you will still be in the Design view. To enter data into
your Table you will need to be in a Datasheet View.
Click the View button. Then click the Datasheet View. Now you
will see the bellow screen which looks like a tiny version
spreadsheet. Notice that all of the Fields you created are – in the
order you created them – along the top of the Table.

Some of the Field Names may be “cut off” a bit. Let’s widen our fields.
Move your cursor over the “line” between two Field Names.
Click and hold down the left mouse button and move your
cursor to the right a bit.

Note:
Since we have a Validation Rule in one of our Fields, it is better to widen
columns when you are not entering data, as otherwise it may give error massages.
Save your layout changes of the table Datasheet View.
Entering Data in the Database – (cont.)
Now let’s enter the bellow data in each field of our datasheet.

Field Name To be typed


Title Prof.
FirstName Hirosh
LastName Jayasinghe
Gender Male
IDNo 705566778v
StreetAddress 55, Galaha Road
City Peradeniya
FavoriteNo 777
DateHired 05/01/2005
PhoneNo (081) -23-93000
Salary(Rs) 165,000
ApplicationReceived Yes (Here, Point the mouse to the little square and
click the left mouse button. You will see a check
mark appear in the square)
Entering Data in the Database – (cont.)
As you are entering this data you will notice several things.
Date Hired and Phone No – You’ll see your Input Mask work.
Gender – You typed in small letters – notice how the Format ( > ) forced the
letter(s) to be capitals.
Favorite Number – since the Favorite Number is “too big” you will see your
error message appear. Click-on OK in the message screen and then create a
Favorite number that will work.
Salary - notice how your Currency formatting created a comma and round off.

When you have completed typing the information, tap Enter so the cursor will
move down to the next record. You are now ready to insert your 2nd entry.
Note: When you tapped Enter, Access automatically saved your first record.
Also note: As you began typing your first record a small pencil appeared in the
left margin. This indicates that you are "writing to" this record (editing). Below
the pencil an * (asterisk) also appeared. This indicates that your next record will
go below the first.
Entering Data in the Database – (cont.)

Important
To record enough information so that you can see the power of Access
database does enter 20 or more records now. You may use either
Form View or Datasheet View.

You might also like