0% found this document useful (0 votes)
6 views

Module V

Uploaded by

Pashal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Module V

Uploaded by

Pashal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 198

Micro Computer Application

Microsoft Access
Module V

Training Department
[email protected]

1
msomibora.com
Course Objectives
 In this program you will learn more about
exactly:
 what a database is
 what it is used for
 how to perform simple database tasks, such as
adding and deleting records.

msomibora.com

msomibora.com Microsoft Access 2


Database
 Databases store and manage
information related to a particular
subject or purpose.
 Database is a single organized collection of
structured data in a data file with a
minimum duplication of data items so as to
provide consistent and control pool of
information.

msomibora.com Microsoft Access 3


Database Cont….
 In its simplest form, a database is a
collection of information that is
organized into a list and stored in a
manner similar to a file cabinet

A File Cabinet

msomibora.com Microsoft Access 4


Database Cont….
 Whenever you make a list of information,
such as names, addresses, products, or
invoices, you are, in fact, creating a
database
 Technically, you don't even have to use a
database program to create a database.
 You can make a list of information in all
kinds of programs, such as Microsoft Excel,
Microsoft Word, Notepad program etc.

msomibora.com Microsoft Access 5


Database Cont….
 A database program, however, is much more
powerful than a simple list you keep on
paper or in a Microsoft Word document. A
database program lets you:
 Store Information:
 A database stores lists of information that are related
to a particular subject or purpose. It could be a list of
home recipes, or business information, such as a list
of hundreds of thousands of customers. A database
also makes it easy to add, update, organize, and
delete information.

msomibora.com Microsoft Access 6


Database Cont….
 Find Information:
 You can easily and instantly locate information
stored in a database.
 For example, you can find all the customers with the
last name "Johnson" or all the customers who live in
the 55417 zip code and are older than 65.

msomibora.com Microsoft Access 7


Database Cont….
 Analyze and Print Information:
 You can perform calculations on information in a
database.
 For example, you could calculate what percent of
your total sales comes from Arusha Region. You can
also present information in a professional-looking
printed report.

msomibora.com Microsoft Access 8


Database Cont….
 Manage Information:
 Databases make it easy to work with and
manage huge amounts of information.
 For example, with a few keystrokes you can change
the area code for hundreds of customers in the (612)
area code to a new (817) area code.

msomibora.com Microsoft Access 9


Database Cont….
 Share Information:
 Most database programs (including Microsoft
Access) allow more than one user to view and
work with the same information at once. Such
databases are called databases.

msomibora.com Microsoft Access 10


Exercise 1
 What is a database?
 List down five things which you can perform
by using the database program.

msomibora.com Microsoft Access 11


msomibora.com Microsoft Access 12
Starting Microsoft - Access
There are several ways which you can use to start Microsoft
Access
1st Option
 Click on Start button
 Select All Programs
 Select Microsoft Office
 Click on Microsoft Access

msomibora.com Microsoft Access 13


Starting Microsoft Access
2nd Option
If there is a shortcut Icon to Microsoft Access on the Desktop
Double Click it

msomibora.com Microsoft Access 14


Starting Microsoft Access
3rd Option
 Click Start Button

 Click Run Command (Run box will appear)

msaccess

Type
msaccess
 Click OK Button or press the enter key

msomibora.com Microsoft Access 15


Starting Microsoft Access
 4rd Option
 Click once the program-Icon which is on
your desktop

 Press the Enter Key

msomibora.com Microsoft Access 16


Starting Microsoft Access
 Access program appears and the task pane
displays options for an existing database or
creating a new database, as shown below

 Click the Open button on the toolbar.


msomibora.com Microsoft Access 17
The Microsoft Access screen

msomibora.com Microsoft Access 18


The Microsoft Access screen
 Title bar
 Displays the name of the program you are
currently using (in this case, Microsoft Access).
The title bar appears at the top of all Windows
programs.

msomibora.com Microsoft Access 19


The Microsoft Access screen
 Menu bar
 Displays a list of menus you use to give
commands to Access.
 Clicking a menu name displays a list of
commands
 For example, clicking the Edit menu name would
display different formatting commands.

msomibora.com Microsoft Access 20


The Microsoft Access screen
 Toolbar
 Toolbars are short cuts they contain buttons for
the most commonly used commands (instead of
having to wade through several menus).
 The toolbars in Access change depending on
what you are working on.
 The database toolbar (the toolbar currently
displayed) contains buttons for the Access
commands that you will use most often, such as
opening and printing databases.

msomibora.com Microsoft Access 21


The Microsoft Access screen
 Database window
 The command center for a database, the
Database window, allows you to view, create,
edit, and modify database objects.

msomibora.com Microsoft Access 22


The Microsoft Access screen
 Objects bar
 The Objects bar categorizes the different types
of database objects.
 Each type of database object has its own icon to
view a type of object, click its icon on the
Objects bar.

msomibora.com Microsoft Access 23


The Microsoft Access screen
 Database objects
 Database objects are the basic components that
make up a database.
 Database objects include tables, queries, forms,
reports, pages, macros, and modules.

msomibora.com Microsoft Access 24


The Microsoft Access screen
 Status bar
 Displays messages and feedback.
 The Status bar is especially important in Access
since it can give you meaningful information and
messages when you are entering information
into a database.

msomibora.com Microsoft Access 25


Menus Found in Microsoft Access
 File
 File-related commands to open, close, print, and
create new files.
 Edit
 Commands to copy, cut, paste, find, and replace
