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

Ict 141 Notes

This document provides an introduction to databases, including: - Databases organize collected information for easy access, management, and updating. - Common database types are flat databases, relational databases, and database management systems (DBMS). - Key characteristics of DBMS include using real-world entities, relation-based tables, isolation of data and applications, reduced redundancy, consistency, and query languages.

Uploaded by

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

Ict 141 Notes

This document provides an introduction to databases, including: - Databases organize collected information for easy access, management, and updating. - Common database types are flat databases, relational databases, and database management systems (DBMS). - Key characteristics of DBMS include using real-world entities, relation-based tables, isolation of data and applications, reduced redundancy, consistency, and query languages.

Uploaded by

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

BUKURA AGRICULTURAL COLLEGE

BIOLOGICAL PHYSICAL AND APPLIED SCIENCE

DEPARTMENT

APPLIED SCIENCES SECTION

COURSE NOTES

UNIT TITLE: INTRODUCTION TO DATABASE

UNIT CODE: ICT 141

REVISED: 2022
INTRODUCTION TO DATABASE
Introduction
A collected information which is in an organized form for easier access, management, and
various updating is known as a database.
Data can be defined as a collection of facts and records on which we can apply reasoning or
can-do discussion or some calculation.
Data can exist in form of graphics, reports, tables, text, etc. that represents every kind of
information, that allows easy retrieval, updating, analysis, and output of data by systematically
organized or structured repository of indexed information.
Any system that manages databases is called a database management system, or DBM.
Types of Database
Flat Databases have the following characteristics −

• simple
• long and dominant
• useful for very small scale and simple applications.
A Relational Database has the following characteristics −

• organizes data such that it appears to the user to be stored in a series of


interrelated tables
• used for high-performance applications
• efficient
• ease of use
• ability to perform a variety of useful tasks

A database management system stores data in such a way that it becomes easier to retrieve,
manipulate, and produce information.

Characteristics of DBMS

Traditionally, data was organized in file formats. DBMS was a new concept then, and all the
research was done to make it overcome the deficiencies in traditional style of data management.
A modern DBMS has the following characteristics −
• Real-world entity − A modern DBMS is more realistic and uses real-world
entities to design its architecture. It uses the behavior and attributes too. For
example, a school database may use students as an entity and their age as an
attribute.
• Relation-based tables − DBMS allows entities and relations among them to
form tables. A user can understand the architecture of a database just by looking
at the table names.
• Isolation of data and application − A database system is entirely different than
its data. A database is an active entity, whereas data is said to be passive, on
which the database works and organizes. DBMS also stores metadata, which is
data about data, to ease its own process.
• Less redundancy − DBMS follows the rules of normalization, which splits a
relation when any of its attributes is having redundancy in values. Normalization
is a mathematically rich and scientific process that reduces data redundancy.
• Consistency − Consistency is a state where every relation in a database remains
consistent. There exist methods and techniques, which can detect attempt of
leaving database in inconsistent state. A DBMS can provide greater consistency
as compared to earlier forms of data storing applications like file-processing
systems.
• Query Language − DBMS is equipped with query language, which makes it
more efficient to retrieve and manipulate data. A user can apply as many and as
different filtering options as required to retrieve a set of data. Traditionally it
was not possible where file-processing system was used.

Examples of database management systems.


Some of the popular database management systems are:

• Oracle,
• MS Access,
• MS SQL Server,
• Paradox,
• Dbase,
• FoxPro,
• MySql

Database Users

A typical DBMS has users with different rights and permissions who use it for different
purposes. Some users retrieve data and some back it up. The users of a DBMS can be broadly
categorized as follows −

• Administrators − Administrators maintain the DBMS and are responsible for


administrating the database. They are responsible to look after its usage and by
whom it should be used. They create access profiles for users and apply
limitations to maintain isolation and force security. Administrators also look
after DBMS resources like system license, required tools, and other software
and hardware related maintenance.
• Designers − Designers are the group of people who actually work on the
designing part of the database. They keep a close watch on what data should be
kept and in what format. They identify and design the whole set of entities,
relations, constraints, and views.
• End Users − End users are those who actually reap the benefits of having a
DBMS. End users can range from simple viewers who pay attention to the logs
or market rates to sophisticated users such as business analysts.

Database Architecture
A Database Architecture is a representation of DBMS design. It helps to design, develop,
implement, and maintain the database management system. A DBMS architecture allows
dividing the database system into individual components that can be independently modified,
changed, replaced, and altered. It also helps to understand the components of a database.

