Cambridge IGCSE: Complete
Cambridge IGCSE: Complete
Complete
ICT
Third edition
Stephen Doyle
Mahmoud Farouk Bahnassy
Jimmy Arifin
Muhammad Naveed Rajput
Foreign key
A foreign key is used to link two tables together. A foreign key is a
field (or collection of fields) in one table that links to the primary
A flat file uses a single table of data set up like this. key in a different table.
183
Flat files and relational databases Three tables are needed to store this data and these can be called:
Computerised databases may be divided into two types: the
Tools
limited flat-file database suitable for only a few applications, and
Customers
the much more comprehensive and flexible relational database.
Rentals.
Flat-file databases If the above were stored in a single table (in other words using
Flat-file databases are of limited use and are suitable only for very a flat file), there would be a problem. As all the details of tools,
simple databases. Flat files only contain one table of data. A record
is simply the complete information about a product, employee, KEY WORDS
student, etc. This is one row in the file/table. An item of information
Data redundancy where the same data is stored more
such as surname, date of birth, product number, product name,
than once in a table or where the same data is stored in
in a record is called a field. The fields are the vertical columns in
more than one table.
a table. Because flat-file databases contain only one table, this
Primary key this is a field that is unique for a particular
limits their use to simple data storage and retrieval systems such
record in a database.
as storing a list of names, addresses, phone numbers, etc. Tables
consist of columns and rows organised in the following way:
customers and rentals are stored together, there would be no record
The first row contains the field names.
of a tool unless it had been hired by a customer. There would be no
The rows apart from the first row represent the records in the
record of a customer unless they had hired a tool at the time.
database.
The columns contain the database fields. In the flat file there would be data redundancy because
customer address details are stored many times for each time
The problems with flat-file systems they hire a tool. This means the same data appears more than
Flat files store all the data in a single table. The disadvantages of once in the one table. Hence there are serious limitations in
using a flat file are: using flat files and this is why data is best stored in a relational
database where the data is held in several tables with links
Data redundancy. There is often a lot of duplicate data in the
between the tables.
table. Time is wasted retyping the same data, and more data
is stored than needs to be, making the whole database larger.
When a record is deleted, a lot of data that is still useful may
Creating databases
Before you create a structure for a database, it is important to
also be deleted.
look at a sample of the data that needs to be stored.
Harder to update as you may have to update the same
information in different places in the database. A school keeps details of all its pupils in a database. As well as
Lack of data integrity. It is easy to forget to update data in all personal details (name, address, etc.), the school also holds
the areas in the database where it occurs. This can lead to details of the tutor group and tutors.
inconsistencies in the data held and staff can no longer rely
The person who is developing the database asks the principal for a
on the integrity of the data held.
sample of the data. This sample of the data is shown below:
Lack of security as all the data is held together. This means a
person in personnel could see data relating to accounts. Description of data stored Sample data
Pupil number 76434
Relational databases Surname Harris
In a relational database, we do not store all the data in a single
Forename Amy
file or table. Instead, the data is stored in several tables with links
Date of birth 15/03/04
between the tables to enable the data in the separate tables to
Street 323 Leeward Road
be combined together if needed.
Town Waterloo
To understand this, look at the following example: Postcode L22 3PP
A tool hire business hires tools such as ladders, cement mixers, Contact phone number 0151-002-8899
scaffolding, chain saws, etc., to tradesmen. The following would Home phone number 0151-002-1410
need to be stored: Tutor Group 7G
Tutor number 112
Data about the tools
Data about the customers Tutor teacher title Mr
Data about the rentals. Tutor surname Harrison
Tutor initial K
Three tables are used with the names: Pupils, Tutor Groups and
184 Tutors.
18 DATABA SES
186
18 DATABA SES
Activity 18.1
Locating, opening, and importing data from an existing file
In this activity you will learn how to:
identify the structure of a csv file
import a file in csv file format into database software
change field names and data types
change the structure of a database.
1 Load Microsoft Word and locate and open the file called Employees. This file is a comma separated variable (csv) file and a
section of it is shown here:
Notice that the first row of the data (which also appears on the next line because it is long) contains the field names.
Each subsequent row represents a record. Notice also that all the data is separated by commas.
Rather than type all this data into the database, we can create a database using this existing file.
Close the file without saving it and exit Word.
Click on .
187
3 Look at the following screen which appears:
As a csv file is a text file, click on to tell the database software we want to import the data from a new data source
(i.e. the text file).
From the drop-down menu, select From file and from the next menu select Text file.
4 The Get External Data – Text File window appears. Click on Browse and find the file called Employees. Click on it to open it.
Check that the correct file is shown.
The data needs to be imported into a database table. Check that the first item in the list has been selected like this:
Click on OK.
188
18 DATABA SES
Check that Delimited has been selected, as the data being imported has fields separated by commas, and then
click on Next.
6 The following window appears:
Check that Comma has been selected as the delimiter (i.e. what separates the fields in the file) and tick the box for ‘First
Row Contains Field Names’.
You are now going to check the data types for each of the fields to make sure they have been set up with the most
appropriate data type.
Click on .
189
7 The following window appears where you can check the field names that have been set up automatically:
Here you can make changes to the names of the fields and change the data types. You do this by clicking on the field name
and altering either the field name itself or the data type in the next column using the drop-down arrow.
Make the following changes:
Change the data type of the field ‘Salary’ to currency.
Change the data type of the field ‘Includes IGCSE Maths’ from Text to Yes/No.
Change the data type of the field ‘Includes IGCSE English’ from Text to Yes/No.
Change the data type of the field ‘Driving licence held’ from Text to Yes/No.
Change the field name ‘Includes IGCSE Maths’ to ‘IGCSE Maths’.
Change the field name ‘Includes IGCSE English’ to ‘IGCSE English’.
After all these changes have been made, click on OK.
8 Notice that the changes have been made in the window shown here:
Click on Next.
190
18 DATABA SES
A window appears and as there are no changes to be made, click Next again.
9 The following window appears:
Notice that a new field has appeared in the first column called ID. This is called the Primary Key and it is created
automatically to ensure that there is a unique field for each record (i.e. row of the table).
We want to choose the field Employee No as the primary key as this is a unique field in this table.
Select Choose my own primary key and use the drop-down arrow to select Employee No.
Click on Next.
10 The following window appears:
Here you give the table a name. The name suggested (i.e. Employees) is fine, so just click on Finish.
191
The following screen appears:
Click on Close to complete the import of the file to create a table of a database.
You will see the table listed on the left of the screen like this:
Click on and then on and you will switch to Design View which shows the fields and their data types like
this:
Click on the box to the right of ‘Format’ and you will see a drop-down arrow from which you should select Yes/No.
Make similar changes to the following fields:
192
18 DATABA SES
IGCSE English
Driving licence held.
In the original csv file, the Salary field contained numbers so there was no currency symbol added.
To add the currency symbol, click on Salary in the list of fields and then click on format and use the drop-down arrow to
move to the required currency. Change the currency to Euro.
Currencies are normally expressed to two decimal places. As salaries are normally given as integers (i.e. whole numbers),
we need to change this so that numbers are given to 0 decimal places. Click on Salary in the list of fields and then click on
decimal places and use the drop-down arrow to select 0 decimal places.
Click on and then to view the data after the changes have been made.
Click on Yes to save the changes made and the table containing the data will be displayed.
193
Activity 18.2
Importing data from an existing file and creating a relationship between two tables
In this activity you will learn how to:
import data from an existing file
create relationships between tables.
1 Load Microsoft Access and open the file Personnel_Database if it is not already open.
Browse for the text file called Departments and import the file into a new table (note the steps to do this are identical to
steps 4 and 5 in Activity 18.1). Check that your file looks like this:
194
18 DATABA SES
Select the delimiter Comma as we are importing a comma separated variable (csv) file and also select First Row Contains
Field Names and click Next.
The following screen appears:
195
Click on Choose my own primary key and then select Dept from the drop-down list.
Click on Finish.
196
18 DATABA SES
The table now appears in the list of tables. Double-click on to view the data.
Click on Departments
and then on .
197
Now click on Employees and then on .
Both tables are added like this:
Click on the corner of the Employees table and drag so that it is positioned to the left of the other table. Also enlarge this table
so that all the fields can be seen.
The tables should now look like this:
Click on Dept in the Departments table and keeping the left mouse button pressed down, drag to the Dept field in the
Employees table. The following window appears.
Ensure that the box for Enforce Referential Integrity is ticked and then click on .
198
18 DATABA SES
This will ensure that employees cannot be linked to a Department which does not exist.
The relationship between the fields in each table now appears like this.
Manipulating data
Activity 18.3
Entering data with 100% accuracy, showing subsets of data, and sorting data
In this activity you will learn how to:
enter data into a database with 100% accuracy
adjust the column widths so all the field names are visible
show subsets of data
sort data.
Data can be entered straight into a table and you may be asked to add data to existing data in the examination. The data you
add can be added at the end of the table and must be entered with 100% accuracy. This means you must visually check what
you have typed by comparing it with what is written on the examination paper. If you make mistakes in your data entry, it will
cost you marks.
1 Load Microsoft Access and open the database file called Personnel_Database.
2 You will notice that some of the field names and data items are not fully visible:
Move the cursor on the line which separates the field names. You will see it change to a double-headed arrow. Now drag
the line until the whole field name is shown along with the data in the column below it. Repeat this process for those field
names and data that are not fully shown.
3 At the end of the table enter the following new records.
Visually check the records you have added and ensure you have achieved 100% accuracy. Save this new data by clicking
on then Save, or by the keyboard shortcut Ctrl-S.
199
4 You are now going to use a query to select certain fields to show and also put them in descending order of salary (i.e. with
the largest salary first).
Check that Simple Query Wizard has been selected and click on OK. The next window appears. This is where you select a
table and the fields in that table you want displayed in the query.
Make sure the Table: Employees is selected and then add the fields in the Employees table by clicking on each of the
following fields followed by .
Surname
Forename
200
18 DATABA SES
Salary
Full or part time
Now click on the drop-down arrow to select .
Add the Description field in the Departments table by clicking on the field followed by .
When all the fields have been added, click Next.
The next window appears:
Change the title for the query to Query Salaries. Click on the button for Modify the query design and click .
The query design is now shown:
201
Move the cursor to the Sort box for the Salary field and click on the drop-down arrow and select Descending. This sorts all
the data in order of salary with the highest salary first.
Click on Home and then View to view the results of the query:
202
18 DATABA SES
Activity 18.4
Performing searches using queries
In this activity you will learn how to:
perform searches using numeric data with operators, e.g. =, <, > , >= and <=.
In this activity you will be using a query to make a list of only some of the records, i.e. the employees who do not have IGCSE
Maths. Also, you only want some of the fields for these employees and not all of them.
1 If you do not have the Personnel database already loaded, load Microsoft Access and open the database file called
Personnel database. Click on the Employees table to select it.
Here is what you need to select for each one. Simple Query Wizard and then click on OK. Select the fields Forename,
Surname, IGCSE Maths and Position from the Employees table.
Select the field Description from the Departments table when the selected fields section will now
appear as follows:
Click on Next.
Select and then click Next.
The purpose of this query is to give information about those employees who do not have IGCSE Maths, so this query name
describes the purpose of the query.
Select and click on .
4 In the Criteria box for the field IGCSE Maths enter No:
203
5 To display the results of the query, click on Home and then View. Note that in order to see the data in some fields fully, you
will need to widen some of the columns.
6 To close a query, click on the cross at the top right of the query tab.
7 You now have to follow similar steps to the above to create a new query that must display the following fields:
Forename
Surname
Position
Salary
Dept
Give the query the name Query High pay. The purpose of the query is to show those fields outlined above for all the
employees who have a salary of over 40000 and also to organise the data in descending order (i.e. with the highest
salary first).
When you get to the query design screen, you need to insert the details in the criteria for the Salary field box >40000 and
also click on the Sort box and select Descending using the drop-down arrow.
Click on Home and then View to see the results and check that they are correct. Save and close this query.
204
18 DATABA SES
Activity 18.5
Performing wildcard searches Note that even though this field is formatted to currency
In this activity you will learn how to: you should not include the currency sign with the
perform searches using multiple criteria number in the search criteria. Notice also that because
perform searches using wildcards. two criteria are being used, the data has to meet both
criteria (i.e. contain the word ‘admin’ for Position AND
1 Load Microsoft Access and load the file Personnel_
have a Salary of 26000 or less). Run the query by
Database if not already loaded.
2 Click on the Employees table and create a query clicking .
containing all the fields. Give the query the name Query
Admin.
3 In the Criteria box for the field Position enter the following 5 Go back to Design View and delete all the search criteria.
wildcard: 6 You have been asked to show all the details for those
employees who are not programmers. For the Position
field enter the criteria Not programmer like this:
205
Activity 18.6
Putting formulas in queries
In this activity you will learn how to:
put formulas in queries.
1 Load Microsoft Access and load the file
Personnel database if not already loaded.
2 Create a query containing all the fields in the Employees
table and call this query Query showing pension.
3 Ensure you are looking at the Design View of the query.
The company has a pension scheme where each
employee must pay 8% of their salary into the scheme.
A formula is needed to calculate 8% of the Salary for each In the Property Sheet section, click on the drop-down
employee. arrow for Format and change it to Euro like this:
Before entering the formula, you should widen the
column where the formula is to go so that all the formula
can be seen.
In the first blank field enter the following formula:
Pension:([Salary]*8/100)
After entering the formula, make sure that the box is
ticked to show the results of the calculation.
Now change Decimal Places to 0.
5 Go back to the View to see the results of the query.
6 Save this query.
206
18 DATABA SES
Activity 18.7
Performing searches on the Employees database 6 A list of the fields: surname, position and salary for all
In this activity you will learn how to: employees who are not programmers.
perform searches using multiple criteria 7 A list of the fields: surname, forename, position and room
use Boolean operators in searches where the position contains the word ‘clerk’.
sort data using one criterion into ascending or 8 A list of the fields: surname, position and salary for all
descending order. employees who have the words ‘clerk’ or ‘analyst’ as part
For this activity you are required to produce queries on the of the position field.
Personnel_Database to extract the following data: 9 A list of the fields: surname, position and salary for
1 A list of the fields: surname, forename, sex and position all employees earning 40000 or over arranged in
for all female programmers. alphabetical order according to surname.
2 A list of all employee numbers, surname and forename 10 A list of the fields: forename, surname and position for all
for employees who work part time. female workers who earn over 30000. This list needs to
3 A list of the fields: surname, forename, salary, description be sorted in descending order according to salary.
and sex for all employees earning less than 20000. 11 A list of the fields: employee no, surname, forename for
4 A list of the fields: surname, forename and position for all the staff who work in room A2.
all employees who are either web designers 12 A list of the fields: employee no, surname, forename for
or programmers. all staff who are programmers and who have a driving
5 A list of the fields: surname, forename, position and licence, arranged in alphabetical number according
number of IGCSEs for all the employees having less than to surname.
or equal to three IGCSEs.
Presenting data
Activity 18.8
Producing reports
In this activity you will learn how to:
produce reports to display all the required data and labels in full
set report titles, use headers and footers, align data and labels appropriately.
A database report is the printout of the output from a database. Reports are professional-looking documents and you have
more control over their appearance rather than simply printing out query results.
1 Load Microsoft Access and open the file Personnel_Database. This report is going to be based on one of the queries you
have already produced and saved. Select in the All Access Objects section on the left of the
screen.
2 Click on Create and then look for the Reports section shown here:
Click on .
207
3 The results of the query are made into a report which is now displayed:
4 We will now change the orientation of the report. You will be told in the examination paper which orientation to use. Here
you will need to change the orientation to Landscape.
Left-click near the edge of the box to select it. When selected, the border will look like this:
Now click on the right vertical edge of the box, when you will obtain a double-headed arrow which you can then use to
stretch the box until it looks like this:
and select .
208
18 DATABA SES
Press the left mouse button down and keeping it pressed down, drag down so that it now looks like this:
Check that has been selected and then look at the controls section:
209
Keeping the left mouse button pressed down, drag the cursor to create the label to look like this:
The name is to be right-aligned so click on Home and then the right-align button .
Your name will appear like this:
210
18 DATABA SES
You can see from the report that the data all appears on the report. Always check that the field names and the data in the
fields are all visible.
There are a few things we can alter. The report has a total added for total salary which was added automatically. This
requires deleting. It would look better if the page number were right-aligned, like your name. The headings and data for
Salary and Dept are too close.
Notice there is still a line where the formula was . To delete it, right-click on the line but make sure
there is only the orange box around the line and from the drop-down menu select delete.
Now left-click on the page number info so that the box is selected like this:
Now ensure that the cursor has changed to this and drag the box into
To right-align the page numbers, highlight the text in the box like this:
Now click on and to check that the report looks like this:
211
7 Go back to the design of the report by clicking then .
Click on the Dept box in the Page Header section to select and move the cursor onto the right-hand side of the box where it
changes into a two-headed arrow like this:
. Drag the edge of the box to the left until it looks like this:
Notice that the Dept box in the Detail section underneath the fieldname is adjusted automatically.
Now view the report. It looks like this:
In a similar way to the above, reduce the widths of the other fields as shown here. Also line up the boxes containing the
page numbers and your name in the page footer so that the right side of the box is aligned with the right side of the box for
the Dept field.
212
18 DATABA SES
Check the appearance of the report by looking at it in Report View. It should look similar to this:
8 We are going to right-align the field name and the fields for Dept.
Go to Design View and position the cursor on the top of the box for the fieldname Dept like this:
When you do this, you will notice that both boxes are selected.
Click on right-align and the fieldnames and fields are now right-aligned .
9 We need to adjust the Salary field so there are no decimal places shown.
Click on the Salary in the Detail section. Only this book should be selected like this:
To adjust the decimal places, click and then to show the salary with no decimal places.
10 We will now adjust the heading. Click on the heading in the Report Header.
213
Now click on the right of the box and drag the edge so that it is lined up with the right edge of the Dept field like this:
Click on to make the text bold and then click to centre the heading within the box.
Check your Report Header looks like this:
11 Click on Home and then on and then Report View to see the final report:
Close the report by clicking on the positioned on the pink tab. The following appears:
214
18 DATABA SES
Type in the report name Report High Pay and then click OK to save the report.
Activity 18.9
Producing calculations at run time
In this activity you will learn how to:
create calculated fields
perform calculations at run time
format fields.
One way of performing a calculation on data in a database is to create a calculated field which is worked out in a calculation
performed on other fields already in the database. This is called a calculation produced at run time.
1 Load Microsoft Access and open the file Personnel_Database.
2 The company has decided to give all the employees a 5% pay rise. You have been asked to produce a query that shows the
fields Employee No, Surname, Description and Salary, along with two new calculated fields.
One of these calculated fields is to be called Pay rise and the other is to be called New salary.
As we are going to use the fields in the two tables to create the query, click on:
215
Click Next and at the next window also click Next.
Now change the title for the query to: Query Pay Rise and ensure you have selected Modify the query design.
In the first row of the first blank column enter the following formula:
Pay rise: [Salary]*5/100
There are some important points to remember with formulas:
The new fieldname is written to the left of the colon (:).
Fieldnames that are used in the formula are identical to those used in the database.
The fieldnames used in formulas must be enclosed in square brackets.
Adjust the width of the column so that the entire formula can be seen like this:
In the next blank column enter the following formula to calculate the New salary:
New salary:[Salary]+[Pay rise]
Make sure you put a tick in the box to show the data for this calculated field.
Widen the column containing this formula so that all of it is shown like this:
4 Click on Home and then View to see the results of the query.
Notice that the Pay rise field is not formatted correctly.
Go back to the Design View and right-click the mouse button on the Pay-rise field:
216
18 DATABA SES
The following menu appears, from which you should select Properties.
The Property Sheet appears on the right like this:
Click on Format and click on the drop-down arrow and select Euro from the list.
Click on Decimal Places and click on the drop-down arrow and select 0 from the list.
217
Activity 18.10
Creating the report based on the query
In this activity you will learn how to:
create totals of columns of numbers using SUM.
1 Load the database software and open the file Personnel_Database if it is not already open.
2 Single left click on and then click on and then Report.
3 Click on the query called ‘Query Pay Rise’ created in the last activity.
Click on Design View.
Click then .
Right-click on Salary in the Page Header to select it and a drop-down menu also appears. Select
descending. The data will be sorted into descending order according to Salary.
Click Home and then View to check that the data has been sorted correctly.
218
18 DATABA SES
Make the text bold and centre it. It should look similar to this:
7 Notice there is already a calculation that has been automatically added to the report. This calculation =Sum([Salary])
adds up all the salaries in the Salary column.
You are going to put some calculations in the Report Footer section of the report.
Click on the horizontal line at the end of the Report Footer section and you will see the double-headed arrow. Drag this
down until it looks like this:
As we want to design our formulas from the start, we need to delete the formula that has been added automatically.
Right-click on the formula to highlight it like this and from the drop-down menu, select Delete.
Notice a line is still left behind. This needs to be deleted in the same way.
8 Click on and then on and drag it to produce a text box below the Salary column.
You may need to adjust this box so it looks like this:
There are two boxes: one box to hold text explaining what the contents of the other box represents and the other to hold the
result of the calculation.
The box on the right is called a control and this will be used to work out the total of the old salary for all the employees.
Double left-click on the label (i.e. the box on the left) and you will see the Property Sheet appear down the right-hand side
of the screen.
219
Click on the All tab in the Property Sheet.
In the Caption box, type the text ‘Total of old salary’.
Click on the Controls box (i.e. the box containing the text Unbound) to select it like this:
Select the Data tab of the Property Sheet and in the box to the right of Control Source enter the following formula:
=SUM([Salary])
9 Create two similar text boxes with the following text and formulas:
Total cost of pay rise =Sum([Pay rise])
Total of new salary =Sum([New salary])
They should appear like this:
220
18 DATABA SES
10 Click on Report View to see the results of the report. The totals are shown but they are not in currency format.
11 Click on Design View. If the Property Sheet is not shown on the right, then right-click on the first control containing the
formula: .
Look at the Property sheet on the right of the screen.
Click the Format tab if Format has not been selected and make the following changes.
From the drop-down menu for Format select Euro. Now click on Decimal places in the menu and select 0.
Repeat this process for the two other controls.
You will now have set the calculation fields to currency (Euro in this case) and to zero decimal places.
Click on Report View and you will see all the totals correctly formatted:
Position the cursor a couple of lines down from the top of the blank document and click on .
221
You will see the screenshot inserted into the document like this:
You cannot see the formulas easily, so it is necessary to crop the image (i.e. only use part of it) and then enlarge the
remaining part.
Right-click on the image (i.e. the screenshot) and a menu appears.
222
18 DATABA SES
Drag the black handles so that only the report design part of the image is shown like this:
Add your name to the document and then save it using a suitable file name.
Print a copy of this document.
Activity 18.11
Showing and hiding data and labels within a report
In this activity you will learn how to:
show and hide data and labels within a report.
1 Load Microsoft Access and open the file Personnel Database.
Open the Report Pay Rise by clicking on it in the All Access Objects section:
2 Change the view to Design view to display the design of the form.
3 Sometimes field names, fields or labels need to be hidden.
Here you are going to hide the Salary and New salary details in the report.
Keeping your finger pressed down on the shift key, left-click on all the following boxes to select them in the Page Header
section and Detail section of the report:
When they are all selected, they will have an orange border and look like this:
Clicking both boxes for each pair of fields ensures that both the fieldname and the data in the field are hidden.
4 Look at the Property Sheet on the right of the screen and select the Format tab if it is not already selected:
Click on the drop-down arrow for the Visible property and select No. This will hide all the items selected.
5 Click on the Report View. The report now appears with the selected items hidden:
223
6 You are now going to show the hidden data.
Go back to the design view where you will notice that there are fieldnames and fields that were not visible in the report.
Select all the headings and fields that did not appear in the report and go to the Property Sheet and change Visible to Yes
like this:
Click on the Datasheet View and the report will now be shown with the previously hidden items displayed.
7 Another way to hide data is to make the background colour the same as the text colour.
You are now going to change the background colour to black for the first column of data. The column heading is kept but
the data below it will look like a black column so it cannot be seen.
Left-click on Salary in the detail section like this:
Look at the Property Sheet down the right of the screen and click on Format.
Look down the list until you find the following
Click on the three dots next to the drop-down arrow and a palette of colours is shown:
Click on the black colour in the Standard Colors section to set this as the background for the selected field.
224
18 DATABA SES
8 Go to Report View and you will see the field for Salary with the black background like this:
However, there is a problem. You can still make out the amounts as the text colour is not completely black, so it shows
slightly. This is easy to correct. We just need to make the text black rather than a shade of grey.
Go back to the Design View and ensure Salary in the Detail Section is selected.
Look at the Property Sheet section and click on Format and look down at the list for Fore color.
Click on the above and then click on the three dots to obtain a palette of colours.
Select black.
9 In a similar way, hide the fields for New Salary.
10 Go to Report View and you will see the field for Salary and New Salary obscured like this:
Click Yes.
Activity 18.12
Database labels
In this activity you will learn how to:
produce labels that can be printed out.
1 Load Microsoft Access and open the Personnel_Database.
2 You are going to produce labels arranged in two columns for all staff who work full time and who work in the Sys or
Prg departments. The only fields to be shown on these labels are Forename, Surname, Position and Department, all on
separate lines. It has also been decided to include the field names next to the data on each label.
You first need to create a query to extract this information from the database and this query is then used as the source of
data for the labels.
Click on and then . Choose Simple Query Wizard and then click on OK.
225
Using the Employees table as the source of the fields, select the fields Forename, Surname, Position, Dept and Full or part
time. Click Next.
The next window appears from which you should enter the following name for the query: Label query. Also make sure that
Modify the query design is selected.
Click Finish.
3 The query design now appears. Enter the following criteria which will ensure that the query only extracts the data for
employees who work full time and who work in either the Sys or Prg departments.
4 Click on Home then View and use the drop-down arrow to select Datasheet View. Check that the data being extracted is
correct by comparing it with the following:
5 Make sure that the query in the All Access Objects section is selected if it isn’t already as you
are going to use the fields in this query as the basis for the fields on the labels you are going to create.
226
18 DATABA SES
6 Click on and then . The following window appears from which you need to select the labels that
have the dimensions 72mm × 72mm and are 2 across.
Click on Next.
7 In the window that appears, make the following changes to the text as shown here.
Click Next.
8 The following window appears:
227
Type in the field name Forename:
This will appear just as ordinary text on all the labels.
The label will now look like this .
Leave a space and then click on Forename in the Available fields and click on to add the field to the label so that the
label becomes .
Now do the same for the fields Surname, Position and Department so the label is the same as that here:
Click Next when another window appears. As we do not need to do any sorts, click Next.
A window appears. Make the settings the same as those shown here:
Click Finish.
9 The design of the query is now shown.
228
18 DATABA SES
11 To check the way the labels will be printed, click on Home and then on the drop-down arrow for View and finally on Print
Preview. The labels are now shown as follows:
Activity 18.13
Creating a data entry form
In this activity you will learn:
key features of form design
creating a data entry form
using font styles and sizes, spacing between fields and character spacing in fields
use of radio buttons and drop-down menus.
Data can be entered straight into a table, but it is better to create a data entry form for the entry of data. The purpose of a data
entry form is to make it easy and quick to enter data into the database. For example, a button called a radio button can be used
for those fields having only yes/no possibilities. If the button is filled in, it means yes, and if it is empty, it means no. Also,
you can set up drop-down menus so that a user can select from a list of items when they are entering data where there is a
restricted number of possibilities.
Forms are used to view data or enter data into a table or tables. In this activity, you will be creating a data entry form for the
entry of data into the Employees table.
229
1 Load Microsoft Access and the Personnel_Database if not already loaded.
2 Click on and then and in the field list on the right of the screen click on Show all tables.
3 In the above list of fields, double-left-click on the fields Employee No, Forename, Surname and Sex in turn and they will be
added to the form like this.
You are looking at the form in Layout view which shows how the form will look on the screen with data added.
Change the view of the form to Design View by clicking on and then on the drop-down arrow for View where you
should select Design View.
230
18 DATABA SES
Click at the bottom of the form where the cursor changes into a double-headed arrow and keeping the mouse button
pressed down, drag down to increase the length of the form. Increase the length to about 9 using the vertical ruler.
4 Click on the right box (called the control) for the Sex field. When selected, the field looks like this:
Press Delete to delete the control. Note that both boxes are deleted.
5 You are now going to replace this with a combo box (also called a drop-down menu) which will allow the user to either
choose M or F. This restricts what the user can type in, so it is a good method of data validation.
Click on and then on which is the button for the combo box.
When on the form, the cursor changes to a + with an icon for the combo box attached. Click under the control box for
Surname and drag to produce two boxes. One of these boxes is for the control and the other is for the label.
When you release the mouse button, a window appears from which you should select the following:
7 Add the fields DOB and No of IGCSEs onto the form. To do this, click and then click . Add the
fields from the list of fields to the form by double-clicking on them. You may need to move the labels and controls into the
positions on the form as shown below. Note that combo boxes are not being used for these fields.
231
8 Now add the IGCSE maths field by double left-clicking on it in the Field List. Now move it to below the field No of IGCSEs.
You will need to reposition it so it is in a similar position to that shown here:
Now in a similar way, add the IGCSE English field and position it below the IGCSE Maths field.
9 Now add the Position and Salary fields. These are just ordinary controls with their labels. Your form will now look like this:
10 Now create a combo box for the Full or part time field below Salary. The alternatives for the combo box should be F or P and
this data should be stored in the Full or part time field.
11 You are now going to use a radio button to indicate whether a person has a driving licence or not. Add the control and label
for Driving licence held in the position shown here.
Now delete the control and label and click on and then on the radio button which is called an option
button by Access.
232
18 DATABA SES
Now click on the form to add the button and its label positioned below the boxes for Driving licence.
Add the text Driving licence held: to the box containing the label.
Click on the button to select it . You will notice the Property sheet appears on the right of the
screen.
Select the Data tab and then use the drop-down arrow to select Driving licence held as shown here:
12 Click on and then so that you can add the final field to the form.
In the list of fields, double-click on Dept to add it to the form.
Select the control and label and delete it using the Delete key.
Click on and which is the icon for a list box and draw a box underneath the field for Driving licence held.
Click on Next.
A new window appears. Make the following changes.
233
Click on Next.
At the next window add the following text for the label .
Click on .
13 It has been decided that it would be better to have a check box rather than a radio button to show whether an employee
has a driving licence or not.
To change the radio button, right click on it and from the drop-down menu select Change to:
A new drop-down menu appears from which you should select the check box like this:
234
18 DATABA SES
You need to check that all parts of the form behave as expected by looking at each record in turn.
15 You are now going to rearrange the fields on the form so that there is more white space between them. Adding white space
will improve the appearance of the form. Click on the bottom right of the workable area of the form and the cursor will
change to:
You can now click on the fields and move them around.
It is up to you where you position each of the fields, but the more important fields should be at the top of the form and on
the left.
Save your form using the file name Data entry form.
235