text.
 View
 Commands to change how the screen is
displayed.

msomibora.com Microsoft Access 26


Menus Found in Microsoft Access
 Insert
 Items that you can insert into a database, such
as graphics and charts.
 Format
 Commands to format fonts, cell alignment, and
borders.
 Records
 Commands to add, delete, sort, and filter
information.

msomibora.com Microsoft Access 27


Menus Found in Microsoft Access
 Tools
 Tools such as the spell checker and macros. You
can also change the default options for Microsoft
Access here.
 Window
 Commands to display and arrange multiple
windows (if you have more than one file open).
 Help
 Provides help with using Microsoft Access.

msomibora.com Microsoft Access 28


Database Components
 An Access database consists of several
different components. Each component
listed is called an object.
 Listed below are the names and descriptions
of the different objects you can use in
Access. In this program you will learn more
about:
 Tables
 Queries
 Forms
 Reports.
msomibora.com Microsoft Access 29
Database Components
 Tables:
 tables are where the actual data is defined and
entered. Tables consist of records (rows) and
fields (columns).

msomibora.com Microsoft Access 30


Database Components
 Queries:
 queries are basically questions about the data in
a database.
 A query consists of specifications indicating
which fields, records, and summaries you want
to see from a database.
 Queries allow you to extract data based on the
criteria you define.

msomibora.com Microsoft Access 31


Database Components
 Forms:
 forms are designed to ease the data entry
process. For example, you can create a data
entry form that looks exactly like a paper form .
People generally prefer to enter data into a well-
designed form, rather than a table.

msomibora.com Microsoft Access 32


Database Components
 Reports:
 when you want to print records from your
database, design a report. Access even has a
wizard to help produce mailing labels.

msomibora.com Microsoft Access 33


Database Components
 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. This data is
stored in a Microsoft Access database or a
Microsoft SQL Server database.

msomibora.com Microsoft Access 34


Database Components
 Macros:
 a macro is a set of one or more actions that
each performs a particular operation, such as
opening a form or printing a report. Macros can
help you automate common tasks. For example,
you can run a macro that prints a report when a
user clicks a command button.

msomibora.com Microsoft Access 35


Database Components
 Modules:
 a module is a collection of Visual Basic for
Applications declarations and procedures that
are stored together as a unit.

msomibora.com Microsoft Access 36


Creating a new database
 To create a new database, choose Blank
Database and specify a new file name for
the database.
 Click on the OK button to create the new
database.

msomibora.com Microsoft Access 37


Open an Existing Database
 To open an existing database:
 Choose Open an Existing Database
 highlight More Files...
 click on the OK button
 To exit Access:
 Choose the File menu
 Click Exit

msomibora.com Microsoft Access 38


Exercise 2
 List down the Database components

msomibora.com Microsoft Access 39


msomibora.com Microsoft Access 40
Tables
 Tables are the main units of data storage in
Access.
 A table is made up of one or more columns
(or fields) and that a given column may
appear in more than one table in order to
indicate a relationship between the tables.

msomibora.com Microsoft Access 41


Creating Tables
 For example we want to create the business
database we conclude that two tables
would be sufficient to store the data about
Customers and their bank Accounts.

msomibora.com Microsoft Access 42


Creating Tables
 There are a number of ways to create a table
in Access.
 Access provides wizards that guide the user
through creating a table by suggesting
names for tables and columns.
 The other main way to create a table is by
using the Design View to manually define the
columns (fields) and their data types.

msomibora.com Microsoft Access 43


Creating Tables
 While using the wizards is a fast way to
create tables, the user has less control over
the column names (fields) and data types.

 In this lesson, we will describe the steps to


create a table using the Design View.

 You will experiment on your own with using


the Create Table wizard.

msomibora.com Microsoft Access 44


Creating a Table Using the Design View
 To create a table in Access using the Design View
 Make sure the Tables tab is clicked and perform the
following steps:

 Double click on Create Table in Design view

msomibora.com Microsoft Access 45


Table Design View
 The Table Design View will appear. Fill in the
Field Name, Data Type and Description for
each column/field in the table.

msomibora.com Microsoft Access 46


Table Design View

Note that the default name given for the table is Table1

msomibora.com Microsoft Access 47


Table Design View
 In a later step, we will assign an appropriate
name for this table.
 Fill in the information for the fields as follows:
Field Name Data Type Description
CustomerID Number The Unique Identifier for a
Customer

Name Text The Name of the Customer

Address Text The Address of the Customer

City Text The City of the Customer

State Text The home State of the Customer

Zip Text The Zip Code of the Customer

msomibora.com Microsoft Access 48


Table Design View
 A figure below showing the design view with
the new table definition filled in

msomibora.com Microsoft Access 49


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 identifies
each record stored in the table.

msomibora.com Microsoft Access 50


Primary keys
 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.

 There are three kinds of primary keys that


can be defined in Microsoft Access:
AutoNumber, single-field, and multiple-field.
msomibora.com Microsoft Access 51
Primary keys
 AutoNumber primary keys
 An AutoNumber field can be set to automatically

enter a sequential number as each record is


added to the table.
 Designating such a field as the primary key for a

table is the simplest way to create a primary key.


 If you don't set a primary key before saving a

newly created table, Microsoft Access will ask if


you want it to create a primary key for you.
 If you answer Yes, Microsoft Access will create

an AutoNumber primary key.

msomibora.com Microsoft Access 52


Primary keys
 Single-field primary keys
 If you have a field that contains unique values

such as ID numbers or part numbers, you can