Types of DBMS Architecture


There are mainly three types of DBMS architecture:

• One Tier Architecture (Single Tier Architecture)


• Two Tier Architecture
• Three Tier Architecture

1-Tier Architecture
1 Tier Architecture in DBMS is the simplest architecture of Database in which the client,
server, and Database all reside on the same machine. A simple one tier architecture example
would be anytime you install a Database in your system and access it to practice SQL
queries. But such architecture is rarely used in production.

1 Tier Architecture Diagram


2-Tier Architecture
A 2 Tier Architecture in DBMS is a Database architecture where the presentation layer runs
on a client (PC, Mobile, Tablet, etc.), and data is stored on a server called the second tier.
Two tier architecture provides added security to the DBMS as it is not exposed to the end-
user directly. It also provides direct and faster communication.

2 Tier Architecture Diagram


In the above 2 Tier client-server architecture of database management system, we can see that
one server is connected with clients 1, 2, and 3.

Two Tier Architecture Example:

A Contact Management System created using MS- Access.


3-Tier Architecture
A 3 Tier Architecture in DBMS is the most popular client server architecture in DBMS in
which the development and maintenance of functional processes, logic, data access, data
storage, and user interface is done independently as separate modules. Three Tier architecture
contains a presentation layer, an application layer, and a database server.

3-Tier database Architecture design is an extension of the 2-tier client-server architecture. A


3-tier architecture has the following layers:

1. Presentation layer (your PC, Tablet, Mobile, etc.)


2. Application layer (server)
3. Database Server

3 Tier Architecture Diagram


The Application layer resides between the user and the DBMS, which is responsible for
communicating the user’s request to the DBMS system and send the response from the
DBMS to the user. The application layer(business logic layer) also processes functional logic,
constraint, and rules before passing data to the user or down to the DBMS.

The goal of Three Tier client-server architecture is:

• To separate the user applications and physical database


• To support DBMS characteristics
• Program-data independence
• Supporting multiple views of the data

Three Tier Architecture Example:

Any large website on the internet, including guru99.com.


Microsoft Access
Microsoft Access is a Database Management System (DBMS) from Microsoft that combines
the relational Microsoft Jet Database Engine with a graphical user interface and software
development tools. It is a member of the Microsoft Office suite of applications, included in the
professional and higher editions.
Microsoft Access stores information which is called a database. To use MS Access, you will
need to follow these four steps −
• Database Creation − Create your Microsoft Access database and specify what
kind of data you will be storing.
• Data Input − After your database is created, the data of every business day can
be entered into the Access database.
• Query − This is a fancy term to basically describe the process of retrieving
information from the database.
• Report (optional) − Information from the database is organized in a nice
presentation that can be printed in an Access Report.

Vocabulary
A collection of fields make up a record. A collection of records make up a Table. A
collection of Tables make up a database
Field – One column of a Table common to all the records
Record – One row of a Table containing all data about a particular entry
Table – One set of related data
Database – Structured collection of related Tables

MS Access Objects
MS Access uses “objects" to help the user list and organize information, as well as prepare
specially designed reports. When you create a database, Access offers you Tables, Queries,
Forms, Reports, Macros, and Modules. Databases in Access are composed of many objects but
the following are the major objects −

• Tables
• Queries
• Forms
• Reports
• Macro
• module
Together, these objects allow you to enter, store, analyze, and compile your data. Here is a
summary of the major objects in an Access database;
Table

Table is an object that is used to define and store data. When you create a new table, Access
asks you to define fields which is also known as column headings.
• Each field must have a unique name, and data type.
• Tables contain fields or columns that store different kinds of data, such as a name
or an address, and records or rows that collect all the information about a
particular instance of the subject, such as all the information about a customer
or employee etc.
• You can define a primary key, one or more fields that have a unique value for
each record, and one or more indexes on each table to help retrieve your data
more quickly.

Query

An object that provides a custom view of data from one or more tables. Queries are a way of
searching for and compiling data from one or more tables.
• Running a query is like asking a detailed question of your database.
• When you build a query in Access, you are defining specific search conditions
to find exactly the data you want.
• In Access, you can use the graphical query by example facility or you can write
Structured Query Language (SQL) statements to create your queries.
• You can define queries to Select, Update, Insert, or Delete data.
• You can also define queries that create new tables from data in one or more
existing tables.

