Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

THE FEDERAL POLYTECHNIC, EDE

COMPUTER SCIENCE DEPARTMENT

NATIONAL DIPLOMA II

PRACTICAL GUIDE/ASSIGNMENT
ON

COURSE CODE: COM 221


TEAM: __________

SN NAME(S) MATRIC NUMBER(S)


1
2
3
4
5
6
7
8
9
10

PROGRAMME: ________________________________________________________

SESSION: ______________________________________________________________
Instructions:

It is proposed to complete a project, with a team of minimum 4 and maximum 10.

All answers, submission and conclusion should be typed and well numbered. Use the cover page above
for all solutions.

Carryout the following experiments; 1, 2, 3, 4, 6,8  Find below solution sessions, for guide.

WEEK1 - 4: MS ACCESS (Tables, Form, Query and Report)


Required: A functional PC loaded with Microsoft Office 2016
Task1: Create table CUSTOMERS
Create the field names and their properties, as you need them to store customer’s data. You will
have ten customers with their information included in your customers table whose state name
start only with the alphabet “K”.
CUSTOMERS Table Field Names:
Customer ID (Primary Key: cid)
First Name (fname)
Last Name (lname)
Mobile Number (mnumber)
City (city)
State (state)
Number of Purchases (pnumber)
Total Amount of Purchases (ptotal)
Date of Last Purchase (pldate)

Note: Under Field properties of each field, remember to caption your fields appropriately and make sure
all fields are NOT NULL (Required: Yes)
Instruction/Procedures
i. Open a Microsoft Access

ii. Click on Blank desktop database

iii. Name the database file as “Customers_Purchase” and click create


iv. Click on the Create Tab, then Click on Table Design Or From Home Tab, Click on
Table1, Under the Home Ribbon, Click on View (Design view) icon
v. To create the table “CUSTOMERS” as required above, enter the fields given and
assign the datatype appropriately as shown below

vi. To define “cid” as Primary Key and caption it as CUSTOMER ID, Click on the field
name “cid” under the Design Tab ribbons, locate the primary key icon, then click
(Primary key defined). Below field declaration section, is “Field Properties” Locate
Caption and type in CUSTOMER ID.

vii. To appropriately assign datatype to “mnumber” the input mask (Field Properties)
need to defined based on the format required.Click on the field name “mnumber” and
assign short Text as the datatype, Goto the “field properties” section locate input
mask, and click the build button(a three dotted button). Accept to save the table and
name it “CUSTOMERS”

Click OK

Understanding Input Mask


An input mask is a string of characters that indicates the format of valid input values. You can use input
masks in table fields, query fields, and controls on forms and reports. The input mask is stored as an
object property.
You use an input mask when it is important that the format of the input values is consistent. For example,
you might use an input mask with a field that stores phone numbers so that Access requires ten digits of
input. If someone enters a phone number without the area code, Access won’t write the data until the area
code data is added.
The three parts of an input mask
Input masks are made up one mandatory part and two optional parts, and a semicolon separates each part.
The purpose of each part is as follows:
1. The first part is mandatory. It includes the mask characters or string (series of characters) along
with placeholders and literal data such as, parentheses, periods, and hyphens.
2. The second part is optional and refers to the embedded mask characters and how they are stored
within the field. If the second part is set to 0, the characters are stored with the data, and if it is set
to 1, the characters are only displayed and not stored. Setting the second part to 1 can save
database storage space.
3. The third part of the input mask is also optional and indicates a single character or space that is
used as a placeholder. By default, Access uses the underscore (_). If you want to use another
character, enter it in the third part of your mask.
For example, this is an input mask for a telephone numbers in the U.S. format: (999) 000-000;0;-:
The mask uses two placeholder characters, 9 and 0. The 9 indicates an optional digit (which makes it
optional to enter an area code), and each 0 indicates a mandatory digit.
The 0 in the second part of the input mask indicates that the mask characters will be stored along with the
data.
The third part of the input mask specifies that a hyphen (-) instead of the underscore (_) is to be used as
the placeholder character.
Characters that define input masks

Character Explanation
0 User must enter a digit (0 to 9).
9 User can enter a digit (0 to 9).
# User can enter a digit, space, plus or minus sign. If skipped, Access
enters a blank space.
L User must enter a letter.
? User can enter a letter.
A User must enter a letter or a digit.

& User must enter either a character or a space.