designate that field as the primary key.

msomibora.com Microsoft Access 53


Primary keys
 Multiple-field primary keys
 In situations where you can't guarantee
the uniqueness of any single field, you
may be able to designate two or more
fields as the primary key.
 The most common situation where this

arises is in the table used to relate two


other tables in a many-to-many
relationship

msomibora.com Microsoft Access 54


Inserting a Primary keys
 Click on the CustomerID field with the
Right mouse button
 Choose Primary Key from the pop-up menu.

OR
 Click the Edit Menu

 select Primary Key

OR
 Click the Primary Key Icon on the Toolbar

msomibora.com Microsoft Access 55


Inserting a Primary keys

Notice that a small key appears next to the field name on the left side.
Note: To remove a primary key, simply repeat this procedure to toggle the primary
key off.
msomibora.com Microsoft Access 56
Saving a Table
 As a final step, the table must be saved.
 Click the File menu
 Choose the Save command.

msomibora.com Microsoft Access 57


Saving a Table
 A dialog box will appear where the name of the
new table should be specified. Note that Access
gives a default name such as Table1 or
Table2. Simply type over this default name with
the name of the table you prefer . For this
example, name the table: Customer

Click on the OK button.


msomibora.com Microsoft Access 58
Closing a Table
 At this point, the new Customer table has
been created and saved.
 Switch back to the Access main screen by
pulling down the File menu and choosing the
Close menu item.
 This will close the Design View for the table
and display the Access main screen.

msomibora.com Microsoft Access 59


Closing a Table
 Notice that the new Customer table
appears below the Table tab.

msomibora.com Microsoft Access 60


Field names
 When defining the fields (columns) for a
table, it is important to use field names that
give a clear understanding of the data
contents of the column. For example, does
the field CNO indicate a Customer Number
or a Container Number ?
 Field names in Access can be up to 64
characters long and may contain spaces.
However, the use of spaces in field
names and table names is strongly
discouraged.
msomibora.com Microsoft Access 61
Field names
 If you wish to make field names easier to
read, consider using an underscore character
to separate words. However be certain no
spaces appear before or after the
underscore.
 The following table summarizes some
different ways to give field names:
 (See the next slide)

msomibora.com Microsoft Access 62


Field names
Description Bad Good

Unique identifier CID CustomerID or


for a customer Customer_ID
Description for a PDESC ProductDescripti
product on
Employee's Employee_home HomePhone
home telephone _telephone_num
number ber
Bank account BA# AccountNumber
number

msomibora.com Microsoft Access 63


Exercise 3: Creating a Table
 Create the Accounts table by following the
same steps used to create the Customer
table.
 Click on the New button and highlight Design
View in the dialog box that appears. Then
click on the OK button.
 The Table Design View will appear. Fill in the
Field Name, Data Type and Description for
each column/field in the Accounts table as
shown in the next slide.
msomibora.com Microsoft Access 64
Exercise 3 Cont…….
Field Name Data Type Description

CustomerID Number The Unique Identifier for a


Customer

AccountNumber Number The Unique Identifier for a


Bank Account

AccountType Text The type of account


(Checking, savings, etc.)

DateOpened Date The date the account was


opened

Balance Number The current balance


(money) in this account (in
$US)

msomibora.com Microsoft Access 65


Exercise 3 Cont…….
 After finishing your design view with the
new table definition filled in will look like
the figure below:

msomibora.com Microsoft Access 66


Exercise 3 Cont….
 Define a Primary Key for the Accounts table.
on the AccountNumber field.
 Save the new Accounts table with the File
name Accounts.

msomibora.com Microsoft Access 67


Viewing and Adding Data to a Table
 Data can be added, deleted or modified in
tables using a simple spreadsheet-like
display.
 To bring up this view of a single table's data,
highlight the name of the table and then click
on the Open button.
 In this view of the table, shown in the next
slide the fields (columns) appear across the
top of the window and the rows or records
appear below. This view is similar to how a
spreadsheet would be designed.
msomibora.com Microsoft Access 68
Viewing and Adding Data to a Table

Note at the bottom of the window the number of records is displayed. In this
case, since the table was just created, only one blank record appears.

msomibora.com Microsoft Access 69


Viewing and Adding Data to a Table
 To add data to the table, simply type in
values for each of the fields (columns).
 Press the Tab key to move between fields
within a record.
 Use the up and down arrow keys to move
between records.
 Enter the data as given in the next slide

msomibora.com Microsoft Access 70


Viewing and Adding Data to a Table
CustomerID Name Address City State Zip

1001 Name Mr. 123 Lexington Smithville KY 91232


Smith

1002 Mrs. Jones 12 Davis Ave. Smithville KY 91232

1003 Mr. Axe 443 Grinder Ln. Broadville GA 81992

1004 Mr. & Mrs. . 661 Parker Rd. Streetville GA 81990


Builder

msomibora.com Microsoft Access 71


Viewing and Adding Data to a Table

msomibora.com Microsoft Access 72


saving the new data
 Click the File menu
 Choose Save

msomibora.com Microsoft Access 73


Navigate to other records in the table

 To navigate to other records in the table, use


the navigation bar at the bottom of the
screen

msomibora.com Microsoft Access 74


Modifying existing data
 Simply navigate to the record of interest and
tab to the appropriate field.
 Use the arrow keys and the delete or
backspace keys to change the existing data

msomibora.com Microsoft Access 75


Deleting a record
 First navigate to the record of interest.
 Click the Edit menu
 Click Delete

