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

LO1 - Creating Database Objects

This learning guide focuses on operating a database application, specifically using Microsoft Access. It covers the creation and modification of database objects, including tables, queries, forms, and reports, while emphasizing the importance of proper naming conventions and data types. The guide includes learning activities and self-checks to assess understanding and ensure mastery of the content.

Uploaded by

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

LO1 - Creating Database Objects

This learning guide focuses on operating a database application, specifically using Microsoft Access. It covers the creation and modification of database objects, including tables, queries, forms, and reports, while emphasizing the importance of proper naming conventions and data types. The guide includes learning activities and self-checks to assess understanding and ensure mastery of the content.

Uploaded by

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

INFORMATION TECHNOLOGY SUPPORT SERVICE

Level II

LEARNING GUIDE # 1
Unit of Competence: Operate Database Application
Module Title: Operating Database Application
LG Code: ICT ITS2 LO1 01
TTLM Code: ICT ITS2 TTLM 0614

LO 1: Create database objects

TTLM Development Manual Date: 08-2006 Page 1 of 39


Author: BTVET
Introduction Learning Guide # 1

This learning guide was developed to provide you the necessary information regarding the following
content coverage and topics –

 Opening and designing DB application and principles


 Creating DB objects

This guide will also assist you to attain the learning outcome stated in the cover page. Specifically,
upon completion of this Learning Guide, you will be able to –

 Open and design database application incorporating basic designprinciples


 Create database object according to database usage, as well as user requirements
 Modify database object as required
 Add and modify data in a table according to information requirements
 Add, modify and delete records as required
 Save and compile database objects

Learning Activities
1. Read the specific objectives of this Learning Guide.
2. Read the information written in the “Information Sheets 1- 2”.
3. Accomplish the “Self-check” in pages7.
4. If you earned a satisfactory evaluation proceed to “Information Sheet 2”. However, if your rating is
unsatisfactory, see your teacher for further instructions or go back to Learning Activity # 1.
5. Submit your accomplished Self-check. This will form part of your training portfolio.
6. Read the information written in the “Information Sheet 2”.
7. Accomplish the “Self-check” in page 19.
8. If you earned a satisfactory evaluation proceed to “Operation Sheet” in page 20. However, if your
rating is unsatisfactory, see your teacher for further instructions or go back to Learning Activity #2 .
9. Read the “Operation Sheet” and try to understand the procedures discussed.
10. Do the “LAP test” in page 33 (if you are ready) and show your output to your teacher. Your
teacher will evaluate your output either satisfactory or unsatisfactory. If unsatisfactory, your teacher
shall advice you on additional work. But if satisfactory you can proceed to Learning Guide 2.

Information Sheet-1 Opening and designing DB application and


principles
TTLM Development Manual Date: 08-2006 Page 2 of 39
Author: BTVET
Database

A database can best be described as a way of storing large amounts of information. The data
can be retrieved and we can even ask questions of the data and get answers. For example:You may
want to know how many Students enrolled in every occupational level.

Ms Access is a database management tool that enables one to store relevant data.
This also has the capabilities to retrieve, sort, summarize and reportresultsimmediately
and effectively. It can combine data from various files (tables) through creating
relationships,and can make data entry more efficient and accurate through the use of
forms.

Microsoft Access (MS Access) enables one to manage all important information from a
singledatabase file. Within the file, one can use the different objects:

 Tables - A table is a collection of data about a specific topic, such as products or suppliers.
Using a separate table for each topic means that you store that data only once. This results in
a more efficient database and fewer data-entry errors.
 Queries - You use queries to view, change, and analyze data in different ways. You can also
use them as a source of records for forms, reports, and data access pages.
 Forms - A form is a type of a database object that is primarily used to enter or display data in a
database. You can also use a form as a switchboard that opens other forms and reports in the
database, or as a custom dialog box that accepts user input and carries out an action based
on the input.
 Reports - A report is an effective way to present your data in a printed format. Because you
have control over the size and appearance of everything on a report, you can display the
information the way you want to see it

 Modules - A module is essentially a collection of declarations, statements, and procedures


stored together as one named unit to organize your Microsoft Visual Basic code. Microsoft
Access has two types of modules: standard modules and class modules.
 Data access 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— data that is stored in a Microsoft
Access database or a Microsoft SQL Server database. The data access page may also include
data from other sources, such as Microsoft Excel.

In MS Access, data is stored once in one table, but can be viewed from multiple
locations.When the data is updated in a Table, Query or Form, it is automatically updated everywhere
itappears.

Establishment of Ms Access database

TTLM Development Manual Date: 08-2006 Page 3 of 39


Author: BTVET
All Ms Access databases files are saved with extension .mdb. A database should have a
separate table for every major subject, such as Students records, Students grades,etc..

Production data or Treatment information. Data should not be duplicated in multiple tables.
Microsoft Access provides three methods to create a database

 Database Wizard (though easy, the wizard offers limited options to customize thedatabase)
 Using a template (This method works best if one can find and use a template thatclosely
matches the specific requirements)
 Creating a database directly (This is the most flexible method, but it requires one todefine
each database element separately).

Basic Database Concept: In studying MS Access, it is but necessary to understand some basic
elements of a database before proceeding to it.

Database Elements:

 Dataareraw facts. It tells the truth about something;a person, a place, an object, etc.
Example:

Name (1) “Noel” is a data.“Noel” is my name, so it tells


Noel something about a person. “Noel” is aName