C User can enter characters or spaces.
.,:;-/ Decimal and thousands placeholders, date and time separators. The
character you select depends on your Microsoft Windows regional
settings.
> Coverts all characters that follow to uppercase.
< Converts all characters that follow to lowercase.
! Causes the input mask to fill from left to right instead of from right to
left.
\ Characters immediately following will be displayed literally.
"" Characters enclosed in double quotation marks will be displayed
literally.
Task2: Name the Description as mnumber. Considering the information above which can be
accessed by placing the cursor on the input mask field and click Help button (note that internet
connection is required on MS ACCESS 2016).
Instruction: Mask the input to accommodate “mnumber” in this format:08012345678 and also
make input mask to fill values from left to right instead of from right to left.
Solution: Enter eleven 0s in the Input Mask field and define the sample appropriately, Click Close
button and select “mnumber” from the list of input mask

Click Finish button


To make input mask to fill values from left to right instead of from right to left. Enter “!” into the format
field (Field Properties) as shown above with reference to the characters that define input masks

Task3: The fields (city and state) can be lookup either by typing the values or from another table.

Instructions

i. Click on “city” and select Lookup Wizard


ii. Select “I will type in the values that I want” and click the Next button. Then type in the
values and click Finish button

Task4: Do it yourself exercise 1: For the state field create a Table (STATE). Then lookup the values from
a column of the table(STATE).

STATE Table Field Names:


STATE ID (sid)
STATE NAME (state)
STATE CAPITAL (Primary key: city)

Note: To accomplish the exercise above, you need to close the Design View and create a new table.

Task5: Input mask the “pnumber” field to accept only maximum of three digits. Assign the Currency
datatype to the “ptotal” field and Date/Time to “pldate” field respectively. Note that all fields are NOT
NULL

Instructions: Add a validation text (Please, enter the number of purchases made. Thanks) to guide data
entry.

i. Click on pnumber and change the datatype to Short Text.


ii. In the Field Properties, type 099 in the input mask field and “Please, enter the number of
purchases made. Thanks” in the Validation Text property field
iii. Click on ptotal and change the datatype to Currency.
Task6: From the Field Properties of “pldate” field. Assign the medium date format. There are other
format as shown with samples below.

Task7: Do it yourself exercise 2: Fields in a table can be altered, deleted or added base on need. Delete
the “state” field and insert a new field GENDER (gender) before mnumber.
Instructions: Declare a Validation Rule (Male or Female) and also a Validation Text (Please, enter your
gender. Thanks)

Task8: Goto Datasheet View and enter 10 records.


Week5 - 10: MS ACCESS (Form)
Task 1: Create a columnar form for the Customers table. Include all fields in the form except
“Customer ID” field. Use the Form Wizard to create a form and enter five additional customers
using the form.
Procedure:
i. Click on the “Create Tab” and click on “Form Wizard” from the ribbons

ii. To select the fields to show on the form, click on the fields one after the other and
click single forward arrow (>) or the double forward arrow (>>) to move selected
fields at once and click “Next”.
iii. Select Columnar as the form layout and click “Finish”

iv. To add new records using the form, Click on New Record icon at the buttom of the
form
v. Enter five new records, after each record click on the “New Record” icon or press the
Tab button.

Result:
Task2: On Customers Form, go-to Design view and click on Design Tab to modify the form to
make it more friendly and intuitive applying your desktop publishing skills while exploring the
predefined commands with button tool.

Result

SQL and MS ACCESS (Query)


SQL stands for Structured Query Language, is a standard language for accessing and manipulating
databases. SQL became a standard of the American National Standards Institute (ANSI) in 1986, and
of the International Organization for Standardization (ISO) in 1987.

Every table is broken up into smaller entities called fields. A field is a column in a table that is
designed to maintain specific information about every record in the table. A record, also called a row,
is each individual entry that exists in a table. A record is a horizontal entity in a table.

A column is a vertical entity in a table that contains all information associated with a specific field in
a table.

Task3: Create a query that displays only the following fields (Customer id, First name, Mobile
number, Total Amount and City) as arranged.
Procedures/Instructions (Using Query Wizard)
i. Click on the “Create Tab” and click on “Query Wizard” from the ribbons
ii. Select Simple Query Wizard and click Ok

iii. Select the required fields one after the other in the arranged format by clicking the
single arrow “>” to move the fields to Selected fields from Available fields.
iv. Click Next twice, Rename the title of the query to Customers Summary and Click
Finish
Task4: Create a query that displays record of Ilorin customers sorted by last name in ascending
order.
Procedures/Instructions (Using Query Design)
i. Click on the “Create Tab” and click on “Query Design” from the ribbon