msomibora.com Microsoft Access 76


Closing the table
 Return to the Access main screen
 Click the File menu
 Close.

msomibora.com Microsoft Access 77


Exercise 4: Adding Data to a Table
 For this exercise, open up the Accounts table
and add data for the seven accounts table

 Be sure to enter the data exactly as shown


including the capitalization of the data in the
AccountType field. e.g., type Savings instead
of savings or SAVINGS.

msomibora.com Microsoft Access 78


Exercise 4 Cont…….
 When entering the dates, type in the full
four digits for the year
 By default, Access only displays the last two
digits of the year; however, all four digits are
stored in the table
 Save the data when you are done
 The figure in the next slide shows the
Accounts table and data as it should appear
when you are done with this exercise.

msomibora.com Microsoft Access 79


Exercise 4 Cont…….

msomibora.com Microsoft Access 80


Creating Relationships Between tables
 Recall that one of the main characteristics of
relational databases is the fact that all tables are
related to one another.
 In the Bank database thus far, the Customers table
is related to the Accounts table by virtue of the
CustomerID field appearing in both tables.
 Access has a means to make this relationship
explicit using the Relationships screen.
 Access uses this information when designing
reports, forms and queries that require more than
one table to be displayed

msomibora.com Microsoft Access 81


Creating Relationships
 Click the Tools menu
 Select Relationships
 The blank Relationships screen will appear
as follows (See next Slide)

msomibora.com Microsoft Access 82


Creating Relationships

msomibora.com Microsoft Access 83


Creating Relationships
 The next step is to
display all of the tables
on the relationships
screen.

 Right click anywhere


on the Relationships
screen and select the
Show Tables... option
from the pop-up menu:

msomibora.com Microsoft Access 84


Creating Relationships
 When the Show Table
dialog box appears,
highlight both the
Customers table and
the Accounts table as
shown
 Then click on the Add
button
 Click on the Close
button

msomibora.com Microsoft Access 85


Creating Relationships
 The Relationships
screen will now
reappear with the two
tables displayed as
shown

msomibora.com Microsoft Access 86


Creating Relationships
 To connect the Customers table with the
Accounts table to form a relationship
 Click on the CustomerID field in the Customers
table and drag it over on top of the CustomerID
field on the Accounts table.
 Upon releasing the mouse button, the Edit
Relationships dialog box will appear as shown on
the next slide

msomibora.com Microsoft Access 87


Creating Relationships

Access will do its best to determine the Relationship Type (almost


always One-to-Many).

msomibora.com Microsoft Access 88


Creating Relationships
 For this example, Access knows that
CustomerID is a key of the Customer table
so it chooses this field as the "One" side.
This makes the Accounts table the "Many"
side as One customer may have Many
accounts
 One additional step to be taken is the check
off the box labeled "Enforce Referential
Integrity

msomibora.com Microsoft Access 89


Creating Relationships
 This option puts constraints into effect such
that an Accounts record can not be created
without a valid Customer and Access will
also prevent a user from deleting a
Customer record if a related Accounts record
exists.
 At this point, click on the Create button to
create the relationship.
 The Relationships screen should reappear
with the new relationship in place as follows:
msomibora.com Microsoft Access 90
Creating Relationships

msomibora.com Microsoft Access 91


Creating Relationships
 Note the symbols "1" (indicating the "One"
side) and the infinity symbol (indicating the
"Many" side) on the relationship.
 Close the relationships screen
 Select Yes to save the changes to the
Relationships layout

msomibora.com Microsoft Access 92


Creating and Viewing Tables
 Click on the Tables tab on the Access main
screen
 Click on the New button.
 Choose the Design View and click the OK
button.
 Fill in the name, data type and description
of each of the fields in the table.

msomibora.com Microsoft Access 93


Creating and Viewing Tables
 Designate a primary key by clicking on one
of the fields with the right mouse button and
then choose Primary Key from the pop-up
menu.
 Save the table by pulling down the File
menu and choosing Save.
 Close the new table by pulling down the File
menu and choosing Close

msomibora.com Microsoft Access 94


To change the design of an existing table

 Click on the Tables tab on the Access


main screen
 Highlight the name of the table to be
modified and click on the Design button.
 Make the necessary changes.
 Save the table by pulling down the File
menu and choosing Save.
 Close the table by pulling down the File
menu and choosing Close

msomibora.com Microsoft Access 95


Add, delete or change data in an existing table

 Click on the Tables tab on the Access


main screen
 Highlight the name of the table to be
modified and click on the Open button.
 Make the necessary changes to the data.
 Save the table data by pulling down the
File menu and choosing Save.
 Close the table by pulling down the File
menu and choosing Close

msomibora.com Microsoft Access 96


To create or edit relationships between tables

 Pull down the Tools menu and select the


Relationships menu item.
 To display tables, right click and choose Add
Tables
 To create new relationships, drag a key field from
one table and drop it on the associated field in
another table
 To edit an existing relationship, double click on
the relationship line.
 To delete an existing relationship, click on the
relationship line and press the delete key
msomibora.com Microsoft Access 97
msomibora.com Microsoft Access 98
Creating and Running Queries
 Queries are a fundamental means of
accessing and displaying data from tables.
 Queries can access a single table or multiple
tables. Examples of queries for our bank
database might include:
 Which Customers live in Georgia ?
 Which Accounts have less than a $500 balance ?
 In this section, we show how to use the
Access Wizards to create queries for a single
table and for multiple tables

msomibora.com Microsoft Access 99