Form

Form is an object in a desktop database designed primarily for data input or display or for
control of application execution. You use forms to customize the presentation of data that your
application extracts from queries or tables.
• Forms are used for entering, modifying, and viewing records.
• The reason forms are used so often is that they are an easy way to guide people
toward entering data correctly.
• When you enter information into a form in Access, the data goes exactly where
the database designer wants it to go in one or more related tables.

Report

Report is an object in desktop databases designed for formatting, calculating, printing, and
summarizing selected data.
• You can view a report on your screen before you print it.
• If forms are for input purposes, then reports are for output.
• Anything you plan to print deserves a report, whether it is a list of names and
addresses, a financial summary for a period, or a set of mailing labels.
• Reports are useful because they allow you to present components of your
database in an easy-to-read format.
• You can even customize a report's appearance to make it visually appealing.
• Access offers you the ability to create a report from any table or query.

Creating a Database

In this chapter, we will be covering the basic process of starting Access and creating a database.
This chapter will also explain how to create a desktop database by using a template and how to
build a database from scratch.
To create a database from a template, we first need to open MS Access and you will see the
following screen in which different Access database templates are displayed.

To view the all the possible databases, you can scroll down or you can also use the search box.
Let us enter project in the search box and press Enter. You will see the database templates
related to project management.
Select the first template. You will see more information related to this template.

After selecting a template related to your requirements, enter a name in the File name field and
you can also specify another location for your file if you want.
Now, press the Create option. Access will download that database template and open a new
blank database as shown in the following screenshot.

Now, click the Navigation pane on the left side and you will see all the other objects that come
with this database.
Click the Projects Navigation and select the Object Type in the menu.

You will now see all the objects types — tables, queries, etc.
Create Blank Database

Sometimes database requirements can be so specific that using and modifying the existing
templates requires more work than just creating a database from scratch. In such case, we make
use of blank database.
Step 1 − Let us now start by opening MS Access.

Step 2 − Select Blank desktop database. Enter the name and click the Create button.
Step 3 − Access will create a new blank database and will open up the table which is also
completely blank.

Every field in a table has properties and these properties define the field's characteristics and
behavior. The most important property for a field is its data type. A field's data type determines
what kind of data it can store. MS Access supports different types of data, each with a specific
purpose.
• The data type determines the kind of the values that users can store in any
given field.
• Each field can store data consisting of only a single data type.
Here are some of the most common data types you will find used in a typical Microsoft Access
database.

Type of Data Description Size

Text or Up to 255 characters.


combinations of
text and numbers,
including
Short Text
numbers that do
not require
calculating (e.g.
phone numbers).

Lengthy text or Up to 63, 999 characters.


Long Text combinations of
text and numbers.

Numeric data 1, 2, 4, or 8 bytes (16 bytes if set to Replication ID).


used in
Number
mathematical
calculations.

Date and time 8 bytes


values for the
Date/Time
years 100
through 9999.

Currency values 8 bytes


and numeric data
used in
mathematical
Currency
calculations
involving data
with one to four
decimal places.

A unique 4 bytes (16 bytes if set to Replication ID).


sequential
(incremented by
1) number or
AutoNumber
random number
assigned by
Microsoft Access
whenever a new
record is added to
a table.

Yes and No 1 bit.


values and fields
that contain only
Yes/No one of two values
(Yes/No,
True/False, or
On/Off).

• If you use previous versions of Access, you will notice a difference for two of those
data types.

• In Access 2013, we now have two data types — short text and long text. In previous
versions of Access these data types were called text and memo.

• The text field is referred to as short text and your memo field is now called long text.
• These are all the different data types that you can choose from when creating fields in
a Microsoft Access table.

When you create a database, you store your data in tables. Because other database objects
depend so heavily on tables, you should always start your design of a database by creating all
of its tables and then creating any other object. Before you create tables, carefully consider
your requirements and determine all the tables that you need.
Let us try and create the first table that will store the basic contact information concerning the
employees as shown in the following table −

Field Name Data Type

EmployeelD AutoNumber

FirstName Short Text

LastName Short Text

Address1 Short Text

Address2 Short Text

City Short Text


State Short Text

Zip Short Text

Phone Short Text

Phone Type Short Text

Let us now have short text as the data type for all these fields and open a blank database in
Access.