ii. Select the CUSTOMERS table and click Add to query the said table then close the
Show Table dialogue
iii. From the table below,
 On the “field”row in first column select ‘CUSTOMERS.*’ (‘*’ simply means
display all fields that met the condition)
 On the “field” row in second column select ‘city’ and on the Criteria row on
same column type ‘ ”Ilorin” ’ (simply means display customers only whose
city is ’Ilorin’) Note: uncheck the checked box on show row
 On the “field” row in third column select ‘lname’ and on the “Sort” row on
same column select Ascending (simply means ‘arrange last name in
ascending order’) Note: uncheck the checked box on show row
iv. On Design Tab, click on Run (!) on the ribbons

Task 5: Create a query that displays first name, city and total price of items purchased of
customers whose total purchase is less $100 or less
Procedures/Instructions (Using SQL)
i. Click on the “Create Tab” and click on “Query Design” from the ribbon
ii. Close the Show Table dialogue and click on SQL view under the Design Tab.

iii. In SQL view, type “SELECT fname, city, ptotal FROM customers WHERE ptotal <=
100;” and click Run (!) on the Design Tab ribbons
- To save, press Ctrl + S, and name as “100 and below total purchase”
USING WILDCARDS IN QUERY
WILDCARDS
Wildcards are special characters that can stand in for unknown characters in a text value and are
handy for locating multiple items with similar, but not identical data. Wildcards can also help
with getting databased on a specified pattern match.
ANSI-89 Wildcard Characters
The following table lists out characters supported by ANSI-89 −

Character Description Example

Matches any number of characters. You can use the wh* finds what, white, and
*
asterisk (*) anywhere in a character string. why, but not awhile or watch.

? Matches any single alphabetic character. B?ll finds ball, bell, and bill.

B[ae]ll finds ball and bell, but


[] Matches any single character within the brackets.
not bill.

b[!ae]ll finds bill and bull, but


! Matches any character not in the brackets.
not ball or bell.

Matches any one of a range of characters. You must


b[a-c]d finds bad, bbd, and
- specify the range in ascending order (A to Z, not Z to
bcd.
A).
# Matches any single numeric character. 1#3S finds 103, 113, and 123.

ANSI-92 wildcard characters


The following table lists out characters supported by ANSI-92 −

Character Description Example

Matches any number of characters. It can be used as wh% finds what, white, and
%
the first or last character in the character string. why, but not awhile or watch.

_ Matches any single alphabetic character. B_ll finds ball, bell, and bill.

B[ae]ll finds ball and bell, but


[] Matches any single character within the brackets.
not bill.

b[^ae]ll finds bill and bull,


^ Matches any character not in the brackets.
but not ball or bell.

Matches any one of a range of characters. You must


b[a-c]d finds bad, bbd, and
- specify the range in ascending order (A to Z, not Z to
bcd.
A).

Task 1: Using SQL, Query the customers table to display the names and city of customers whose
city ends with “a”
Procedure
i. In SQL view, type ” SELECT fname, lname, city FROM customers WHERE city
LIKE '*a';” and Run.
REPORTS
Design a report for the “customers summary” query.
Procedures
i. On the Create Tab, click on “Report Wizard”
ii. On the report wizard dialogue box, Select “Query: CUSTOMERS SUMMARY” and
move the fields from available fields to selected fields with “>>” as applicable to
form wizard and click Next.

iii. Since, no need for regrouping, click Next

iv. Select the field to sort with in ascending or descending order if need be, then click
Next and select the your preferred Layout (Tabular preferably) and Finish
Note: Just as form, report design can be modify in Design View
Task3: Modified the report as shown below .

RELATIONSHIP
Relationship is the association between two more tables. Relationship allow you access data
Task1: Establish the relationship between the customers and state table.
Procedures
i. On the “Database Tool Tab” Click Relationship.

ii. On State table, city is the primary key and a foreign key on the customers table (that is a cross
reference). Pick the city on state table and drop on the city on customers table.

iii. Click Create if no need to check the Enforce Referential Integrity (It ensures that user don’t
accidentally change or delete related data, i.e keeps record fields valid and accurate)
The relationship type is one to many i.e there are many customers in one city.
Final Instruction: Print all tables, forms, reports, queries and relationships as your result.

You might also like