Single Table Queries
 In this section, we will demonstrate how to query a
single table.
 Single table queries are useful to gain a view of the
data in a table that:
 only displays certain fields (columns) in the

output
 sorts the records in a particular order

 performs some statistics on the records such as

calculating the sum of data values in a column


or counting the number of records

msomibora.com Microsoft Access 100


Single Table Queries

 Creating a query can be accomplished by


using either the query design view or the
Query wizard. In the following example, we
will use the query wizard to create a query.

 Queries are accessed by clicking on the


Queries tab in the Access main screen as
shown on the figure in the next slide

msomibora.com Microsoft Access 101


Single Table Queries

msomibora.com Microsoft Access 102


Creating a new query(Using Wizard)
 To create a new query
 Click on the New button. The New Query
menu will appear
 Select the Simple Query wizard option
 Click the OK button.

msomibora.com Microsoft Access 103


Creating a new query (Using Wizard)

msomibora.com Microsoft Access 104


Creating a new query (Using Wizard)

 The first step in the Simple Query wizard is


to specify the table for the query and which
fields (columns) should be displayed in the
query output. Three main sections of this
step are:
 Tables/Queries - Pick a list of tables or queries
you have created.
 Available Fields - Those fields from the table that
can be displayed.
 Selected Fields - Those fields from the table that
will be displayed.

msomibora.com Microsoft Access 105


Creating a new query (Using Wizard)

 For this example, pull down the


Tables/Queries list and choose the Customer
table.
 Notice that the available fields change to list
only those fields in the Customer table. This
step is shown on the next slide

msomibora.com Microsoft Access 106


Creating a new query (Using Wizard)

msomibora.com Microsoft Access 107


Creating a new query (Using Wizard)

 From the list of Available


fields on the left, move the
Name, Address, City and
State fields over to the
Selected Fields area on the
right.
 Highlight one of the fields
and then click on the right
arrow button in the center
between the two areas.

 Repeat this for each of the


four fields to be displayed.
When done with this step,
the wizard should appear
as shown in the next slide

msomibora.com Microsoft Access 108


Creating a new query (Using Wizard)

msomibora.com Microsoft Access 109


Creating a new query (Using Wizard)

 Click on the Next button to move to the next and


final step in the Simple Query wizard.
 In the final step, give your new query a name. For
this example, name the query: Customer Address
 At this point, the wizard will create the new query
with the option to either:
 Open the query to view information - that is, the wizard
will execute the query and show the data.
 Modify the query design - the wizard will switch to the
Design View to allow further modification of the query

msomibora.com Microsoft Access 110


Creating a new query (Using Wizard)

msomibora.com Microsoft Access 111


Creating a new query (Using Wizard)

 For this example, choose Open the query to


view information and click on the Finish
button.
 When this query executes, only the
customer's name, address, city and state
fields appear, however, all of the rows
appear as shown in the figure (Next slide)

msomibora.com Microsoft Access 112


Creating a new query (Using Wizard)

msomibora.com Microsoft Access 113


Creating a new query (Using Wizard)

 Close this query by pulling down the File


menu and choosing the Close menu item.

 The Access main screen showing the Queries


tab should appear. Note the new query
CustomerAddress appears under the Queries
tab.

msomibora.com Microsoft Access 114


Modifying the query
 In the following example, we will modify the
CustomerAddress query to only display
customers in a certain state. To accomplish
this, we will make use of the Query Design
View.
 Open up the CustomerAddress query in the
design view by highlighting the name of the
query and clicking on the Design button. The
design view will appear as in the figure
below
msomibora.com Microsoft Access 115
Modifying the query

msomibora.com Microsoft Access 116


Modifying the query
 The Query Design view
has two major
sections.
 In the top section, the
table(s) used for the
query are displayed
along with the
available fields. In the
bottom section, those
fields that have been
selected for use in the
query are displayed.

msomibora.com Microsoft Access 117


Modifying the query
 Each field has several options
associated with it:
 Field - The name of the field from the table
 Table - The table the field comes from
 Sort - The order in which to sort on this field
(Ascending, Descending or Not Sorted)
 Show - Whether or not to display this field in the
query output
 Criteria - Indicates how to filter the records in
the query output.

msomibora.com Microsoft Access 118


Modifying the query
 For this example, we will filter the records to
only display those customers living in the
State of Georgia (GA). We will also sort the
records on the City field.
 To sort the records on the City field, click in
the Sort area beneath the City field.
 Choose Ascending from the list as shown in
the figure below:

msomibora.com Microsoft Access 119


Sorting the query

msomibora.com Microsoft Access 120


To filter the output to display Customers in Georgia only

 click in the Criteria


area beneath the
State field and type
the following
statement:
= 'GA'

msomibora.com Microsoft Access 121


To filter the output to only display Customers in Georgia

 The = 'GA' statement tells Access to only


show those records where the value of the
State field is equal to 'GA'.
 Run the query by
 clicking the Query menu
 choose the Run command
 The output is shown in the figure in the next
slide

msomibora.com Microsoft Access 122


To filter the output to only display Customers in Georgia

Finally, save and close this query to return to the Access main
screen
msomibora.com Microsoft Access 123
Exercise 5: Single Table Queries
 For this exercise, use the Simple Query wizard to
create a query on the Accounts table showing just
the AccountNumber, AccountType and Balance
fields.

 From the Access main screen, click on the Queries


tab. Then click on the New button.

 Choose the Simple Query wizard option and click


on the OK button.

msomibora.com Microsoft Access 124