This is where we left things off. We created the database and then Access automatically opened
up this table-one-datasheet view for a table.
Let us now go to the Field tab and you will see that it is also automatically created. The ID
which is an AutoNumber field acts as our unique identifier and is the primary key for this table.
The ID field has already been created and we now want to rename it to suit our conditions. This
is an Employee table and this will be the unique identifier for our employees.

Click on the Name & Caption option in the Ribbon and you will see the following dialog box.
Change the name of this field to EmployeeID to make it more specific to this table. Enter the
other optional information if you want and click Ok.

We now have our employee ID field with the caption Employee ID. This is automatically set
to auto number so we don't really need to change the data type.
Let us now add some more fields by clicking on click to add.
Choose Short Text as the field. When you choose short text, Access will then highlight that
field name automatically and all you have to do is type the field name.

Type FirstName as the field name. Similarly, add all the required fields as shown in the
following screenshot.
Once all the fields are added, click the Save icon.
You will now see the Save As dialog box, where you can enter a table name for the table.

Enter the name of your table in the Table Name field. Here the tbl prefix stands for table. Let
us click Ok and you will see your table in the navigation pane.
Table Design View

As we have already created one table using Datasheet View. We will now create another table
using the Table Design View. We will be creating the following fields in this table. These
tables will store some of the information for various book projects.

Field Name Data Type

Project ID AutoNumber

ProjectName Short Text

ManagingEditor Short Text

Author Short Text

PStatus Short Text

Contracts Attachment
ProjectStart Date/Time

ProjectEnd Date/Time

Budget Currency

ProjectNotes Long Text

Let us now go to the Create tab.

In the tables group, click on Table and you can see this looks completely different from the
Datasheet View. In this view, you can see the field name and data type side by side.
We now need to make ProjectID a primary key for this table, so let us select ProjectID and
click on Primary Key option in the ribbon.
You can now see a little key icon that will show up next to that field. This shows that the field
is part of the table’s primary key.
Let us save this table and give this table a name.

Click Ok and you can now see what this table looks like in the Datasheet View.
Let us click the datasheet view button on the top left corner of the ribbon.

If you ever want to make changes to this table or any specific field, you don't always have to
go back to the Design View to change it. You can also change it from the Datasheet View. Let
us update the PStatus field as shown in the following screenshot.
Click Ok and you will see the changes.

MS Access Datasheet
An Access database is not a file in the same sense as a Microsoft Office Word document or a
Microsoft Office PowerPoint are. Instead, an Access database is a collection of objects like
tables, forms, reports, queries etc. that must work together for a database to function properly.
We have now created two tables with all of the fields and field properties necessary in our
database. To view, change, insert, or delete data in a table within Access, you can use the table’s
Datasheet View.
• A datasheet is a simple way to look at your data in rows and columns without
any special formatting.
• Whenever you create a new web table, Access automatically creates two views
that you can start using immediately for data entry.
• A table open in Datasheet View resembles an Excel worksheet, and you can type
or paste data into one or more fields.
• You do not need to explicitly save your data. Access commits your changes to
the table when you move the cursor to a new field in the same row, or when you
move the cursor to another row.
• By default, the fields in an Access database are set to accept a specific type of
data, such as text or numbers. You must enter the type of data that the field is
set to accept. If you don't, Access displays an error message −
Let us add some data into your tables by opening the Access database we have created.

Select the Views → Datasheet View option in the ribbon and add some data as shown in the
following screenshot.

Similarly, add some data in the second table as well as shown in the following screenshot.
You can now see that inserting a new data and updating the existing data is very simple in
Datasheet View as working in spreadsheet. But if you want to delete any data you need to select
the entire row first as shown in the following screenshot.

Now press the delete button. This will display the confirmation message.
Click Yes and you will see that the selected record is deleted now.

A query is a request for data results, and for action on data. You can use a query to answer a
simple question, to perform calculations, to combine data from different tables, or even to add,
change, or delete table data.
• As tables grow in size they can have hundreds of thousands of records, which
makes it impossible for the user to pick out specific records from that table.
• With a query you can apply a filter to the table's data, so that you only get the
information that you want.
• Queries that you use to retrieve data from a table or to make calculations are
called select queries.
• Queries that add, change, or delete data are called action queries.
• You can also use a query to supply data for a form or report.
• In a well-designed database, the data that you want to present by using a form
or report is often located in several different tables.
• The tricky part of queries is that you must understand how to construct one
before you can actually use them.

Create Select Query