Gender (2) “Male” is Noel’s gender. So it tells


Male something about “Noel”. Noel is Male.

 Information is a collection of data (raw facts) which is contained in 1 file (table in Access)
Example:
IDNumber LName FName Mname Gende Bday Address
r
MOE-0001 Cuevas Noel Pancho Male 11-05-1978 Aratkilo
(this is an information about a person named “Noel”)

Example of a table (file):


IDNumber LName FName Mname Gende Bday Address
r
MOE-0001 Cuevas Noel Pancho Male 11-05-1978 Aratkilo
MOE-0002 Panganiban Mark Perez Male 11-05-1978 Magadang
Fil a
MOE-0003 Cerna Patrick Santos Male 11-05-1978 Aratkilo
MOE-0004 Hipolito Valder Cruz Male 11-05-1978 Sidiskilo
MOE-0005 Ohmy Diana Antonio Female 11-05-1978 Aratkilo

Naming Convention

TTLM Development Manual Date: 08-2006 Page 4 of 39


Author: BTVET
Is manner of naming files and variables. Having a poor naming convention can only add
confusion, so it's important that you start with a good scheme, and think about what the scheme will
mean to you. Here are the three things to consider in establishing a naming convention:

1. Does my convention make sense to me?


 Is must be simple and understandable to you.
2. Will my convention make sense to other people?
 Time will come that other people will look into your database program, so they must
able to understand it.
3. Can I be consistent in implementing and enforcing my convention?
 All throughout my database work, your naming convention must not change.

General
Here are some basic simple rules when it comes to the name of any object in a database
(including the name of the database itself):
 Do not use spaces in object names. It might seem tempting and cute to have a view named
"Sales By Quarter," but this is a nightmare to deal with programmatically. Instead write it as
“SalesByQuarter” or “SalesByQtr” or “QtrlySales”
 Avoid using reserved words.This is easier said than done, as there is a very large list of
current and future reserved words to check against. Example: do not name your file as “Date”
because “Date” is a reserve word in Ms Access.
 Do not use dashes in database names.Dash “-“ was often recognized by a computer as an
operator (subtraction), so instead of naming your object as “Quarterly-Sales” better name it
as QuarterlySales” or better use underscore instead of a dash“Quarterly_Sales”.
 Start object names with a letter.I see table named "2005_Sales" and columns and columns
named "1", "2," "3," and so on (to represent months). Ms Access might treat it as a number
and not as a filename.
 Keep names short but meaningful.This is self-explanatory and fairly logical,"SlQ" is too
short. “SalesFiguresForCompanyByFiscalQuarter" is just silly.
 Use sensible case.There is little worse than going through a database schema where all the
table names are in ALL CAPS. It’s like Ms Access is yelling at you! Likewise, trying to read a
procedure name like "getallarticlestatisticsbyweek" could drive some people to drink. I like
camel-/Pascal-casing or using underscores, leaning toward the former in most cases:
GetArticleStatsByWeek or getArticleStats_ByWeek.
 Avoid Hungarian notation. The name of the object should make it pretty obvious what type of
data it contains, and if for some reason it does not, then there is always the metadata tables
and/or the documentation you should have written when designing the system. Using
datatype-style prefixes for columns like IContactID (integer) and VEmail (varchar) not only
make the column names harder to read, they also make them less flexible.

Opening and designing DB application and


Self - Check 1
principles
TTLM Development Manual Date: 08-2006 Page 5 of 39
Author: BTVET
Name: ______________________________________ Date: ________________________________________

Time started: _______________________________ Time finished: _______________________________

Directions: Answer all the questions listed below.

1. In Ms Access, a way of storing large amounts of information was called a? (1 points)

2. Enumerate and the different Ms Access objects. (7 points)

3. Ms Access database file was saved with what extension name? (1 point)

4. What are the 3 methods to create a database in Ms Access? (3 points)

5. A collection of related data is called (1 point)

6. File in Ms Access is synonymous to what? (1 point)

7. What are the three things to consider in establishing a naming convention? (3 points)

Note: Satisfactory rating - 14 points, Unsatisfactory - below 14 points


You can ask you teacher for the copy of the correct answer

Opening and designing DB application and


Self - Check 1 Creating
principles
database objects

TTLM Development Manual Date: 08-2006 Page 6 of 39


Author: BTVET
Answer Key:

1. database

2. a. Tables
b. Queries
c. Forms
d. Reports
eModules
f Macros
g. Page

3. .mdb

4. a. Database Wizard
b. Using a template
c. Creating a database directly

5. information

6. Table

7. a. Does my convention make sense to me?


b. Will my convention make sense to other people?
c. Can I be consistent in implementing and enforcing my convention?

Information Sheet-2 Creating database objects


Creating DB Tables

TTLM Development Manual Date: 08-2006 Page 7 of 39


Author: BTVET
Recently, we define it as a file but technically, it was defined as a container or a
worksheet-like container where the collection of data has been stored.

Before we proceed to creating your first table, we need to know first the basic
components of a table:
o Meta Data – Database Structure
o Field – Column – Data
o Fieldname
o Record - Row - Information

Metadata – is a “data about data” or synonymously called table structure that defines
what type of data your data is?

Given these data:


(1) “Noel” which is a firstname, we can say that it composes of texts, so we
define the firstname to accept text only thus it accepts the value “Noel”

(2) Supposed that “21” is the Age of Noel, then we will define Age as a number,
specifically an Integer so it will only accept a value which is an integer.