Exercise 5: Single Table Queries
 Under Table/Queries: choose the Accounts table.
Then move the AccountNumber, AccountType and
Balance fields over to the Selected fields area.
Then click the Next button.

 In the next panel, you will be asked to choose


between a detail or summary query. Choose
detailed query and click on the Next button.

 Name the new Query : AccountsQuery and click on


the Finish button.

msomibora.com Microsoft Access 125


Exercise 5 Cont….
 The output is shown
below

msomibora.com Microsoft Access 126


Exercise 5 Cont….
 Close this query by pulling down the File menu and
choose Close.
 In the next part of the exercise, we will modify the
query to sort the output on the account number
and only display the Savings accounts.
 From the Queries tab on the Access main screen,
highlight the AccountsQuery and click on the
Design button.
 Change the Sort order for the AccountNumber
field to Ascending.
Add the following statement to the Criteria: are
under the AccountType field:
= 'Savings'

msomibora.com Microsoft Access 127


Exercise 5 Cont….

Run the query by clicking the Query menu and choose Run
command. The output is shown on the next slide

msomibora.com Microsoft Access 128


Exercise 5 Cont….

Finally, save and close the query to return to the Access main
screen

msomibora.com Microsoft Access 129


Multiple Table Queries
 Up to this point, queries involving only one
table have been demonstrated. It is almost a
given that queries will need to involve more
than one table.
 For this example, assume that a manager
would like to see a list of all of the
customers and the type of account(s) that
each one maintains at the bank. Such a
query requires data from both the
Customers table as well as the Accounts
table.
msomibora.com Microsoft Access 130
Multiple Table Queries
 In such queries, Access will rely on the
Relationships established between tables to
guide how the data will be assembled to
satisfy the query.

 Before proceeding with these next


instructions, make certain the One-to-Many
relationship between the Customers and
Accounts table has been created before

msomibora.com Microsoft Access 131


Multiple Table Queries
 To start the process of creating a multiple table
query
 Click the Query tab
 Click on the New button to create a new query.
 Select the "Simple Query Wizard" option as was done
previously.
 When the simple query wizard appears
 Select the CustomerID and Name fields from the
Customers table
 Then switch the Tables/Queries selection to the Accounts
table and select the CustomerID, AccountType and
Balance fields from the Accounts table
 The result from this step is down below

msomibora.com Microsoft Access 132


Multiple Table Queries

msomibora.com Microsoft Access 133


Multiple Table Queries
 Click the Next button to continue. In the
next step of the wizard, an option will
appear to provide some level of Summary.

 For this example, leave the default at


"Detail ..." as shown in the next slide and
then click on the Next button

msomibora.com Microsoft Access 134


Multiple Table Queries

msomibora.com Microsoft Access 135


Multiple Table Queries
 In the final step of the wizard, name the
query "Customer Accounts Query"

 Click on the Finish button. The multiple table


query results should appear as in the next
slide

msomibora.com Microsoft Access 136


Multiple Table Queries

msomibora.com Microsoft Access 137


Multiple Table Queries
 As with single table queries demonstrated
previously, one can change the query
definition in design view by adding filters
(e.g., show account information for all
customers in 'GA').

msomibora.com Microsoft Access 138


Exercise 6: Multiple Table Queries
 For this exercise, create a new query called
"Accounts Summary Query" that joins the
Cusomers table (include the CustomerID and
Name fields) with the Accounts table
(include the Balance field only).
 In the second step of the wizard, click on
the Summary choice (instead of Details) and
then click on the Summary Options... button.
Check all of the Summary option boxes such
as Sum, AVG, Min and Max as shown in
the figure in the next slide
msomibora.com Microsoft Access 139
Exercise 6 Cont….

msomibora.com Microsoft Access 140


Exercise 6 Cont….
 The resulting query should appear as follows

msomibora.com Microsoft Access 141


Creating and Running Queries
 In this section, the basic steps for creating and
running queries were introduced.
 The query wizard can be used to create simple
queries that access a single table.
 It is also possible to then modify the query to sort
or filter the records.

msomibora.com Microsoft Access 142


Summary Creating and Running Queries
 Creating a query using the query wizard:
 From the Access main screen, click on the Queries tab. Then click
on the New button.
 From the Queries tab on the main Access screen, click on the New
button and choose the Simple Query wizard option.
 Under Table/Queries: choose the appropriate table for the query and
then indicate which fields in the table will appear in the query
output.
 If querying more than one table, change the Table/Queries:
selection to display additional tables and select the necessary fields.
 If the table contains numeric fields, either detailed or summary
information may be specified for the query.
 Finally, name the new query and click on the Finish button.

msomibora.com Microsoft Access 143


msomibora.com Microsoft Access 144
Creating and Running a Data Entry Form
 Data entry forms are the primary means of
entering data into tables in the database. In a
previous section, we described how to add data to
a table using a spreadsheet-like view of the data.
Data entry forms offer a more user-friendly
interface by adding labels for each field and other
helpful information.
 Access provides several different ways of creating
data entry forms. These include creating the forms
by hand using a Design View as well as a number
of wizards that walk the user through the forms
creation process. In this section, we cover the
basic steps for using a wizard to create a data
entry form.

msomibora.com Microsoft Access 145


Creating a Single Table Form using the Wizard
 In this example, we will create a simple data entry
form for the Customer table. To begin the process,
click on the Forms tab on the Access main screen. As
with the other components in Access, there are
buttons for creating a New form, Open an existing
form and Design an existing form. For this example,
click on the New button to create a new form.

 A New Form dialog box will appear with several