If you want to review data from only certain fields in a table, or review data from multiple
tables simultaneously or maybe just see the databased on certain criteria, you can use
the Select query. Let us now look into a simple example in which we will create a simple query
which will retrieve information from tblEmployees table. Open the database and click on
the Create tab.

Click Query Design.


In the Tables tab, on the Show Table dialog, double-click the tblEmployees table and
then Close the dialog box.

In the tblEmployees table, double-click all those fields which you want to see as result of the
query. Add these fields to the query design grid as shown in the following screenshot.

Now click Run on the Design tab, then click Run.


The query runs, and displays only data in those field which is specified in the query.

Query criteria helps you to retrieve specific items from an Access database. If an item matches
with all the criteria you enter, it appears in the query results. When you want to limit the results
of a query based on the values in a field, you use query criteria.
• A query criterion is an expression that Access compares to query field values to
determine whether to include the record that contains each value.
• Some criteria are simple, and use basic operators and constants. Others are
complex, and use functions, special operators, and include field references.
• To add some criteria to a query, you must open the query in the Design View.
• You then identify the fields for which you want to specify criteria.

Example

Let’s look at a simple example in which we will use criteria in a query. First open your Access
database and then go to the Create tab and click on Query Design.
In the Tables tab on Show Table dialog, double-click on the tblEmployees table and then close
the dialog box.

Let us now add some field to the query grid such as EmployeeID, FirstName, LastName,
JobTitle and Email as shown in the following screenshot.
Let us now run your query and you will see only these fields as query result.

If you want to see only those whose JobTitle are Marketing Coordinator then you will need to
add the criteria for that. Let’s go to the Query Design again and in Criteria row of JobTitle
enter Marketing Coordinator.
Let us now run your query again and you will see that only Job title of Marketing Coordinators
are retrieved.

If you want to add criteria for multiple fields, just add the criteria in multiple fields. Let us say
we want to retrieve data only for “Marketing Coordinator” and “Accounting Assistant”; we can
specify the OR row operator as shown in the following screenshot −
Let us now run your query again and you will see the following results.

If you need to use the functionality of the AND operator, then you have to specify the other
condition in the Criteria row. Let us say we want to retrieve all Accounting Assistants but only
those Marketing Coordinator titles with “Pollard” as last name.
Let us now run your query again and you will see the following results.

Queries
In MS Access and other DBMS systems, queries can do a lot more than just displaying data,
but they can actually perform various actions on the data in your database.
• Action queries are queries that can add, change, or delete multiple records at one
time.
• The added benefit is that you can preview the query results in Access before you
run it.
• Microsoft Access provides 4 different types of Action Queries −
o Append
o Update
o Delete
o Make-table
• An action query cannot be undone. You should consider making a backup of any
tables that you will update by using an update query.

Create an Append Query

You can use an Append Query to retrieve data from one or more tables and add that data to
another table. Let us create a new table in which we will add data from the tblEmployees table.
This will be temporary table for demo purpose.
Let us call it TempEmployees and this contains the fields as shown in the following
screenshot.
In the Tables tab, on the Show Table dialog box, double-click on the tblEmployees table and
then close the dialog box. Double-click on the field you want to be displayed.
Let us run your query to display the data first.

Now let us go back to Query design and select the Append button.
In the Query Type, select the Append option button. This will display the following dialog box.

Select the table name from the drop-down list and click Ok.
In the Query grid, you can see that in the Append To row all the field are selected by default
except Address1. This because that Address1 field is not available in
the TempEmployee table. So, we need to select the field from the drop-down list.

Let us look into the Address field.


Let us now run your query and you will see the following confirmation message.

Click Yes to confirm your action.


When you open the TempEmployee table, you will see all the data is added from the
tblEmployees to the TempEmployee table.

Create an Update Query

You can use an Update Query to change the data in your tables, and you can use an update
query to enter criteria to specify which rows should be updated. An update query provides you
an opportunity to review the updated data before you perform the update. Let us go to the
Create tab again and click Query Design.
In the Tables tab, on the Show Table dialog box, double-click on the tblEmployees table and
then close the dialog box.

On the Design tab, in the Query Type group, click Update and double-click on the field in
which you want to update the value. Let us say we want to update the FirstName of “Rex” to
“Max”.
In the Update row of the Design grid, enter the updated value and in Criteria row add the
original value which you want to be updated and run the query. This will display the
confirmation message.

Click Yes and go to Datasheet View and you will see the first record — FirstName is updated
to “Max” now.
Create a Delete Query

