module 06 Operate database application (2)
module 06 Operate database application (2)
September, 2022
Addis Abeba, Ethiopia
Table of Contents
Acknowledgment.........................................................................................................................................4
Introduction of module................................................................................................................................5
Unit one: Create database objects.............................................................................................................6
1.1. Introduction to database object.....................................................................................................7
1.2. Creating database object...............................................................................................................8
1.3. Modifying database object..........................................................................................................10
1.4. Create relationship......................................................................................................................12
Self-check 1...............................................................................................................................................14
Operation sheet 1.1: - Modifying database object................................................................................15
Lap test 1....................................................................................................................................................17
Unit Two : Customize basic setting...........................................................................................................18
2.1 Introduction to customizing Access............................................................................................19
2.2 Adjusting page layout.................................................................................................................19
2.3 . Opening and viewing different toolbars....................................................................................21
2.4 Formatting font as appropriate....................................................................................................24
Self-check 2...............................................................................................................................................25
Unit Three: Create reports....................................................................................................................25
3.1. Introduction to report......................................................................................................................26
3.2. Designing reports in a logical sequence or manner........................................................................26
3.4. Modifying reports...........................................................................................................................27
Self-check 3...............................................................................................................................................33
Operation sheet 3.......................................................................................................................................34
Operation sheet 3.1 Produces access database report................................................................................34
Operation sheet 3.2 Produces selected filed data report............................................................................37
Lap Test 3..................................................................................................................................................38
Unit four : Create Database Forms..........................................................................................................39
4.1. Introduction to forms..................................................................................................................40
4.2. Create a simple form...................................................................................................................41
4.3. Open existing database and modify records using a simple modified form...............................52
4.4. Rearranging objects within the form...........................................................................................57
Self-check 4...............................................................................................................................................62
Operation sheet 4.1 Procedures access database form...............................................................................64
DB Database
M06 module 06
WDDBA
Ministry of Labor and Skills wish to extend thanks and appreciation to the many representatives of
TVET instructors and respective industry experts who donated their time and expertise to the
development of this Teaching, Training and Learning Materials (TTLM).
This unit is developed to provide you the necessary information regarding the following content
coverage and topics:
Introduction to database object
Creating database object
Modifying database object
Creating relationship
This unit will also assist you to attain the learning outcomes stated in the cover page.
Specifically, upon completion of this learning guide, you will be able to:
Database objects are components that save and query information. A database contains objects that are
used to store and display large, relational data.
Important Terms and Basic Objects
Now in this Microsoft Access tutorial, we will learn about some important terms and basic objects in
MS Access:
Database File:
It is a file which stores the entire database. The database file is saved to your hard drive or other storage
devices.
Datatypes:
Datatypes are the properties of each field. Every field has one datatype like text, number, date, etc.
Table: - A Table is an object which stores data in Row & Column format to store data.
A Table is usually related to other tables in the database file.
Each column must have Unique name
We can also define Primary Key in a table.
Query: - Queries answer a question by selecting and sorting and filtering data based on
search criteria.
Queries show a selection of data based on criteria (limitations) you provide.
Queries can pull from one or more related Tables and other Queries.
Types of Query can be SELECT, INSERT, UPDATE, DELETE.
Form: - A form is a database object that you can use to create a user interface for a
database application.
Forms help you to display live data from the table. It mainly used to ease the
process of data entry or editing.
Report: -A report is an object in desktop databases primarily used for formatting,
calculating, printing, and summarizing selected data.
You can even customize the report’s look and feel.
Macros: - Macros are simply shortcuts. If you've ever used macros in MS Word or Excel, then
you are already familiar with what they do. You can create a macro to execute a task that you
would otherwise execute with your keyboard or mouse.
It is possible to modify the design of your table and fields at any time by going to design view and
making the required changes. However, any changes made after data has been added to the table may
cause loss of data. Changes to field names, data types and properties may also impact on other objects
which are linked to or based on the table.
Adding and removing fields
You can modify the structure of your table by adding and removing fields in design view. Note,
however, that using the cut, paste or delete functions will remove the field and any data in that field.
Selecting fields
To select a field, click on the row selector to the left of the field name. To select multiple fields, click on
the row selector and drag the mouse down the selector symbols to select additional fields. The screen
capture below shows a table with two fields selected.
Deleting fields
1. Select the field or fields to be deleted using the row selector.
2. Press the Delete key on the keyboard, select Delete Rows from the Design tab or right-click on
the row selector and choose Delete Rows.
Inserting fields
A relationship in Access helps you combine data from two different tables. Each relationship
consists of fields in two tables with corresponding data.
Primary key
A primary key is a single field or combination of fields in a table that uniquely identifies each record in
that table. No two records can have the same value in the primary key field or combination of fields.
It is advisable to create the primary key before entering data in a table because Access will prevent
duplicate values being created in the designated field. It is particularly important to set a primary key
when creating relationships between tables as Access uses it to link tables together.
Helpful hint: Records are displayed in primary key order by default.
Setting a primary key
1. Click on the appropriate field name and click the Primary key button on the Design tab.
2. The primary key symbol will appear on the button in the row selector box on the
appropriate row (see the screen capture on previous page).
Setting a multiple field primary key
With a multiple-field primary Key, the combination of the contents of all fields included in the key must
be unique. For example, for a primary key based on the CourseID and CourseDate fields, the same
CourseID and CourseDate combination cannot appear in more than one record.
A foreign key
A foreign key is a field (or fields) in one table that references the primary key in another table. The data
in the fields from both tables is exactly the same, and the table with the primary key record (the primary
table) must have existing records before the table with the foreign key record (the foreign table) has the
matching or related records. Like primary keys, you can define foreign keys in the table declaration by
using the CONSTRAINT clause.
There are essentially three types of relationships:
One-to-one: - For every record in the primary table, there is one and only one record in the
foreign table.
One-to-many: - For every record in the primary table, there are one or more related records in the
foreign table.
Many-to-many: For every record in the primary table, there are many related records in the
foreign table, and for every record in the foreign table, there are many related records in the
primary table.
Page 12 of 98 Ministry of Labor and Operating Database Version -1
Skills
Author/Copyright Application September , 2022
Referential integrity
Referential integrity is a system of rules that Access uses to make sure that relationships between
records in related tables are valid, and that you do not accidentally delete or change related data. You
can set referential integrity when all the following conditions are true:
The matching field from the primary table is a primary key or has a unique index.
The related fields have the same data type. There are two exceptions. An AutoNumber field
can be related to a Number field that has a FieldSize property setting of Long Integer, and
an AutoNumber field that has a FieldSize property setting of Replication ID can be related to
a Number field that has a FieldSize property setting of Replication ID.
Both tables belong to the same Access database. If the tables are linked tables, they must be tables in
Access format, and you must open the database in which they are stored to set referential integrity.
Referential integrity cannot be enforced for linked tables from databases in other formats.
A. Form C. Report
B. Table D. All
_______2. database object that you can use to create a user interface for a database application.
A. Macros C. Report
B. Form D. All
_______3. Which one is a single field or combination of fields in a table that uniquely identifies each
record in that table
_______4. Which one is a field (or fields) in one table that references the primary key in another table
_______5. Which one of the following is used in access helps you combine data from two different
tables?
Step 6: - Insert the filed name in to table with datatype and size
Step 7: - Right click on table name and select datasheet view and click on “Yes”
Task 2:- Insert filed name with appropriate datatype and size or format
This unit is developed to provide you the necessary information regarding the following content
coverage and topics:
Adjusting page layout
Opening and viewing different toolbars
Formatting font as appropriate
This unit will also assist you to attain the learning outcomes stated in the cover page.
Specifically, upon completion of this learning guide, you will be able to:
The ribbon is the strip of tabs across the top of the program window that contains groups of
commands.
The Backstage view is the collection of commands that you see on the File tab on the ribbon.
The Navigation Pane is the pane on the left side of the Access program window that lets you
work with database objects.
2.2 Adjusting page layout
Layout view
when printed. However, you can also make changes to the report design in this view. Because you can
Page 19 of 98 Ministry of Labor and Operating Database Version -1
Skills
Author/Copyright Application September , 2022
see the data while you are modifying the report, it's a very useful view for setting column widths, add
grouping levels, or performing almost any other task that affects the appearance and readability of the
report. The following illustration shows a student report in Layout view.
Design view
Design view gives you a more detailed view of the structure of your report. You can see the header and
footer bands for the report, page, and groups. The report is not actually running in Design view, so you
cannot see the underlying data while working; however, there are certain tasks you can perform more
easily in Design view than in Layout view. You can:
Add a wider variety of controls to your report, such as labels, images, lines, and rectangles.
Edit text box control sources in the text boxes themselves, without using the property sheet.
Change certain properties that are not available in Layout view.
The following illustration shows a student file report in Design view.
In this lesson, you will familiarize yourself with the Access environment, including
the Ribbon, Backstage view, Navigation pane, Document Tabs bar, and more. You will also learn
how to navigate with a navigation form, if your database includes one.
Access 2016 uses the Ribbon to organize commands, just like in Access 2013 and 2010. If you've used
these versions before, Access 2016 will feel familiar. But if you are new to Access or have more
experience with older versions, you should first take some time to become familiar with the Access 2016
interface.
Page 20 of 98 Ministry of Labor and Operating Database Version -1
Skills
Author/Copyright Application September , 2022
Note: - Click the buttons in the interactive below to become familiar with the Access interface.
Ribbon
Access uses a tabbed Ribbon system instead of traditional menus. The Ribbon contains multiple tabs,
each with several groups of commands. For example, the Clipboard group on the Home tab contains
commands such as Cut, Copy, and Paste.
The Quick Access Toolbar, located above the Ribbon, lets you
access common commands no matter which tab you are on. By
default, it shows the Save, Undo, and Redo commands. If
you'd like, you can customize it by adding additional
commands.
1. Click the File tab on the Ribbon. 2. Backstage view will appear
Navigation pane
1. To minimize the Navigation pane, click the double arrow in the upper-right corner.
The Font Size property uses the following settings. (Default for
all reports and controls except command buttons) The text is 8-
point type.
The Short Text and Long Text (also called Memo) data types
do not have predefined formats. The Short Text data type has
only custom formats. The Long Text data type has both custom
and Rich Text formatting. If you don't specify a format, Access
left aligns all text in datasheets.
Typically, you apply custom formats to Short Text and Long
Text data types to make the table data easier to read. For
example, if you use a form to collect credit card numbers, and
you store those numbers without spaces, you can use a custom
format to add the appropriate spaces to make the credit card numbers easier to read.
Custom formats for Text fields can have up to two sections. Each section contains the format
specification for different data in a field.
Setting Description
8 (Default for all reports and controls except command buttons) The text is 8-point
type.
10 (Default for command buttons) The text is 10-point type.
Other sizes The text is the indicated size.
Page 23 of 98 Ministry of Labor and Operating Database Version -1
Skills
Author/Copyright Application September , 2022
Table 2. 1 Default value of text and buttons
Self-check 2
___1. Which one of the following in the maximize size of text data?
A. 256 C. 255
B. 1010 D. 1000
___2. Which one is a strip across the top of the program window that contains groups of
commands
A. Ribbon C. Folder
B. Toolbar D. File
___3. ____ is the pane on the left side of the Access program window that lets you work with
database objects.
A. Navigation Pane C. Backstage view
B. Ribbon D. All
___4. Which one is the most intuitive view to use for report modification
A. Layout view
B. Design view
C. Datasheet view
D. All
___5. Which one data type has both custom and Rich Text formatting.
A. Long Text
B. Short Text
C. Number
D. All
Page 24 of 98 Ministry of Labor and Operating Database Version -1
Skills
Author/Copyright Application September , 2022
Part II: - Give short answer for the following questions
1. List and explain types access environment?
2. Discuses types of datatype used in access 2016?
3. What is the main advantage of Quick Access toolbar?
This unit will also assist you to attain the learning outcomes stated in the cover page.
Specifically, upon completion of this learning guide, you will be able to:
Design reports to present data in a logical sequence or manner.
Modify reports to include/exclude additional requirements.
Distribute reports to appropriate person in an approved format.
The good news is reports in Access are just like any other reports you would create. Reports organize
and present information from your database in an attractive and easy-to-read format. You can print or
A report can be created by selecting Create Report on the ribbon. The table or query that is selected
in the object browser when we press Create Report will become the record source of the report. As
with forms, reports can be created in other ways (as blank reports or with the help of a wizard). In this
section we will just look at the simplest type which is a report based on one table. We can select the
table Student in the object browser and press Create Report on the ribbon. The new report will look
like this:
A report is an object in MS Access that is designed for formatting, calculating and printing selected data
in an organized way. It contains information from tables and also information that are there in the report
design. Reports are helpful as they allow you to present all information of your database in an easy-to-
read format.
Formatting reports is one of the strengths of reports is that you can modify their appearance to make
them look how you want. You can add headers and footers, apply new colors, and even add a logo. All
of these things can help you create visually appealing reports.
Let’s take an MS Access databases example of ‘Contact’ DB default report – ‘Phone Book.’
Step 1) Click on ‘Phone Book’ under ‘Report’ section. The system will open the inbuilt ‘Phone Book’
report. It will display Contact Name, Home, Business and Mobile name displayed for each record
present.
Step 3) Edit the name you want to update and Press ‘Ctrl+S’.
Report Wizard
This tool makes it easier to create reports from multiple tables and multiple queries.
In the Create tab Reports group Report Wizard :
When satisfied with the layout of your report, click Next, enter a title for the report, select whether
you want to preview or modify its design, and then click Finish.
3.5. Distributing reports to appropriate person in approved format
3.5.1. Distribute a report
Liberate your Access reports and distribute them far and wide. For example, email them to one or more
users, export them to SharePoint document libraries, and archive them on network folders. When you
distribute an Access report, you create a static report of data at a certain moment in time, such as daily,
weekly, or monthly. By doing so, you have a single point of truth that information workers can use to
make good business decisions, answer questions, find alternatives, determine best plans, evaluate risks,
and improve quality.
Note :- When you create the report, add a publication date. This helps users confirm the correct time
the report was created.
Note:- Although there are a variety of formats you can select, consider using Portable Document
Format (PDF) which has become a defacto standard, preserves the layout and format of the original
Access report, and has built-in ways to customize the pages for viewing and printing.
4. Access opens a new e-mail message in Outlook with the file attached.
5. Type the recipients' e-mail addresses in the To and Cc boxes, a description in the Subject box, and a
message in the message area.
Tip By default, the file that you send by using this method is not saved on your computer. If you want
to save a copy of the file on your computer, right-click the attachment in the Attached box, and then
select Save As.
6. Select Send.
Self-check 3
A. Form C. Query
B. Report D. All
4. ___is one of the strengths of reports is that you can modify their appearance to make them look
how you want.
A. Formatting reports
B. Report view
C. Display view
D. All
5. How many fields are used for sorting access database data report
A. 5 Fields
B. 4 Fields
C. 3 Fields
D. 1 filed
7. Which one of the following is the advantage of design report?
A. Add header on the report
B. Change the field of the report
C. Easily to read and view
D. All
Grad
Student name Gender Age Level e
Tolosa Mohammed M 20 V C
Biruk Teshome M 19 II NYC
Astir Getnet F 17 IV C
Chaltu Solomon F 18 I C
Kedir Mehamed F 18 I NYC
Note :- Give appropriate data type for the above field
Steps in doing the task
Step 1: - Create database called college and table student
Step 2: - Insert the above given data
Step 5:- Right click on report table name and select Report view then print preview
Grad
Student name Gender Age Level e
Tolosa Mohammed M 20 V C
Biruk Teshome M 19 II NYC
Astir Getnet F 17 IV C
Chaltu Solomon F 18 I C
Kedir Mehamed F 18 I NYC
Note :- Give appropriate data type for the above field
Steps in doing the task
Step 1:- Use the above operation sheet of 4.1 steps 1 and 2
Step 2:- Select the table name and click on create Report wizard
Step 3: - select and move the field and click on Next Next Next sort by “ID”
Note :- This is the last output of the student using report wizard and using specific filed of the table
Quality Criteria:- Create student report using Report wizard
Id_No Employee name Gende Age Level Salary Department Phone number
r
Ep_01 Tale Ayemew M 34 B 8078 Auto 0912312231
Ep_02 Ayenalem Baye F 35 A 10231 ICT 0924535142
Ep_03 Dawit Slemon M 43 A 8012 GMF 0923234342
Task 1: - Create the above database and table and save on desktop
Task 2: - Insert the above data into your data
Task 3: - Using report wizard and use any three filed of the table prepare employee report
This unit to provide you the necessary information regarding the following content coverage
and topics:
Creating a form
Modify database forms
Rearrange object with form
This guide will also assist you to attain the learning outcomes stated in the cover page.
Specifically, upon completion of this learning guide, you will be able to:
Use wizard to create a simple form
Open and record existing database through a simple form modified
Rearrange objects within the form to accommodate information requirements
Forms can be used both for adding and editing data, as well as for browsing and presenting data.
In Access 2016, a form is an object that generally serves three purposes:
1. To allow users to perform data entry. Data can be inserted, updated, or deleted from a
table using a Form object.
2. To allow users to enter custom information, and based on that information perform a
task. For example, you may want to ask a user for parameters before running a report.
3. To allow users a method of navigating through the system. For example, you may
create a form where a user can select a form to load, a report to run, etc.
Plus, to that of the above purposes a form is: -
A form is a database object that you can use to create a user interface for a database
application.
It mainly used to ease the process of data entry or editing.
Data in a form can be selected from one or more tables.
Forms can also be used to control access to data, like which fields or rows of data are
visible to which users.
Forms have a Form View.
Help you to display live data with easy creation of new data.
To create access 2016 database form you must select the create tab in the toolbar at the top of
the screen. Then click on the form design button in the forms group. To view the form property
of Access 2010 database, select the design tab in the toolbar at the top of the screen. Then click
on the property sheet button in the tools group. When the Property Sheet appears,
select Form from the drop down if it is not already selected. You should now see the properties
for the Form object.
It is also primarily being 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.
A data-entry form
A switchboard form
There are four primary ways to create the form as mentioned below:
1. Form Wizard 3. Multiple Item
2. Default Form 4. Split Form
Let’s have a look at each option to create the form, one by one:
1. Create using Form Wizard
The wizard lets you make decisions about certain aspects of a form's design and produces a form
based on your instructions. The form wizard gives you more control over your results than one-
click forms do. The wizard lets you make decisions about certain aspects of a form's design and
produces a form based on your instructions. To create a form based on a single table using the
Form Wizard, follow these nine steps.
Note: -This feature works the same in all modern versions of Microsoft Access: 2010, 2013,
and 2016.
This option allows the user to create the form with the wizard and select the column from the
available list of column form in legacy Select window format.
Step 1) Click on ‘Form Wizard.’
Step 3) Select the columns which you want to be there in final form.
Result: ID is selected
Step 5) Layout selection box will appear which allows the user to select the different type of
form layout. Click ‘NEXT’
Step 6) Enter the name of the form as “Contact_Form” and click ‘Finish.’
By default, populate all the column from the selected table in ‘form view,’
The user can delete non-required column manually
Step 1) Select the table for which we want to create the form and click on ‘Form.’
Step 3) Right-click on any cell which we don’t want to be part of final forms and click on
‘Delete.’
Step 4) Press ‘Ctrl+S’ and enter new Form Name as ‘Contact_Form2’. Click ‘OK’.
Result: New form with the name as ‘Contact_Form2’ exists under the “Forms” section.
Step 2) Press ‘Ctrl+S’. Enter the new form name and click ‘OK.’
Page 47 of 98 Ministry of Labor and Operating Database Version -1
Skills
Author/Copyright Application September , 2022
Result: New Form with the name as ‘Contact_Form_Multiple_Item’ exists under the “Forms”
section.
Step 2) Press ‘Ctrl+S’ and enter the new form name. Click ‘OK.’
Layout View: - this view is similar to Design View but is more visually-
oriented in that each control displays real data. As a result, this is a very useful
view for setting the size of controls, or performing many other tasks that affect the visual
appearance and usability of the form.
Design View: - this view gives you a more detailed view of the structure of
the form. You can see the header, detail, and footer sections for the form.
You cannot see the underlying data while you are making design changes.
To open an existing form:
1. Open your database and locate the Navigation pane.
2. In the Navigation pane, locate the form you want to open.
Step 3) Manually fill the data from Form. Note that in split form all data will be automatically
reflected in below data sheet as well.
The Rearrange objects commands make permanent changes in your form. Save a copy of your
form before making such changes. Rearranging the page order in the design form work screens.
Do one of the following: On the Arrange tab, in the Table group, click the layout type that you
want for the new layout (Tabular or Stacked).default, when you create a new form by using one
of the form tools on the Create tab, or when you add fields to a form while it is open in Layout
view, Access puts text boxes and other controls in guides called layouts. A layout, indicated by
an orange grid around the cons you align controls horizontally and vertically to give the form a
uniform appearance. The following illustration shows a "stacked" layout on a form that is open
in Layout view:
To move a field:
1. Locate the field you want to move, then hover your mouse over the bottom border of the field
header. The cursor will become a four-sided arrow. Hovering the mouse over the field.
2. Click and drag the field to its new location. Moving a field.
3. Release the mouse. The field will appear in the new location.
Although layouts can help you quickly create and modify a form, in some cases, you might
prefer having the ability to move and size controls
independently. This article describes how to remove controls
from layouts, after which you can move and resize them
without affecting other controls.
3. Drag the layout by using the layout selector at the upper-left corner of
the layout.
If you want to create a way for users of your form to quickly perform specific actions and tasks,
consider adding command buttons. When you create a command button, you specify an action
for it to carry out when clicked. By including commands for common tasks right in your form,
you're making the form easier to use.
Access offers many different types of command buttons, but they can be divided into a few main
categories:
Record Navigation command buttons, which allow users to move among the
records in your database.
Record Operation command buttons, which let users do things like save and print
a record.
Form Operation command buttons, which allow users to quickly open or close a
form, print the current form, and perform other actions
Page 56 of 98 Ministry of Labor and Operating Database Version -1
Skills
Author/Copyright Application September , 2022
Report Operation command buttons, which offer users a quick way to do things
3. Choose the desired location for the command button, then click the mouse.
4. The Command Button Wizard will appear. In the Categories pane, select the
category of button you want to add. We want to find a way to move more quickly
to specific records, so we'll choose the Record Navigation category.
5. The list in the Actions pane will update
to reflect your chosen category. Select
the action you want the button to
perform, then click Next. In our
example, we'll choose Find Record.
A. Form C. View
B. Design D. All
___5. Which one of the following statements is true when your data record is modifying?
A. The existing data is replaced by the new one
B. The existing data is store in other location
C. The old and new data is store in the same table
D. All
Page 59 of 98 Ministry of Labor and Operating Database Version -1
Skills
Author/Copyright Application September , 2022
Part II: - Give shore answer for
1. What is the main purpose of using form in access database?
2. List and explain the way of creating form?
3. Write down the steps the open the existing access database form?
Step 5: - Click here or select all textbox and resize the text box and level
Step 5:- Click on the normal table name and view the modified data
Quality Criteria: Insert the given data and modify the existing data using form
Task 1: - Create access database called college and the table name employee
Task 4: - Modify the last two employee salary into 7000 and 6000 respectively.
This unit will also assist you to attain the learning outcomes stated in the cover page.
Specifically, upon completion of this learning guide, you will be able to:
A query is what you will use to retrieve information from your database. It consists of questions
of which Access will give you the answers in the form of data from tables within your database.
Queries are what make it easy to find data, then create new tables based on the queries.
Queries are a fundamental means of accessing and displaying data from tables. Queries used to
view, update, and analyze data in different ways. Queries can access a single table or multiple
tables. For example, you want to view a list of employee id and name, but you do not want to see
phone number and other data, you can create a query that displays the employee’s id and name
only.
Queries answer a question by selecting and sorting and filtering data based on search criteria.
Queries show a selection of data based on criteria (limitations) you provide. Queries can pull
from one or more related Tables and other Queries. Types of Query can be SELECT, INSERT,
UPDATE, DELETE.
Queries show a selection of data based on criteria (limitations) you provide. Queries can pull
from one or more related Tables and/or other Queries. The Datasheet View of a Query looks like
a Table. All data added or modified in a Query, will be saved in the Table. The Design View is
A query is a derived item in the database meant to answer specific questions that relate to the
information in the database. Queries are handy during data processing.
To find and retrieve just the data that meets conditions that you specify, including data from
multiple tables, create a query. A query can also update or delete multiple records at the same
time, and perform predefined or custom calculations on your data.
A query requests data from the database. At its simplest, a query merely fetches all data from
a single table. But as you create more complex (and more typical) queries, you can assemble
exactly the data you want (i.e. unique sets of data that you require at any given time).
Queries can also be used to execute mathematical and logical functions to obtain certain
information in the database.
Queries are derived from and linked to tables or other queries. (Due to these linkages, they
tend to largely inflate the size of the database and should thus only be used to execute the
intended functions, and stored only if updated information is to be retrieved).
There are various types of queries for different uses but for this session we will just focus on the
Select queries:
Select queries :- A select query is the most common type of query. It retrieves
data from one or more tables and displays the results in a datasheet where you can
update the records (with some restrictions). You can also use a select query to
group records and calculate sums, counts, averages, and other types of totals.
Example: Select all student’s information
Step 1: - Select or click on table name
Step 2: click on queries wizard then
select simple queries wizard and ok
Step 3: - Move all filed from available fields into selected fields by clicking “>>” and Finish
In order to control which records are displayed, you must define criteria in a query. The most
common type of query is the Select Records query which will be discussed below.
To Define Criteria for Your Query:
1. Position your cursor in the criteria row in the field for which you wish to define the
criteria
2. Type the criteria
You can also use the Between operator to filter for a range of
values, including the end points. For example, Between
#2/2/2006# and #2/4/2006# is the same as >=#2/2/2006# and
<=#2/4/2006# .
Contain values that <#2/2/2006# or Returns records where the transactions took place before Feb 2,
fall outside a range >#2/4/2006# 2006 or after Feb 4, 2006.
Contain one of two #2/2/2006# or #2/3/2006# Returns records of transactions that took place on either Feb 2,
values, such as 2006 or Feb 3, 2006.
2/2/2006 or 2/3/2006
Contain one of many In (#2/1/2006#, Returns records where the transactions took place on Feb 1, 2006,
values #3/1/2006#, #4/1/2006#) March 1, 2006, or April 1, 2006.
Contain a date that DatePart("m", Returns records where the transactions took place in December of
falls in a specific [SalesDate]) = 12 any year.
month (irrespective of
year), such as
December
Contain a date that DatePart("q", Returns records where the transactions took place in the first
falls in a specific [SalesDate]) = 1 quarter of any year.
quarter (irrespective of
year), such as the first
quarter
Contain today's date Date() Returns records of transactions that took place on the current day.
If today's date is 2/2/2006, you see records where the OrderDate
field is set to Feb 2, 2006.
Contain yesterday's Date()-1 Returns records of transactions that took place the day before the
date current day. If today's date is 2/2/2006, you see records for Feb 1,
2006.
Contain tomorrow's Date() + 1 Returns records of transactions that took place the day after the
date current day. If today's date is 2/2/2006, you see records for Feb 3,
2006.
Contain dates that fall DatePart("ww", Returns records of transactions that took place during the current
during the current [SalesDate]) = week. A week starts on Sunday and ends on Saturday.
week DatePart("ww", Date())
and Year( [SalesDate]) =
Multivalued fields
Page 78 of 98 Ministry of Labor and Operating Database Version -1
Skills
Author/Copyright Application September , 2022
Data in a multivalued field are stored as rows in a hidden table that Access creates and populates
to represent the field. In query Design view, this is represented in the Field List by using an
expandable field. To use criteria for a multivalued field, you supply criteria for a single row of
the hidden table. To do this:
1. Create a query containing the multivalued field, and open it in Design view.
2. Expand the multivalued field by clicking the plus symbol (+) next to it — if the field is already
expanded, this is a minus symbol (-). Just below the name of the field, you will see a field
representing a single value of the multivalued field. This field will have the same name as the
multivalued field, with the string. Value appended.
3. Drag the multivalued field and its single value field to separate columns in the design grid. If you
want to see only the complete multivalve field in your results, clear the Show check box for the
single value field.
4. Type your criteria in the Criteria row for the single value field, using criteria that is appropriate
for whatever type of data the values represent.
5. Each value in the multivalued field will be individually evaluated using the criteria you supply.
For example, you may have a multivalued field that stores a list of numbers. If you supply the
criteria >5 AND <3, any record where there is at least one value greater than 5 and one value less
than 3 will match.
5.5. Selecting data and display appropriately
Select Create > Query Wizard. Select Simple Query, and then OK. Select the table that
contains the field, add the Available Fields you want to Selected Fields, and select Next. Choose
whether you want to open the query in Datasheet view or modify the query in Design view, and
then select Finish. Access offers several options for making your queries work better for you. In
addition to modifying your query criteria and joins after you build your queries, you can choose
to sort and hide fields in your query results.
When you open an existing query in Access, it is displayed in Datasheet view, meaning you will
see your query results in a table. To modify your query, you must enter Design view, the view
you used when creating it.
There are two ways to switch to Design view:
Input masks
An input mask is used to provide some control over what values can be entered. They are
primarily used in Text and Date/Time fields, but can also be used in Number or Currency fields.
Input Mask are used when data is entered in a fixed pattern of numbers, letters, spaces etc., such
as a National Insurance number but is unsuitable where the pattern varies (e.g. postcode or
telephone number). When you click in the input mask area, a build button appears on the right.
Clicking this button will enable the Input Mask wizard, which will help you select an appropriate
input mask for your field.
A. Report C. Query
B. Form D. Al
3. Which one is retrieves data from one or more tables and displays the results in a
datasheet
A. Is Null C. Like
B. Is Not Null D. All
5. Which one is Returns records where the value is not missing in the give field.
A. Is Null C. Like
B. Is Not Null D. All
6. Which types of filed is used based on the values from an existing data source depend
on the data type of the foreign key
A. Attachment
B. Lookup fields
C. Multivalued fields
D. All
Step 3:- Move all filed from available fields into selected fields by clicking “>>” and Next
Step 4:- click on Next click on NextGive file name and click on “Finish”
Page 84 of 98 Ministry of Labor and Operating Database Version -1
Skills
Author/Copyright Application September , 2022
Operation sheet 5.2 Retrieve information from access database
Step 2: - select table name and click on “Ok” then click “close”
Step 5: click on
Right click on query name and save as
Give name on file and OK
Reference