options for creating a new form. For this tutorial,
choose the Form wizard. At the bottom of the dialog
box, there is a prompt to supply the name of the
table or query to be used for the new form. In this
case, select the Customer table as in the following
figure and then click on the OK button
msomibora.com Microsoft Access 146
Creating a Single Table Form using the Wizard

msomibora.com Microsoft Access 147


Creating a Single Table Form using the Wizard

 In the next step of the Form wizard, we


need to specify the fields from the Customer
table that will appear on the form.
 In this case, we want all of the fields to
appear.
 Move each of the fields from the Available
Fields side over to the Selected Fields side
as in the following figure.
 Then click on the Next button

msomibora.com Microsoft Access 148


Creating a Single Table Form using the Wizard

msomibora.com Microsoft Access 149


Creating a Single Table Form using the Wizard

 Forms can have several different layouts or


arrangement of the labels and fields on the
screen.
 Columnar - Places the labels to the left of each
field. This is similar to a paper form. This layout is
suitable for viewing data one record at a time.

 Tabular - Places the field labels at the top of the


screen and the records are displayed below. This
is similar to how a spreadsheet would display the
data and is suitable for displaying multiple
records of data at a time.

msomibora.com Microsoft Access 150


Creating a Single Table Form using the Wizard

 Datasheet - The data appears in the same fashion


as when viewing or adding data to a table.
 Justified - Places the labels above each field with
the fields spread out on the form. This is suitable
for viewing a single record at a time as with the
columnar layout.

 For this example, choose the columnar layout as


shown in the figure below and click on the Next
button.

msomibora.com Microsoft Access 151


Creating a Single Table Form using the Wizard

msomibora.com Microsoft Access 152


Creating a Single Table Form using the Wizard

 Access has several sample display styles that


determine how the form will appear,
including elements such as fonts, colors and
the background used in the form.

 For this example, select the Standard style


as shown in the next slide and click on the
Next button

msomibora.com Microsoft Access 153


Creating a Single Table Form using the Wizard

msomibora.com Microsoft Access 154


Creating a Single Table Form using the Wizard

 As a final step, give this new form the name:


 CustomerDataEntry

 Then click on the Finish button as shown in


the next slide

msomibora.com Microsoft Access 155


Creating a Single Table Form using the Wizard

msomibora.com Microsoft Access 156


Creating a Single Table Form using the Wizard

 The new form will be created by the wizard and


then opened. It should appear as in the figure
below

msomibora.com Microsoft Access 157


Navigate between fields/records
 Use the tab key to navigate between fields in the
form.
 To move to the next or previous record, use the
record navigation bar at the bottom of the form

Previous Record Next Record

msomibora.com Microsoft Access 158


Navigate between records
 The buttons on the navigation
bar perform the following
functions:

 Go to the first record.


Go to the previous record.
Go to the next record.
Go to the last record.
Go past the last record to add a
new record.
 To close the form and return to
the Access main screen, pull
down the File menu and choose
Close.
 To open the form at any time,
highlight the form name under
the Forms tab on the Access
main screen and click on the
Open button

msomibora.com Microsoft Access 159


Close/Open the Form
 To close the form and return to the Access
main screen
 Click the File menu
 Choose Close.
 To open the form at any time
 Highlight the form name under the Forms tab on
the Access main screen
 Click on the Open button

msomibora.com Microsoft Access 160


Exercise 7: Creating a Single Table Form
 For this exercise, we will create a data entry
form for the Accounts table created in a
previous exercise.
 Click on the Forms tab on the Access main
screen and then click on the New button to
create a new form.
 Select the Form wizard
 Select the Accounts table.
 Click the OK button.
 Select all of the available fields and click on the
Next button.

msomibora.com Microsoft Access 161


Exercise 7 Cont……
 Choose a Tabular layout and click on the Next
button.
 Choose the Standard style and click on the Next
button.
 Name the form: AccountsDataEntry
Then click on the Finish button to create,
save and view the new form.
 The new form is shown in the next slide

msomibora.com Microsoft Access 162


Exercise 7 Cont……

Close the form and return to the Access main screen, by pulling
down the File menu and choosing Close

msomibora.com Microsoft Access 163


Review of Creating a Form
 The basic steps for creating a simple data
entry form are:
 Choose a table and a form wizard
 Specify the fields (columns) that will appear
in the form
 Specify the layout for the form
 Specify the style (fonts/colors, etc.) for the
form
 Save, create and run the new form
msomibora.com Microsoft Access 164
Review of Creating a Form
 In this section we covered the basic steps
required to create and run a data entry
form.
 Access provides wizards which are adept at
building simple forms with a minimal amount
of work.

msomibora.com Microsoft Access 165


msomibora.com Microsoft Access 166
Creating and Running a Report
 Reports are similar to queries in that they
retrieve data from one or more tables and
display the records.
 Unlike queries, however, reports add
formatting to the output including fonts,
colors, backgrounds and other features.
Reports are often printed out on paper rather
than just viewed on the screen.
 In this section, we cover how to create
simple reports using the Report wizard.
msomibora.com Microsoft Access 167
Creating a Report
 In this example, we will create a simple
report for a single table using the Report
wizard.
 As with the Queries and Forms, we begin by
selecting the Reports tab from the Access
main screen.

msomibora.com Microsoft Access 168


Creating a Report (Using Report Wizard)

 To create a new report


 Click on the New button.
 The New Report dialog box will appear as