You can use a delete query to delete data from your tables, and you can use a delete query to
enter criteria to specify which rows should be deleted. A Delete Query provides you an
opportunity to review the rows that will be deleted before you perform the deletion. Let us go
to the Create tab again and click Query Design.
In the Tables tab on the Show Table dialog box, double-click the tblEmployees table and then
close the dialog box.

On the Design tab, in the Query Type group, click Delete and double-click on
the EmployeeID.
In the Criteria row of the Design Grid, type 11. Here we want to delete an employee whose
EmployeeID is 11.

Let us now run the query. This query will display the confirmation message.
Click Yes and go to your Datasheet View and you will see that the specified employee record
is deleted now.

Create a Make Table Query

You can use a make-table query to create a new table from data that is stored in other tables.
Let us go to the Create tab again and click Query Design.
In the Tables tab, on the Show Table dialog box, double-click the tblEmployees table and then
close the dialog box.

Select all those fields which you want to copy to another table.
In the Query Type, select the Make Table option button.

You will see the following dialog box. Enter the name of the new table you want to create and
click OK.
Now run your query.

You will now see the following message.

Click Yes and you will see a new table created in the navigation pane.
MACROS
In this chapter, we will cover the basics of Macros in Access. A Macro is a tool that allows you
to automate tasks and add functionality to your forms, reports, and controls.
• Macros in Access work a bit different from Macros in Word or Excel, where you
essentially record a series of keystrokes and play them back later.
• Access Macros are built from a set of predefined actions, allowing you to
automate common tasks, and add functionality to controls or objects.
• Macros can be standalone objects viewable from the Navigation pane, or
embedded directly into a Form or Report. Once you have created database
objects like tables, forms and reports, Macros can provide a quick and easy way
to tie all those objects together to create a simple database application that
anyone can use or even modify, with relatively little training.
• Macros provide a way to run commands without the need to write or even know
VBA code, and there is a lot that you could achieve just with Macros.

Creating a Macro

Let us start be creating a very simple Macro that opens a form when a command button is
clicked. For this, we need to open your database and frmEmployeeData form in which we have
created two tabs.
In this form, we can add a button allowing users to open up all of the job information.

Let us now go to the Design View of this form and add button form the Controls menu. When
you release your mouse, you will see the Command Button Wizard dialog box.
There is a couple of ways to build that Macro action, but the simplest way is to simply use the
Command Button Wizard.

For common actions like opening a form, select Form Operations from the Categories list and
then select Open Form from the Actions list and click Next as in the above screenshot.
You need to specify which form you would like to open with the command button. For now,
let us select frmJobs and click Next.

In this screen we have two options, we can open the form and display a very specific record,
or we can open the form and show all the records. Let us select the second option and click
Next as in the above screenshot.
We could have the command button itself display a picture or you can select the Display Text.
Here, we want the text View Jobs to display and now click Next.

You can now provide a meaningful name to your command button as in the above screenshot.
This can be used in other codes or other Macros. Let us call this cmdViewJobs and
click Finish.
Now go to the Form View.
You will now see a View Jobs button on your form. Let us click on it.

Now you have a form open, but you will not be viewing any information. Let us go back to the
frmEmployeeData form Design view. Make sure that the command button is selected and click
on the Event tab on the Property Sheet.
Upon clicking, you will see an embedded Macro created by the Wizard. If you now want to
modify this Macro, click on the … button to open up the Macro generated by the Wizard.

This is the Macro Designer and on the right you will see the Action Catalog. This is where all
of your actions will live in folders. You have the Data Entry options, Data Import/Export and
so on, and on the left in the main area you have another Macro. It only contains one action, and
clicking on that one action you can view other properties for that specific action.
You will see the form name and you can hit that drop-down arrow to view the forms available
in your database. You can change how that form is viewed, you can have it open to Form view,
Design view, Print Preview at your choice. You can apply a filter name or a Where condition.
Here we want to change the Data Mode because frmJobs is set to the Add Mode which only
allows the addition of new records. We can override this here in this Macro by changing it to
the Edit Mode.
Now save your Macro, and then close the Macro Designer and go back to the Form View.

Let us click on View Jobs again.