Thus it gave a table structure of:


Field Name Data Type
Firstname Text
Age Integer

Which only means to say that you cannot enter a number value in the Firstname field,
likewise you cannot enter a text value to the Age field. In that case, entering a number value
to a Firstname field would treat it as text. Ex: Richard23. And cannot be used for
computation.

Field – Every column in a table represents a field by which data has been stored.
Field name – This refers to the name of every field.
Records –Every rowin a table represents a record, which is a collection of meaningful data.

Example of a table : Table name: StudentsTable


7 columns = 7 fields

IDNumber LName FName Mname Gende Bday Address


Row
r
MOE-0001 Cuevas Noel Pancho Male 11-05-1978 Aratkilo
Record
TTLM Development Manual Date: 08-2006 Page 8 of 39
Author: BTVET
MOE-0002 Panganiban Mark Perez Male 11-05-1978 Magadang
a
MOE-0003 Cerna Patrick Santos Male 11-05-1978 Aratkilo
MOE-0004 Hipolito Valder Cruz Male 11-05-1978 Sidiskilo
MOE-0005 Ohmy Diana Antonio Female 11-05-1978 Aratkilo

Fieldnames
“MOE-0001” is the data for IDNumber field. And IDNumber is a fieldname for that data.

1 Record MOE-0001 Cuevas Noel Pancho Male 11-05-1978 Aratkilo


1 Row gives an information. It tells that NoelPancho Cuevas is a Male whose birthday is on 11-05-
1978 and who lives in Aratkilo.

Data Types

When creating a table, one will need to specify what kinds of data are to be stored in this field.

The different kinds of MsAccess2003 data types are:

 Text: allows for the storage of any kind of data, characters, digits and special
characters. It has a defect length of 50 characters with a maximum length of 255. It is
normally used to store data such as names, addresses, or any number not used in
calculations, like telephone numbers or zip codes.
 Memo: is used for texts of more than 255 characters such as comments or
explanations. It has a maximum length of 65.536 characters. Access recommends that
to store formatted text or large documents, rather to create an OLE Object field than a
Memo field.

In Access2003 it is possible to arrange or group in a Memo field, but Access only uses
the first 255 characters when it arranges or groups in a Memo field.

 Number: for numerical data used in mathematical calculations. Within the number type
we are able to specify the size property of the field. The types Byte, Integer and Long
Integer allow the storage of numbers without decimals; the types Single, Double and
Decimal allow decimals; the type Replication ID is used for autonumerical codes in
replication databases.
 Date/Time: for the introduction of date and time from the year 100 to 9999.
TTLM Development Manual Date: 08-2006 Page 9 of 39
Author: BTVET
 Currency: For monetary values and numerical data used in mathematical calculations
in which the data involved contains between one and four decimals. The accuracy is up
to 15 digits to the left of the decimal separator and up to 4 digits to the right of the same.

Access recommends the use of Currency type to avoid the rounding off of numbers in
calculus. A Currency field has an accuracy of up to 15 digits to the left of the decimal
separator and 4 digits to the right. A Currency field occupies 8 bytes of space on disc.

 Autonumber: a unique sequential number (increasing one by one), or an aleatory


number that Access assigns every time it adds a new record to a table. Autonumber
fields cannot be updated.
 Yes/No:Yes and No values, and fields that contain one of two values (Yes/No,
True/False or Acivated/Disactivated).
 OLE Object: an object such as a Microsoft Excel spreadsheet, a Microsoft Word
document, graphics, images, sounds, or other binaries.
 Hyperlink: text or a combination of text and numbers stored as text and used as a
hyperlink address. A Hiperlink is a text or grafic that you click to go to a file, a location in
a file, a web page on the Internet, or a web page on an intranet.

Tables may be created by either:


 Table wizard
 Design view

Creating Tables using design view


Creation of a table by design view is a user customized way of making data storage tables.
Each field in the design view of a table corresponds to a column in the datasheet view of atable.

Designing a table involves:

 Entering unique names of the columns of the table in the “field name” column of the