shown below.
 Select the Report wizard and then select the
Customer table as shown on the next slide.
 Then click the OK button.

msomibora.com Microsoft Access 169


Creating a Report

msomibora.com Microsoft Access 170


Creating a Report
 In the next step of the Report wizard, we
need to specify the fields from the Customer
table that will appear on the report.
 In this case, we want all of the fields to
appear.
 Move each of the fields from the Available
Fields side over to the Selected Fields side
as in the figure in the next slide.
 Then click on the Next button.

msomibora.com Microsoft Access 171


Creating a Report

msomibora.com Microsoft Access 172


Creating a Report
 In the next step, we have the opportunity to
add Grouping Levels to the report.
 A grouping level is where several records
have the same value for a given field and we
only display the value for the first records.
 In this case, we will not use any grouping
levels so simply click on the Next button as
shown in the next slide.

msomibora.com Microsoft Access 173


Creating a Report

msomibora.com Microsoft Access 174


Creating a Report
 In the next step, we are given the opportunity
to specify the sorting order of the report.
 For this example, we will sort the records on
the CustomerID field.
 To achieve this,
 Click the down arrow in the list box next to
the number 1 box
 Choose the CustomerID field as shown in
the figure next slide.
 Then click on the Next button.

msomibora.com Microsoft Access 175


Creating a Report

msomibora.com Microsoft Access 176


Creating a Report
 The next step is to specify the layout of the
report. The three options are:
 Columnar - Places the labels to the left of each
field. This is similar to a paper form.
 Tabular - Places the field labels at the top of the
report page and the records are displayed
below. This is similar to how a spreadsheet
would display the data.

msomibora.com Microsoft Access 177


Creating a Report
 Justified - Places the labels above each field with
the fields spread out on the report page.
 Generally, reports use the tabular layout.
 For this example
 Choose Tabular layout and set the page
Orientation to Landscape so that all of the fields
will fit across one page.
 This is shown in the figure next slide.
 Click on the Next button to continue.

msomibora.com Microsoft Access 178


Creating a Report

msomibora.com Microsoft Access 179


Creating a Report
 In the next step, the style of the report can
be selected.
 For this example
 Choose the Corporate style
 Click on the Next button to continue.

msomibora.com Microsoft Access 180


Creating a Report

msomibora.com Microsoft Access 181


Creating a Report
 Finally, give a name for the new report:
CustomerReport and then click on the Finish
button to create, save and display the new
report.

msomibora.com Microsoft Access 182


Creating a Report

msomibora.com Microsoft Access 183


Creating a Report
 The output from the report is shown in the
figure next slide.
 Note that on some screens, the last field,
Zip, may not display without scrolling over to
the right.

msomibora.com Microsoft Access 184


Creating a Report

msomibora.com Microsoft Access 185


Creating a Report
 Once the report is displayed, it can be
viewed, printed or transferred into Microsoft
Word or Microsoft Excel.

msomibora.com Microsoft Access 186


Creating a Report
 To close the report and return to the Access
main screen, pull down the File menu and
choose Close or click on the Close button.

msomibora.com Microsoft Access 187


Exercise 8 creating a Report
 For this exercise, we will create a report showing
all of the Accounts information.
 1. From the Reports tab on the Access main
screen, click on the New button.
 2. Select the Report wizard, select the Accounts
table and then click the OK button.
 3. Select all of the fields in the Accounts table by
moving them all over to the Selected Fields side
and then click Next
 4. Group the report by CustomerID by clicking on
the CustomerID field and then clicking on the right
arrow button. This is shown in the figure in the next
slide
msomibora.com Microsoft Access 188
Exercise 8 Cont……

Choose to sort the report on the AccountNumber field. Note


that a new button will appear called Summary Options.

msomibora.com Microsoft Access 189


Exercise 8 Cont……

msomibora.com Microsoft Access 190


Exercise 8 Cont……
 Click on the Summary Options button.
 Choose the Balance field and select the Sum
option.
 Choose the option to show both Detail and
Summary data.
 Then click on the OK button.

msomibora.com Microsoft Access 191


Exercise 8 Cont……

Click on the Next button.

msomibora.com Microsoft Access 192


Exercise 8 Cont……
 1. Choose a Block layout and click on the
Next button.
 2. Choose the Corporate style and the
click on the Next button.
 3. Finally, name the report:
AccountsReport and click on the Finish
button to create, save and run the report.
 The output from the AccountsReport is
shown in the next slide

msomibora.com Microsoft Access 193


Exercise 8 Cont……

msomibora.com Microsoft Access 194


Exercise 8 Cont……
 Note the Grouping at the level of the
CustomerID and the Sum for each
customer's balances.
 To close the report and return to the Access
main screen, pull down the File menu and
choose Close.

msomibora.com Microsoft Access 195


Review of Creating and Running a Report

 As can be seen in the report exercise, there


are many ways to create reports to show
summarization, sorting and layout of the
data.
 Further study of Reports will show how to
modify the layout using the Design View.
Students are encouraged to work with the
Report wizards to create different styles and
types of reports.

msomibora.com Microsoft Access 196


Summary
 In this Lesson, we have covered the basics
for creating an Access database including
tables with data, queries to retrieve data,
forms to enter data and reports to display
and summarize data.
 Students are encouraged to further their
Access knowledge and skills by working
through more advanced Lessons and by
reading the on-line help and Access
documentation
msomibora.com Microsoft Access 197
Thank you for listening

Training Department
[email protected]

198
msomibora.com

You might also like