You can now see that it opens your frmJobs form and allows you to scroll through all of the
available jobs in our database.
REPORTS
In this chapter, we will be covering the basics of reports and how to create reports. Reports
offer a way to view, format, and summarize the information in your Microsoft Access database.
For example, you can create a simple report of phone numbers for all your contacts.
• A report consists of information that is pulled from tables or queries, as well as
information that is stored with the report design, such as labels, headings, and
graphics.
• The tables or queries that provide the underlying data are also known as the
report's record source.
• If the fields that you want to include all exist in a single table, use that table as
the record source.
• If the fields are contained in more than one table, you need to use one or more
queries as the record source.
Example
We will now take a simple example to understand the process of creating a very simple report.
For this, we need to go to the Create tab.

Before clicking on the Report button to create a basic report, make sure the proper query is
selected. In this case, qryCurrentProjects is selected in your navigation pane. Now click on
the Report button, which will generate a report based on that query.
You will see that the report is open in Layout view. This provides a quick way to adjust the
size or width of any of your fields that you see on the report. Let us now adjust the column
widths to make everything fit in a better way.
Scroll down and adjust the page control at the bottom.

This was a very quick way to create a very simple report. You could also make minor changes
and adjustments from the report design view.
• Just like forms, a report is made up of a variety of different sections.
• You have the detail section, which is where all of your data lives for the most
part.
• You also will see a page header and a page footer section; these appear at the
top and at the bottom of every single page in your report.
Let us now change the Title of the report and give it another name.

Click on the save icon to save your report.

You will get the above dialog box.


Enter a name for your report and click Ok. If you want to view what this report will actually
look like, in Print Preview, you can go back to the View button and click on Print Preview to
see what this report would look like when printed either on paper or as a PDF.
Using the tools on the lower right-hand corner, you can zoom in or zoom out. You also have
some buttons on the Print Preview tab that appear automatically when you switch to Print
Preview. In the zoom section, you've got a view for one page, two pages; or if you have a longer
report, you can view four pages at once, eight pages or twelve pages. You can also adjust simple
things such as the size of the paper that you are using to print, the margins for your report, the
orientation, the number of columns, page set up, etc. And that is how you can create a very
quick simple report using the Report button on the Create tab.

Create a Report Using Report Design

Report Design is another method for creating a quick report in Access. For this, we need to use
the Report Design View button, which is like the Form Design button. This will create a blank
report and open it directly to the Design View, allowing you to change the control source and
add fields directly to the Design View of the report.
Let us now go to the Create tab and click on the Report Design button.
It will open a blank report or an unbound report, meaning this report is connected to no other
object in our database.

On the Design tab in the Tools group, select the Property Sheet. This will open up the Property
pane.
On the Data tab, assign a record source to this report, to connect it to a database object as in
the following screenshot.

Select qryLateProjects from the drop-down and now, the next step is to go through and add
some fields to this report by clicking on Add Existing Fields list button on the Design tab.
Select the fields as in the above screenshot.

Drag the fields to you report as in the above screenshot. Go the Arrange tab, and in the Table
group, you have a couple of options to choose from.
There is a stacked layout and a tabular layout, which is a layout that is very similar to a
spreadsheet. Let us select the tabular layout.

You can see that it moves all of the labels up to the page header area. These labels will appear
only once at the top of every page and the data query will repeat for every record in the Details
section. Now, you can go through and make some adjustments to make your ProjectName field
wider.
As you can see in the above screenshot, there is a lot of space between Detail section and Page
Footer.
Let us drag the Page Footer up to reduce the space as in the following screenshot. We will now
go to the Design tab and click on the View button and choose Report View.
You can now see that some project names are not complete; you can adjust this with either the
design view, or you can use the layout view to do that.

That is how we create a simple report just from the Design View.
FORMS
Forms in Access are like display cases in stores that make it easier to view or get the items that
you want. Since forms are objects through which you or other users can add, edit, or display
the data stored in your Access desktop database, the design of your form is an important aspect.
There's a lot you can do design-wise with forms in Microsoft Access. You can create two basic
types of forms −

• Bound forms
• Unbound forms

Bound Forms

Let us now understand what Bound Forms are −

• Bound forms are connected to some underlying data source such as a table,
query, or SQL statement.
• Bound forms are what people typically think of when they think of the purpose
of a form.
• Forms are to be filled out or used to enter or edit data in a database.
• Examples of bound forms will typically be what users use to enter, view or edit
data in a database.

Unbound Forms

Let us look into Unbound Forms −

• These forms are not connected to an underlying record or data source.


• Unbound forms could be dialog boxes, switch boards, or navigation forms.
• In other words, unbound forms are typically used to navigate or interact with
the database at large, as opposed to the data itself.