design view. Names of fields and objects in Microsoft Access can be up to 64characters long. They
can include any combination of letters, numbers, spaces, andspecial characters except a period (.),
an exclamation point (!), an accent grave (`), andbrackets ([ ]). They also can't begin with leading
spaces

 Primary Key is the unique identification of one record. It will not allow a duplication of the
Primary Key thus make it unique. Define a Primary Key field (You don't have to define a primary
key, but it's usually agood idea. If you don't define a primary key, Microsoft Access asks if you want
Accessto create one for you when you save the table)

Forms

TTLM Development Manual Date: 08-2006 Page 10 of 39


Author: BTVET
A form is a type of a database object that is primarily used to enter or display data in
adatabase. Most forms are bound to one or more tables and queries in the database. A form's
record source refers to the fields in the underlying tables and queries.

Forms may be created by either:


 Form wizard
 Design view

Creating Forms using a wizard


Creation of a form by using a wizard is the Ms Access pre-defined way of creating a form by
simply following the series of steps and choosing which field and format you would want for your
form.

Creating Forms using design view


Creation of a form by design view is a user customized way of making data entry forms,
Switchboard form and even custom dialog box. Each control in the design view of a form was being
dragged from the control toolbox.

Queries
A query is a derived item in the database meant to answer specific questions that relate to
theinformation in the database. It is the means to retrieve relevant information in one or more tables.
Queries are handy during data processing.

Queries may be created by either:


 Query wizard
 Design view
 SQL View

Creating Queries using a wizard


Creation of a query by using a wizard is a fastest and easy way to extract information you need
from one or more tables.

Creating Queries using design view


Creation of a query by design view is a user customized way of setting-up criteria to filter the
necessary information you need from one or more tables.

Creating Queries using SQL view


Creation of a form by SQL view is another option but not normally being use by Ms Access
programmers. It requires an understanding of the Structured Query Language statements.

Reports
TTLM Development Manual Date: 08-2006 Page 11 of 39
Author: BTVET
Reports provide a means of organizing and summarizing data. Reports are often used
topresent an overview highlighting main points and trends. A report can be a simple list, a
statusreport or a monthly production report.

A report is made from the data available.

Reportsmay be created by either:


 Report wizard
 Design view

Creating Reports using a wizard


Creation of a report by using a wizard is a fastest and easy way to create a report by following
the series of steps and choosing a pre-defined template for your report.

Creating Reports using design view


Creation of a report by design view is a user customized way setting-up your report so to
meet the users desired output and format.

Macros

Macros in Access can be thought of as a simplified programming language which you can use
to add functionality to your database. For example, you can attach a macro to a command button on
a form so that the macro runs whenever the button is clicked. Macros contain actions that perform
tasks, such as opening a report, running a query, or closing the database. Most database operations
that you do manually can be automated by using macros, so they can be great time-saving devices.

A macro is essentially a list of actions that you apply to objects to respond to events. Each
action carries out one task. You create your actions in the order you want them to execute. In
addition, you specify the arguments of the actions, giving the program additional information as
needed.

You can set conditions for each action in a macro to determine whether it runs or not. Run a
macro by applying it to the event property of an object. Once the specified event occurs the macro will
run by running the all the specified actions. Actions that have conditions applied to them may or may
not run depending on whether or not they passed the conditional tests.

Once you've created your macros you'll see them listed in the Macros tab in the Database
window. This way you can attach any macro to any event property in your database.

Modules

TTLM Development Manual Date: 08-2006 Page 12 of 39


Author: BTVET
Modules, like macros, are objects you can use to add functionality to your database. Whereas
you create macros in Access by choosing from a list of macro actions, you write modules in the Visual
Basic for Applications (VBA) programming language. A module is a collection of declarations,
statements, and procedures that are stored together as a unit. A module can be either a class module
or a standard module. Class modules are attached to forms or reports, and usually contain
procedures that are specific to the form or report they're attached to. Standard modules contain
general procedures that aren't associated with any other object. Standard modules are listed
under Modules in the Navigation Pane, whereas class modules are not.

Now that you know how to put together a program, you are ready to give it a try. To create a
VBA procedure, you follow many of the same steps you follow when you created macros. The
general steps in VBA programming are as follows:

1. Identify the task you want to accomplish.


2. Plan the steps needed to accomplish that task.
3. Create the programming code necessary to implement the steps.
4. Test the program.
5. Refine the program.
6. Repeat steps 4 and 5 until the program works correctly.

You create VBA programming code by using the VBA Editor, which is described in the
following section.

What is the VBA Editor?


You create VBA programs using the VBA Editor. To start the VBA Editor, first click your mouse
on the Modules button in the Database window. Then, click your mouse on the New button. Access,
in turn, displays the VBA Editor, as shown in Figure 20-1.

TTLM Development Manual Date: 08-2006 Page 13 of 39


Author: BTVET
Figure 20-1 The VBA Editor.
Notice that there are several different parts to the VBA Editor. In the upper left corner is what
the editor refers to as the Project window. This is where you can see the different elements of your
project and any modules that have been defined in the workbook. Just below the Project window is
the Properties window. Here you can specify different attributes of whatever you have selected in the
Project window. For most simple development needs, you will never do much with the Properties
window. To the right of the Properties window, and at the very bottom of the screen, is the immediate
window. This is where you can either test parts of your procedures during development or you can
find the immediate results of various commands. The Immediate window comes in very handy during
testing and debugging, when they are necessary.

Note: If a window is not displayed within the VBA Editor, you can display it by choosing one of
the options from the View menu. For instance, if you want to display the Project window, choose
Project Explorer from the View menu.
The Module window, which is the largest window on the screen, is where you do your
programming. At the top of the Module windowarethe two drop-down lists. The one on the left is
called the Object box. The one on the right is the Procedure box. You use the Object box to select
which object you want to work with. When you first create a module, the object is set to the
word General, meaning you are working on a general module, not on one associated with a particular
object in a form or report.

The Procedure box is where you indicate the name of the procedure on which you want to
work. If you choose or specify a different procedure in this box, the information Access shows in the
Module window changes to reflect the VBA statements you have assigned to that procedure.
The top level of a module is the Declarations section; It begins with the procedure name you
indicate in the Procedure box when you first create a module. Take a look at the Module window
(Figure 20-1). It contains the programming code already defined for the declarations section. In this
instance, there is only one line of code defined--a statement that indicates the database's default sort
order.
To enter programming statements into a procedure, you type them in the Module window. As
you enter information, Access checks to make sure it can understand what you type. In other words,
Access checks the syntax of what you enter. You use the correct syntax when you follow the VBA
rules of grammar.

TTLM Development Manual Date: 08-2006 Page 14 of 39


Author: BTVET
You can cut, copy, and paste sections of code using standard Windows mouse or keyboard
techniques. You can perform these operations either in the same procedure or between different
procedures.

Data Access 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— data that is stored in a Microsoft Access database or a Microsoft
SQL Server database. The data access page may also include data from other sources, such as
Microsoft Excel.

Using a data access page is similar to using a form: You can view, enter, edit, and delete data
in a database. However, you can also use a page outside a Microsoft Access database, so users can
update or view data over the Internet or an intranet.

Parts of a data access page

 The body - The body is the basic design surface of a data access page. On a page
that supports data entry, you can use it to display informational text, controls bound to
data, and sections.
 Sections - You use sections to display text, data from a database, and toolbars.

Two types of sections are typically used on pages that support data entry: group header
and record navigation sections. A page can also have footer and caption sections.

 Group header and footer Used to display data and calculate values.
 Record navigation Used to display the record navigation control for the group level.
A record navigation section for a group appears after the group header section. You
can't place bound controls in a record navigation section.
 Caption Used to display captions for text boxes and other controls. It appears
immediately before the group header. You can't place bound controls in a caption
section.

Each group level in a data access page has a record source. The name of the record source is
displayed on the section bar for each section used for a group level.

Designing different types of data access pages

TTLM Development Manual Date: 08-2006 Page 15 of 39


Author: BTVET
You design data access pages in Design view in Microsoft Access. The page is a separate file
that is stored outside Access; however, when you create the file, Access automatically adds a
shortcut to the file in the Database window. Designing a data access page is similar to designing
forms and reports— you use a field list, the toolbox, controls, and so on. However, there are some
significant differences in the way that you design and interact with data access pages as opposed to
forms and reports. How you design the page depends on what it will be used for:

 Interactive reporting. This type of data access page is often used to consolidate and group
information that is stored in the database, and then publish summaries of the data. For
example, a page might publish the sales performance for each region in which you do
business. Using expand indicators, you can go from a general summary of the information,
such as a list of all the regions and their combined sales total, to specific details on individual
sales within each region. The data access page might provide toolbar buttons for sorting and
filtering the data, as well as for adding, editing, and deleting the data in some or all group
levels.

 Data analysis. This type of data access page may include a PivotTable list, similar to a
Microsoft Excel PivotTable report, that lets you reorganize the data to analyze it in different
ways. The page might contain a chart that you can use to analyze trends, detect patterns, and
compare data in your database. Or it might contain a spreadsheet, in which you can enter and
edit data and use formulas to calculate as you do in Excel.

Using data access pages in Internet Explorer

A data access page is connected directly to a database. When users display the data access
page in Internet Explorer, they are viewing their own copy of the page. That means any filtering,
sorting, and other changes they make to the way the data is displayed— including changes they
make within a PivotTable list or spreadsheet— affect only their copy of the data access page.
However, changes that they make to the data itself— such as modifying values, and adding or
deleting data— are stored in the underlying database, and therefore are available to everyone
viewing the data access page.

Note To view and work with the data access page on the Internet or an intranet, users need
Microsoft Internet Explorer 5.01 with Service Pack 2 (SP2) or later.

Using data access pages in Microsoft Access

You can also work with a data access page in Page view in Access. Data access pages can
supplement the forms and reports that you use in your database application. When deciding whether
to design a data access page, form, or report, consider the tasks that you want to perform.

TTLM Development Manual Date: 08-2006 Page 16 of 39


Author: BTVET
Self - Check 2 Creating database objects

Name: ______________________________________ Date: ________________________________________

Time started: _______________________________ Time finished: _______________________________

Directions: Answer all the questions listed below.

1. Metadata is also known as? ( 1 point )

2. A field in a table signifies a? (1 point)

3. The name of the field was called a? (1 point)

4. One row in a table signifies a?(1 point)

5. It is the primary and unique identification of a record? (1 points)

TTLM Development Manual Date: 08-2006 Page 17 of 39


Author: BTVET
6. What are the two ways of creating a form? (2 points)

7. Enumerate the 3 ways of creating a query. (3 points)

8. A customized way of creating a report was called as? (1 points)

9. What do you call the editor where you will write your macro code? (1 points )

10. What are the 2 types of Data Access Pages? (2 points)

Note: Satisfactory rating - 13 points Unsatisfactory - below 13 points


You can ask you teacher for the copy of the correct answer

Self - Check 2 Creating database objects

Answer Key:

1. table Structure

2. data

3. fieldname

4. record

5. primary key

6. a. Design View
b. by using a Wizard

7. a. Design View
b. by using a Wizard
c. SQL view

TTLM Development Manual Date: 08-2006 Page 18 of 39


Author: BTVET
8. Wizard

9. VB editor

10. a. Interactive reporting


b. data analysis

Operation Sheet-1 Creating database objects


Creating Database Objects:
(In this lesson, we will be using MS Access 2003)

Before you can create a database objects, you need to launch first the MS Access Software and then
create a blank database.

 To launch MS Access 2003

Double click the Icon in the Desktop or

Click on the Start button>All Programs>Microsoft Office>Microsoft Access 2003

(2)All Programs (3)Microsoft Office

TTLM Development Manual Date: 08-2006 Page 19 of 39


Author: BTVET
(1)clickStart Button

(4) Microsoft Access 2003

 To create a blank database


After launching the MS Access 2003, click the NEW ICON then click the Blank
database… Afterthat, a File New Database will pop-up. Type theFilename(type MyfirstDB.mdb
as your first table name )for your database. Afterwards, click the Create button.

(2)click Blank
(1)click New icon database..

(3) Type a
File name (4) click Create
button

TTLM Development Manual Date: 08-2006 Page 20 of 39


Author: BTVET
Note: your file name must not have a space. It must be 1 word. MyfirstDB is a valid file name,
My first DB is invalid. You can define your own file name but for this purpose let’s just use
MyFirstDB. You may or may not include .mdb as an extension name. It would by default add
.mdb to your filename, thus, make it MyFirstDB.mdb.

Creating a Table
After creating a Blank database, you are now ready to create your first object, let’s start with
the Table.

Let’s now start creating a table..

Creating a table would start by creating a table structure which would define every field in a
table. Let us create a table T_StudentsList and let’s define the following fields as follows:
Field Name Data Type Description (describes each field – optional)
StudentID Text ID number of students
Lastname Text Last name of students
Firstname Text First name of students
Middlename Text Middle name of students
Birthday Date Birth day of students
Gender Text Gender of students
Course Text Course of students

Let’s now simulate it in MS Access..


After creating a blank database with a file name MyFirstDB.mdb, your screen should
resemble like this..

TTLM Development Manual Date: 08-2006 Page 21 of 39


Author: BTVET
You are now ready to create your first database object, the table.
Double-clickCreate table in design view then a blank table structure template will appear.
Enter value for Field Name, Data Type and Description as shown in the figure below.

To make a pre-defined Course list, click the lookup tab properties then choose Combo Box on the
Display Control. On the Source List, choose Value List the start typing “Management” ; “IT”;
“Computer Science”; “Accountancy”; Computer Engineering.

TTLM Development Manual Date: 08-2006 Page 22 of 39


Author: BTVET
To put primary key to a field, click on the field then click the key on the toolbar above and
the key will appear on the left side of the key.When you set one field as primary key, you couldn’t
input the same value for that field.

Note: For the Data type please refer to the Information Sheet 2 – Creating database objects.

To insert new fields within the table, in design view, click in the row below where you want to
add the field, and then click Insert Rows on the toolbar.

To add the field to the end of the table, click in the first blank row.

To change from one view to another, make a selection on the View menu or click the arrow
nextto the View button and choose from the list that appears.

To view, enter, and change data easily and directly in a table, create a ‘form’.

In the lower portion of the window Field properties,please refer below:

 Field size defines the number of characters you’re a text field can contain.
 Format is normally use for a field that has a data type of Number or Date. Click on it to define
custom settings you want.
 Input Mask was good in setting-up initial constant values. Setting an input mask for ID
number field to “MOE-999999” would mean that when you enter a value for that field it would
initially give you a value of MOE-_ _ _ _ _ _. “999999”allows you to enter any 6-digit numbers.
So, you don’t need to type MOE- because it would automatically appear. You just need to add
a 6-digit value to it to complete its value. For example: typing “000123” gives you “MOE-
000123”.
 Caption defines the label of a field. Writing “Last name” on a Caption of the Lname. See
the Caption on the table input view later.
 Default Value gives you an initial value. If you are expecting more Male students, you better
put “Male” on the Default Valueof your Gender field so that when you input a record, it would
automatically appear a Male on your Gender field so you don’t need to type it anymore. In
TTLM Development Manual Date: 08-2006 Page 23 of 39
Author: BTVET
case of a Female gender, you can alter it anyway. You would save time for all Male inputs
since you don’t need to type it anymore.
 Validation Ruleallows you to filter the values you just want to input for a particular field.
Setting a Gender field Validation Rule to “Male” or “Female”would mean that it would only
accept a Male and Female value for Gender field. Typing F or M to it would give you an error-
message.
 Validation Text isthe counterpart of Validation Rule. Instead of displaying a computer
generated error-message when you input a wrong value to a field, you can set your own error-
message. You just type the text you want. Example: “Wrong Input!”
 Required field when set to Yes would not allow you to skip a certain field leaving it blank.
 Indexed whenset to OK (Duplicates OK) would sort out a field alphabetically and it would
accept duplicate values, when set to OK (No Duplicate)would sort out a filed alphabetically
but would not allow you to enter the same value (you cannot enter an ID number that already
exist).

After that, press Ctrl+Son the keyboard toSave your table. It would ask you to enter a Table Name.
Replace Table1 with T_StudentsListthen click OK button.

Note: Same rule applies in naming a table. No spaces please. Make it one-word like T_StudentsList.

Your first table was now ready..

TTLM Development Manual Date: 08-2006 Page 24 of 39


Author: BTVET
To input data, double-click the T_StudentsList table and you’re now ready to
input records to it.

To navigate from records,

Navigation bar

Go to the beginning record Enter new record


Go to the next record
Go to the previous record Go to the end record

To modify a record, you just go to the specific fields of the record and modify it.

To delete a record, click on the Record Selection bar


the record you want to delete.
The record will be highlighted then press
Del key on your keyboard.

Press Ctrl+S on your keyboard to save changes


to your table.

Creating Forms
TTLM Development Manual Date: 08-2006 Page 25 of 39
Author: BTVET
There were 2 ways to create a form
1. Create form in design view
2. Create form by using wizard

Let us try to create a form by using wizard. On the left pane, click on the Forms tab
then double click the Create form by using wizard.

Choose all fieldsfrom the table T_StudentsList by clicking on the double greater than
sign.

The single greater than ( < ) allows you to choose 1 selected field from the Available
Fields. To do the opposite (to deselect the field/s), click the less than or double less than sign.

After that, choose layout from the list. Choose also the form style you want.
For this exercise, choose the default layout, Again for this exercise, you choose Standard
the columnar then click next. Layout and then click next.

TTLM Development Manual Date: 08-2006 Page 26 of 39


Author: BTVET
Save your form as F_StudentsList by changing the T by F in the T_StudentsList.
Choose then the Modify the form’s design and then click Finish. It will then prompt you with
the form in design view as shown in the figure on the right. Let’s customize it a bit.

Just like the table, when you run the form in form view,it has its navigation button below it
that would allow you to navigate from one record to another and would also allow you to add
records to your table using the form. It would also allow you to delete records through the
record selector.

TTLM Development Manual Date: 08-2006 Page 27 of 39


Author: BTVET
Record
Selector

Navigation buttons

The next thing that you will need to do is to create your own customized navigation
buttons. Let’s now go back to your form’s design view.
Now, expand the form a bit by pointing the cursor on the bottom rightmost corner then
dragging while holding the left mouse click diagonally down as shown on the figure on the right.
Next, select all the fields by dragging the mouse through the form while holding the left click
making sure it would go over the entire fields as shown in the figure on the left

After selecting all fields, drag it all down to center into the form. Do it by dragging
while holding the left click of the mouse.

TTLM Development Manual Date: 08-2006 Page 28 of 39


Author: BTVET
Add a label by clicking the “Aa” on the Toolbox then dragging it on the top part of
the form just up a bit to StudentsID field as shown on the left.

Type Students’ Database on it then make the label a bit bigger by clicking your
cursor anywhere in the form then clicking back on the label to select it again. Afterwards
you can now change the font and its size on the toolbar above,

1. Wizard
TTLM Development Manual Date: 08-2006 Page 29 of 39
Author: BTVET
2.button

What you would do next is to create the navigation buttons by using


a button wizard on the Toolbox.
To do that, do the following Button Wizards Steps:
1. Click on the wizard on the toolbox
2. Click the button on the toolbox
3. Drag the cursor while holding the left click
belowthe course field to create a small button
4. On the Control Button Wizard, choose Record
Navigation then choose Go to first Record
Then click next.
5. Click the default button icon picture then
click next.
6. Name your button as B_Gofirst then click
Finish.

3.

You have just created your first navigation button that would allow you to go to the
first record when you run it in form view.

Let’s now create the rest of the navigation buttons as shown below.
1. Go to the first record
2. Go to the previous record
TTLM Development Manual Date: 08-2006 Page 30 of 39
Author: BTVET
3. Exit
1 2 3 4 5 4. Go to the next Record
5. Go to the Last Record

2. Go to the previous record button


To do that, do the following Button Wizards Steps:
1. Click on the wizard on the toolbox
2. Click the button on the toolbox
3. Drag the cursor while holding the left click
below the course field to create a small button
4. On the Control Button Wizard, choose Record
Navigation then choose Go to previous Record
then click next.
5. Click the default button icon picture then
click next.
6. Name your button as B_GoPrevious then click
Finish.

3. Exit button
To do that, do the following Button Wizards Steps:
1. Click on the wizard on the toolbox
2. Click the button on the toolbox
3. Drag the cursor while holding the left click
below the course field to create a small button
4. On the Control Button Wizard, choose Form
Operations then choose Close Formthen
click next.
5. Click the default button icon picture then
click next.
6. Name your button as B_Exit then click
Finish.

4. Go to next record button


To do that, do the following Button Wizards Steps:
1. Click on the wizard on the toolbox
2. Click the button on the toolbox
3. Drag the cursor while holding the left click

TTLM Development Manual Date: 08-2006 Page 31 of 39


Author: BTVET
below the course field to create a small button
4. On the Control Button Wizard, choose Record
Navigation then choose Go to Next Recordthen
click next.
5. Click the default button icon picture then
click next.
6. Name your button as B_GoNext then click
Finish.

5. Go to last record button


To do that, do the following Button Wizards Steps:
1. Click on the wizard on the toolbox
2. Click the button on the toolbox
3. Drag the cursor while holding the left click
below the course field to create a small button
4. On the Control Button Wizard, choose Record
Navigation then choose Go to Last Recordthen
click next.
5. Click the default button icon picture then
click next.
6. Name your button as B_GoNext then click
Finish.

You are now finished creating your navigation buttons. Close it then save. To view it,
double-click the F_StudentsList form. When it opens, try navigating from one record to another.
Click all the buttons you have made and see how it works.

We will do more of the Forms in the succeeding lessons…

Creating Queries

There were 2 ways to create a Query


1. Create query in design view
2. Create query by using wizard

TTLM Development Manual Date: 08-2006 Page 32 of 39


Author: BTVET
Once tables are available, it is easy to create a query.

Just click on the Queries, then double-click on Create query in design view. In the Show Table pop-
up, add the T_StudentsList table. A table will show-up on top part of the query. Double click one by one all
the fields on the table so it would appear on the table-like sheet below. All the fields that you have selected
would appear on the query view with the corresponding records depends on your criteria.

Try putting “IT” on the course criteria as shown abve. Close and save your query as Q_ITStudentsList.
Double-click on the Q_ITStudentsList to view the results of your query. It would then show the list of all
records whose course is “IT” as shown below.

TTLM Development Manual Date: 08-2006 Page 33 of 39


Author: BTVET
We have just created a query. We will do more of the Queries in the succeeding lessons…

Creating Reports

There were 2 ways to create a Report


1. Create Report in design view
2. Create Report by using wizard

Just click on the Reports, then double-click on Create report by using wizard. Follow the series of
steps below in creating an IT Students List:

1. Choose Q_ITStudentsListquery on the Tables/Queries drop-down arrow.


2. Select all fields by clicking the double greater than button just like what you
did in the form wizard. Click next after.
3. Just skip the level grouping by clicking Next.
4. On sort records, click on the Lastname thenset its order as Ascending then click next.
5. Choose the default layout which is tabular and the default orientation as portrait then
click next.
6. Click the default style as formal then choosethe Modify reports in design view
7. Save your report as R_ITStudentsList
8. Click on the Modify the reports design then click Finish.
9. It would then launch the Report in Design View as shown below.

TTLM Development Manual Date: 08-2006 Page 34 of 39


Author: BTVET
Save it then close it. To preview your report, double click on the report file R_ITStudentsList.
We will do more of the Reportsin the succeeding lessons…

Creating Macros

Let’s try to create a Macro that will open that will open the report that you have just created.
Click now on the Macros, then double-click on New. Choose OpenReport in the Action column, then
on the Report Name property below choose the report that you have just created(R_ITStudentsList).
On the view property, choose print preview. Press Ctrl+S to save. Save your module as
M_ITStudentsList_ReportOpen then close it.

To test your module, double-click the module file that you have just created. It would then
launch the report preview of R_ITStudentsList report as shown below.

TTLM Development Manual Date: 08-2006 Page 35 of 39


Author: BTVET
You have now successfully created a macro. It’s so simple that you can play around with it.

Creating Modules

Just click on the Modules,


then double-click on New. On the
Microsoft Visual Basic Form,type the code
you want to perform as shownbelow.

For this activity, type the following


code below:

Sub About theSystem( )


Msgbox “This is a studentsdatabase”,”About”
End Sub

Press Ctrl+S to save then save it as Md_About. You have just created a Module with a
function that will display the messageabout your system. You can now close the Microsoft Visual
Basic Form.

TTLM Development Manual Date: 08-2006 Page 36 of 39


Author: BTVET
To perform the modules, you need to call it in your form Event Procedure to execute or
embed to a button by using a wizard. (see Form Event Procedure links to module codes in the
succeeding learning outcome).

Creating Data Access Pages

There were 3 ways to create a Data Access Page


1. Create data access page in Design view
2. Create data access page by using Wizard
3. Edit Web page that already exist

Just click on the Pages, then double-click on Create data access page by using
Wizard.

Follow these steps in creating your first Data Access Page:


1. Choose T_StudentsListtable on the Tables/Queries drop-down arrow.
2. Select all fields by clicking the double greater than button just like what you
did in the form wizard. Click next after.
3. On the level grouping, click on Course Field then click the greater than button. By doing
this, you are grouping the students’ records according course.
4. On sort records, click on the Lastname then set its order as Ascending then click next.
5. Save your page as P_ITStudentsList
6. Click on Modify the page’s design then click Finish.
7. It would then launch the Data Access Page that you have just created in designview as
shown below.

To view the data access page, Click on Pages then double-click the data access
page file that you have just created.
Try to explore more the data access pages.
TTLM Development Manual Date: 08-2006 Page 37 of 39
Author: BTVET
Lap Test 1 Creating database objects

Name: ______________________________________ Date: ________________________________________


Time started: _______________________________ Time finished: _______________________________

Instructions: You are required to perform the following:


1. Create a database file StudentsProfile.mdb
2. On the database file StudentsProfile.mdb, create the following objects
a. Create a Tablein Design Viewwith its filename as StudInfoTable and with the following
table structure:
Field names Data types Description
o studID Text (field size-10 characters) Student Identification

o studLname Text (field size-30 characters) Student Last name


o studFname Text (field size-30 characters) Student First name
o studMname Text (field size-30 characters) Student Middle name
o studGender Text (field size-6 characters) Student Gender
o studBday Date (format-short date) Student Birthday
o studCourse Text (field size-30 characters) Student Course
After creating a table, open it then input your personal data as your first record then
closeyour table.

b. Createa Formby Using a Wizardfor the table above then save it as StudInfoForm.
Create also a navigation buttons in design view.

c. Create a Queryin Design View then save it as StudInfoQuery. In your query, add the
tableStudDB as your source table then on the Field NamechoosestudID, studLname,
studFname, studMname. Afterthat, close your query.

d. Createa Reportby using a wizard then save it as StudInfoReport. On your report will
display all the fields of the table StudInfoTablehave it displayed in Ascending order by
studLname.

e. Createa New Macro then save it as StudInfoMacro. On the Form name, choose
StudInfoTableand then on the Action, choose OpenForm. Save and close it.

f. Create a New Module then save it as StudInfoModule. Under the Option Compare
Database, type this code:(save it after the close)
Sub openStudInfoForm()
DoCmd.openform "StudInfoForm"
End Sub

g. CreateData Access Page by Using a Wizard then save it as StudInfoPage.Your page


must display the list of all records group according to studCourse.
TTLM Development Manual Date: 08-2006 Page 38 of 39
Author: BTVET
TTLM Development Manual Date: 08-2006 Page 39 of 39
Author: BTVET

You might also like