Types of Bound Forms

There are many types of bound forms you can create in Access. Let us understand the types −
Single Item Form
This is the most popular one and this is where the records are displayed — one record at a time.
Multiple Item Form
This displays multiple records at a time from that bound data source.
Split Form
The form is divided into halves, either vertically or horizontally. One half displays a single
item or record, and the other half displays a list or provides a datasheet view of multiple records
from the underlying data source.

Creating Forms

There are a few methods you can use to create forms in Access. For this, open your Database
and go to the Create tab. In the Forms group, in the upper right-hand corner you will see the
Form Wizard button.
Click on that button to launch the Form Wizard.
On this first screen in the wizard, you can select fields that you want to display on your form,
and you can choose from fields from more than one table or a query.
Let us assume we want to simply have a quick form that we are going to use for data entry for
our employee information.
From Tables/Queries drop-down list, select tblEmployees table. Click on the double arrow to
move all the fields at once.
Let us just leave it with that one table, and click Next.

The following screen in the Form Wizard will ask for the layout that we would like for our
form. We have columnar, tabular, datasheet and justified layouts. We will choose the
columnar layout here and then click Next.
In the following screen, we need to give a title for our form. Let us call it frmEmployees.
Once you have given your form a title, you can open the form to see what that form looks like,
or you can begin entering information into your table. Or you can choose the option to modify
the form's design. Let us choose the first option to open the form to view or enter
information and click Finish.

Now, take a look at the following screenshot. This is what your form looks like. This is a single
item form, meaning one record is displayed at a time and further down you can see the
navigation buttons, which is telling us that this is displaying the record 1 of 9. If you click on
that button then, it will move to the next record.

If you want to jump to the very last record in that form or that table, you can use the button
right beside that right arrow, the arrow with a line after it, that's the last record button. If you
want to add new employee information, go to the end of this records and then after 9 records
you will see a blank form where you can begin entering out the new employee's information.
This is one example of how you can create a form using the Form Wizard. Let us now close
this form and go to the Create tab. Now we will create a slightly more complicated form using
Wizard. Click the Form Wizard and this time, we will choose fields from a couple of different
tables.
In this Form Wizard, let us choose tblProjects for Tables/Queries, and select a few Available
Fields such as ProjectID, ProjectName, ProjectStart, and ProjectEnd. These fields will now
move to Selected Fields.

Now select tblTasks for Tables/Queries and send over the TaskID, ProjectID, TaskTitle,
StartDate, DueDate and PercentComplete. Click Next.
Here, we want to retrieve data from a couple of different objects. We can also choose from
options on how we want to arrange our form. If we want to create a flat form, we can choose
to arrange by tblTasks, which will create that single form, with all the fields laid out in flat
view as shown above.
However, if we want to create a hierarchical form based on that one-to-many relationship, we
can choose to arrange our data by tblProjects.

In the above window, we have the option to include a subform for tblTasks, or we can make
that a linked form. This linked form is where tblProjects will have a button that will launch that
second form filtered to the project that we have selected in that underlying projects form. Let
us now select the Form with subform(s), and then click Next.
In the following screen, you can choose a layout for your subform. The Datasheet View gets
selected by default. The Datasheet View is similar to Table View. Now, click Next.

In the following screen, you need to provide a name for your forms. Enter the name you want
and click Finish.
Access will give you a preview of what your form looks like. On top, you have the controls on
your main form, which is from our Projects table. As you go down, you will see a subform.
It's like a form within a form.

Multiple Item Form

You may also want to create a specific kind of form. For this, you can click on the More
Forms drop-down menu.

From the menu, you can create a Multiple Items form, a Datasheet form, a Split form, or even
a Modal Dialog form. These are typically bound forms; select the object that you would like
to be bound to that form. This does not apply to the Modal Dialog forms.
To create this type of form, you will need to select the object in navigation pane first. Let us
select tblEmployees here.

Proceed by clicking on More Forms and Multiple Items.

The above step will further create a Multiple Items form, listing out all the employees.

Split Form
This type of form is divided in equal halves, either vertically or horizontally. One half displays
a single item or record, and the other half displays a list or a datasheet view of multiple records
from the underlying data source.
Let us now select tblEmployees in the navigation pane and then on Create tab. Select Split
Form option from More Forms menu and you will see the following form in which the form
is divided vertically.

You might also like