Unit 9 MS - Access - Basic
Unit 9 MS - Access - Basic
Structure
9.1 Objectives
9.2 Introduction
9.3 Open MS Access application
9.4 MS Access database Objects
9.4.1 Table
9.4.2 Query
9.4.3 Form
9.4.4 Report
9.4.5 Macro
9.4.6 Module
9.5 Create a new database
9.6 Create a new table
9.7 Modify structure of existing table
9.7.1 Change data type of the fields
9.7.2 Add a new field
9.7.3 Delete fields
9.8 Data types supported in table under MS Access
9.9 Primary Key
9.10 Open a database
9.11 Navigate a database
9.12 Browse a table
9.13 Search for records
9.14 Sort records
9.15 Filter records
9.16 The user Interface and behaviour of MS Access
9.17 Copy, paste and move records in a table
9.18 Delete records from a table
9.19 Let us sum up
9.1 Objectives
Microsoft Access is a GUI based powerful database management utility.After
reading this unit, you will gain the mastery in basic skills of the MS Access. You
willbe able:
To create a database to store and manipulate records,
To define fields in a table and set its‟ properties,
To add, delete and edit records, and
To customize the interface and behaviour of the MS Access,
9.2 Introduction
MS Access is a Relational Data Base Management System (RDBSM). It is used
to store and manipulate large number of records in tabular formin a database.
Records under the RDBMS are organized in related tables. A single record is
reflected by a row of the table and columns of the table reflect individual
attributes of records. Columns of the table are recognized as fields of the table.
One database under the MS Access has more than one related tables. One or more
1
fields of a table may be related with other fields of the same table or other tables.
For example,when you create a database of employees of your organization,one
table can store profiles of employees. There is one record for each employee and
all employees are identified by their unique employees ID number. Other table of
the database has month wise details of salary, other financial benefits availed and
third table of the database may store health records on monthly basisfor all the
employees. There is at least one entry for each employeefor every month in the
salaryand health tables. The RDBMSbased database creates linksin these tables
on the bases of employee ID. This relationship in tables ensuresredundancy in
information, you need not to enter employee profile for every record in salary and
health records table. The profile of each employee is recordedonly once in the
table of profile of employees. Salary and health tables can easily retrieve profile
of concerned employees through link of employees‟ profile table with salary
table. The MS-Access can be used in offices for:
- Store and manage records of inventory such as opening balance, receipt
and delivery of goods.The relationship in these tables results in the current
stock position and utilization of resource in specific period,
- Store detailed profile of customers, there mailing addresses, phone and e-
mail. You can easily filter recordsof the database to confine the listing to
customers situated in a particular city,
- Develop order-supply system,
- Product profile database, and
- Employees database to store profile of employees, their salary, promotion,
health and leave records.
Here we have listed few of the common usage of MS Access in office
environment,however scope and possibilities of the MS Access is endless. The
databases under the MS Access are designed and manipulated on the basis of the
object-oriented concept. Each operation or event is defined as an independent
object under the object oriented programmingconcept. The object oriented
programming concept is popular among computer professionals.
9.3 Open MS Access application
Click on the Start button, takes mouse pointer to Programs on the Start button
menu, wait for next cascade menu to appear. Point to Microsoft Office entry in
the programs menu, wait for next cascade menu to appear. Double click on
Microsoft Office Access 2007to start it or click on Microsoft Office Access
2007and press Enter key.
You can also start the Microsoft Access by double clicking on a database created
or compatible with the Microsoft Access. The database prepared with MS Access
2007 has file name extension accdb. The file name extension of database create
with earlier version of MS Access is mdb. When you open a databasein MS
Access its name appearsalong with „Microsoft Access‟ positioned at the centre of
the title bar of MS Access window.
A database designed in MS Access 2007 could not be opened in earlier version of
the MS Access.If you are planning to use or edit a database in earlier version of
the MS Access then save this database in a format compatible with the earlier
version of the MS Access. Click on Office Button, point to Save As option of the
Office button menu, a new cascade menu appear, click on Access 2002-
2
2003database or Access 2000 databaseoption, you will get the following
window todecide the folder where database is to be stored. Enter the name of file
and click on Save command button.
Fig. 1
The first window of the MS Access is shown below. The left side pane in the
window displays the names of folder, where database templates for designing of
database are stored. Click on specific templates folder to display miniature of
templates from that folder in the middle pane of window. The right segment of the
window displays list of databases opened recently. You can create a new database
by selecting a specific template or New Databaseoption. You can open recently
opened database by double clicking its name from the right pane of fig. 2.
Fig. 2
The ribbon of the MS-Access consists of Home, Create, External Data and
DatabaseToolstabs. The Home tab is the default tab of the ribbon. When you
click on the title of the tab, concerned commands are reflected in the ribbon.The
structure and display of the ribbon is not static in nature. The ribbon changes view
and commands depending on the objects opened and task performed by you at
that time.There are additional tabs, which are context sensitive. These tabs appear,
only when you perform action on specific objects of the database. These tabs
disappear automatically once yourfocus gets away from that object. For example,
when you design a table then the ribbon displays a set of commands assist in
designing of table. Tab of these commends is titled as table tools design.
When you open a database, the first screen will look like this. The database
window has two vertically positioned partitions, the left smaller partition reflects
the list of objects in the active database and right side larger pane displays the
3
object selected in the left pane. The left side pane is recognized as navigation
pane and right side pane is recognized as database window.
Fig. 3
9.4 MS Access database objects
Information and procedure for inputting, retrieving and printing data of in a
database under the MS Access are stored in the forms of objects. All objects of a
database are, stored in a single database file. A database in MS Access may
consist of sixtypes of objects i.e. Table, Query, Form, Report, macro and
modules. Objects of similar type in a database are displayed as a group, in the
navigation pane headed by namesof object. Click on any specific object title, all
objects from that category are listed under this heading. You can edit or execute
an object by selecting it in the navigation pane. The active object is displayed in
the database window. MS Access supports the following type of objects:
9.4.1 Table:Table is the most fundamental object of a database, used to store
large volume of records.Each row of a table is an independent instance of the
subject. Each row reflects a single record. Each record is characterized by many
related attributes, reflected in column in the table, which are called fields. Each
field is discrete and mutually exclusive. An Access table can have up to 255 fields
and can contain up to 2 million records. Access offers various options to add,
delete or modify records. Records from two or more files can be merged or linked
to form a single record. Two and more tables can be joined by linking common
and unique fields of tables. Records of the tables can beeasily imported or
exportedto other applications used frequently in offices. Records in tables can be
sorted or filteredon the criteria specified by you to focus on confined numbers of
records.
9.4.2 Query: A query is a question posed by you to the MS Access to retrieve,
modify or delete records from tables stored in a database. For example, you can
raise a query to list out all customers located in New Delhi or to list out customer
placing order of more than 1000 items in a month or to list out name of customers
who have not made payment for a long time. You specify a criterion for the
selection of specific records from the database.The records (datasheet) returned
on the execution of query is called a record set. You can also confine record set to
display few fields of each record from the tables. Records from two or more
4
tables may be merged during compilation of query. Queries that retrieve specific
records from the underlying tables are called the Select queries. Queries, which
do not provide record set are called action queries. Action queries can be used to
amend, update or delete multiple records at a time from tables and to perform
calculations on the selected records or fields of the table. The Query by Example
(QBE) grid is a standard specification of MS-Access used to design the
queries.Query can acts as a source of information for reports and forms objects.
9.4.3 Form: Forms are used to display records on monitor in more readable,
user-friendly and attractive interface. Forms are used to display, edit or add
records in a database. You can also use forms to export data to other applications.
Every field in the form is linked with the underlying tables.
9.4.4 Report: Reports are used to display records on screen or paper in a
prescribed format. You can rearrange the sequencing of records in specific order
in reports. Different styles and fonts can be used to highlight important
information in the report;data in each sheet of paper is summarized at the bottom
of each page and the entire report is summarizedat the end of the report.
9.4.5 Macro: The macro tool automatically performs a number of tasks and
helps inmaintaining consistence and integrity of the database. A macro consists of
set of commands written in the VB Script language to perform specific tasks.
Multiple operations can be performed in a programmed manner with macros on
the database. Complex tasks can be performed fast and conveniently with macros.
We have already discussed about macro in the unit 6 MS-Word Advanced.
9.4.6 Module: Modules are used to automate operations of the database. The
modules are programme codes designed with the Visual Basic package. They are
more complex than the complexity involve in macros. Forms and reports may
also contain codes. These codes are stored in special class modulesattached to the
form or report. The Class modules are not listed in the Modules section of the
Database Window but can be viewed by clicking the View Code button on the
Design tab of the ribbon, when an object embedded with class modules is in the
design view.
9.5 Create a new database
When you start the MS-Access, the first screen is shown in fig. 2. Click on the
option New Blank Databaseat the top corner of the middle frame of the window
to create a new database.
Fig. 4
You can also create a new database by clicking on the OfficeButton , click on
New option under the OfficeButton menu. The next screen offers a number of
templates to design database to meet specific needs of the users. Some of these
templates are offered as integrated package of the MS Access. Other templates
need Internet connectivity to download and use. There is also an option as shown
in Fig. 5 to start a blank databasein this window.
5
Fig. 5
Databases are assigned names, by default, alike other components of MS-office in
sequential manner such as database1, database2, database3 etc., default names can
be changed later. At the bottom of the right side pane of the window in fig. 5,
enter a name for the new database and then click on the Create button to design a
new database. The next display in the database window is shown below. The MS
Access creates tables, forms queries etc. in a database as shown in fig. 7. A
database with a table and this table is opened in Datasheet view, by default. This
table is named as Table1. You can enter data directly in this table. The fields of
the table are assigned names as field1, field2 etc and fields type is decided by
values fed in each field the first record.Types of field are explained later in this
unit.
Fig. 6
The navigation pane allows you to create new object, open or modify the existing
objects of the active database. The navigation pane displays a list of all objects in
the current database i.e. tables, queries, forms, reports etc. Only objects title is
listed in the navigation pane. Objects of specific type are displayed in the
hierarchal manner, by clicking on symbol on the right side of the object‟s title.
The icon change to in expanded form and all objects under that group are
listed in the navigation pane. Click on to collapse all the items under that
group. The entire list is collapsed and icon is again changed to icon. This
way, you can expand and collapse the listing of objects in the navigation pane.
Click on specific object, in expanded form, result in opening of that object in the
database window. Click on the double arrow icon in the navigation pane‟s
upper right corner to expand and collapse the Navigation pane.The double arrow
change to when navigation pane is expanded. Click over icon minimise
the Navigation pane in the form of a vertical wide line and direction of double
arrow change from to as shown in right side picture of fig. 7. You can also
use F11 key to hide or display the navigation pane. This function Key works in
toggle mode.
6
Collapse navigation pane
Collapse objects
Expand objects
Fig. 7
If navigation pane is not visible then you can make it visible by clicking of Office
Button, click on Access Options. The following window emerges on the screen.
Click on Current database in the left pane of the window. Click on the check
box of the Display Navigation Pane label. The navigation pane is hidden only for
active database.
The left side of the status bar of the MS-Access displays the status of the object
under focus. There are icons on the right side of the status bar for display modes
supported for the object under the focus. The display mode of active object can be
changed by clicking appropriate icon in the status bar.
9.6 Create a new table
Click on Create tab, click on Tableicon under the Tables subgroup. A new table
is created in the Datasheet view. The Datasheet view allows you to add data
directly in to table. Fields in the tables are assigned namesby default such as
field1, field2, field3 and so on. Click in row below the labels of fields of table,
type data to create new fields. The properties of fields are automatically set by
values entered in first record of the table.
Fig. 9
Enter all records in your table and click on the Office Button then click on Save
command from this menu or use Ctrl + S shortcut to save the table. If table is
saved first time, then a dialogue box appears on the screen to seek name of table,
enter name of the table and click on the OK button. Click on Close Databasein
the Office Button menu to close the database. Now your first database with one
table is created. Click on Exit option from Office button menu to quit the MS-
Access or click on Close button (X) on extreme right corner of the title bar. You
should make sure that all databases are closed before quitting MS-Access.
The Datasheet view as shown in fig. 9 displays your table in tabular form, all
fields of a record are displayed in a row. The entire database window is occupied
by rows of records of active table under the datasheet view. Click on Datasheet
7
view icon under the Views sub-group of the Home tab of the ribbon to
display focused table in datasheet view. You can easily add, edit and view records
of a table in datasheet view.
The Datasheet view mode is used to design simple database, it does not offer
much control over the designing of the table. You take your table in the Design
View mode ( ) to gain more control over the attributes and structure of
individual field of the table, while designing structure of table.You can easily
define structure of a table under the design view mode. You can restructure
existing tables. First, double click on the table name in the navigation pane; the
table will be opened in datasheet view mode. Click on the arrow key () of the
View icon, under the Views subgroup on the Home tab. You will get list of views
supported for the selected objects. Select the Design View option. The Design
view displaysthe detailed structure of the table. Once you click on design view
tab, the windowon the right side of the navigation panetakes the following
shape.The table design views display two tables placed in staked manner. The
upper table has three columns reflecting name of field, data type and description
of the field. This table displays list of all the fields in the underlying table. The
name of field can have up to 255 characters. The name of the field should be
chosen carefully, it should reflect on type of data stored in that field the table. The
bottom pane shows the properties of the field in focus in the top pane. The button
pane is called Field Properties window.A field has certain defining characteristics
which are reflected in the field properties of window. Each field has data type,
how much storage space is set to record data in each field. You can define
appearance and behaviour of the field while displayed on the screen. The format
and mask property defines the field‟s display layout. The fields‟ properties
window also defines what kind of data can be stored, data format, any filter,
checks or validation on data before inserting in the table. Entries in field property
window pane change automatically as you change focus to other field in the top
pane.
Some time, data in tables are not entered directly, but they are drawn from other
tables. Such data are recognized as secondary data. The Lookup property of
table in the field property window can easily manage and control linkup of table
acting as source for the current table.
Fig. 10
There are many options,which allow us to control the behavior of data and make
the presentation of data more impressive. The lower portion of the window, define
the property of the field selected in upper pane of the window. This portion has
8
two tabs. The General Tab defines the property of the field under focus. The
contents of the General tab varyfrom one field to another based on data type of
the field under focus. You can set specific property of field under focus by
clicking corresponding text box of that property under the General tab or press F6
and then move to the specific property by using the arrow keys. If selected
property of field can take limited number of alternatives then all these alternatives
are reflected as combo box. Select one of the options from the combo box. The
General tab of the field property window can define following properties for each
field of the table.
Field
property Description
Field Size Set the maximum size for data that can be stored in the field. The
nature (type) of datadecides the maximum length of the field. For
example, a field with number data type can be further classified as
integer, long integer, double integer, or AutoNumber types. Each
type decides the maximum size of the number field.Similarly text
field have maximum 255 characters.
Format Customize the way the field appears when displayed or printed.
Internal data storage in the table is not affected by the format set
by you
Decimal The number of digits after decimal places in number and currency
Places fields
Input Mask Create a format or pattern to guide data entry and display in
readable form. Additional character (/,-, ( ) etc.) can be added in
the mask for impressive display of data. The additional characters
of the mask are not saved as a part of the data value. The masked
field must be text not numeric. The input mask can be added later.
Input masks display data correctly only when data have fixed
length across the table. For example, Phone number can be
masked as „(Country Code) State Code-Phone number‟. Even for
local phone, you have to add country code and state codefor
consistent display of telephone numbers across the table.
Caption Caption is label for the field, which is displayed on forms, reports,
and queries. If you do not provide caption to any field then Access
will use the field name as the caption
Default Value Automatically assigned value to a field, when new records are
added to a table. Frequently occurring value of a field is assigned
9
as the default value. For example, whenyou are creatinga profile of
students enrolled in the higher education in Delhi, then nationality
of students by default can be set to Indianas, there are very few
foreigner students in the higher education in Delhi. Similarly,
when you are creating a database of books issued by the library
than date of issuing of book can be set to current date. There is one
record for each book issued to students. You will add a field to
record with current date as the date of issuing of the books and due
date of return of book will be set by default 14 day ahead of the
current date. The current date and time can be added to a field by
Now() function. Add date() function in Default valueto insert
current date
Validation This rule limits the value can be added in the field. An expression
Rule that must be true whenever you add or change the value in this
field.When you click over this propertyfield,an ellipsis button
appears at the end of the text box. Click on it to add the validation
rule. An example to set the validation rule is given below
Required Specify whether a value must be entered in the field. The default
value of this attribute in No, in this situation you can save record
without value in this field.
AllowZero If this attribute is set to yes then you are allowed to leave this field
Length blank. This attribute is applicable onlyin the Text or Memo fields.
The field of the table which is used as primary key (identify
record) should never be set to zero.
UnicodeComp This attribute is used to Compress text stored in text, memo and
ression hyperlink fields when a large amount of text is stored (> 4,096
characters) in the field.
10
conversion of characters in an Asian version of Windows
(Japanese or Korean). Default value of this property is set to No
Control
IMESentence Specifies type of data that can be entered with an Input Method
Mode Editor (IME). This functionworks only when IMEMode is set to
Yes and control conversion of characters in an Asian version of
Windows.
SmartTags Attach a smart tag to the field or any control bound to the
field.Smart Tags recognize the types of data in a field and allow
you to take action based on the type of data. For example, when E-
mail Address field is attached a Smart Tag, it can start a new mail
message or add the address to a list of contacts.
TextAlign Specify the default alignment of text within a field, this property
takes any of the values i.e. General, Left, Centre, Right and
justified. These options are explained in detail in MS-Word units.
Append Only Determines whether to track changes in values of field. There are
two possible values for this property Yes, it Tracks changes. To
view the history of field values, right-click the field, and then click
on Show Column History,when you display the table in datasheet
view. When you set this property as No. it does not track changes.
The track change enabled property increase the size of database, so
keep this property active only for significant fields.
Scale Specify the maximum number of digits that can be stored to the
right of the decimal separator.
11
If you want more space to set or edit a property in the property box, press Shift
+F2 to display the Zoom box, enter the property or expression and click on OK
Button. When you are entering an input mask or validation expression and
would like to take help in building it, click on next to the property box to
display the appropriate builder. To save your changes, click on Saveicon on the
Quick Access Toolbar,use Ctrl + S shortcut or use Save command from the
Office Button menu.
Data of number type in a table can be further classified as Byte, Integer, Long
Integer, Single, Double or Decimal. Maximum and minimum values those can
be entered in different number typeare reflected in the table.
Byte 0 to 255
Table 1
Another tab of Field Properties pane is Lookup, which is used for creating
lookup information from another table in the current table. You can link-up a
field of another table to the field in focus in the current table, through look-up
information tab. For example, Employees Profile table stores employee ID,
Name and address and the Payment table stores only employee ID and payment
details. By using Lookup property, you can establish link between both the
tables on employee ID field. In the starting, you can use the lookup wizard to
establish the lookup field
1. Open the Payment table, where you have to set lookup field, take table in
the Design View by clicking on the arrow key under View icon of
theViews subgroup of the Home tab and select Design View option.
2. Take focus to field where look up property is to be set, In the Data
Type column of this select click on the Lookup Wizard, you will get the
following window
Fig. 10
12
3. On the first page of the Lookup Wizard, click to select option I want the
lookup column to look up the values in a table or query, and then
click Next and get the following window
Fig. 11
4. First, decide whether look up information will be provided by table,
queries or both. Click on the table, which will provide look up of the field
under the focus, for current example, select Employees table from the list
of tables, and then click Next.
Fig. 12
5. Double-click the Emp ID field under the Available fields label, the field
is added to the list of Selected Fields: frame, and then click Next
Fig. 13
6. You can decide the sortingorder of field chosen in the last step, regardless
of order of these fields in the current and source tables. The sorting feature
is limited to four fields. If you are not interested in sortingentries of the
field,you can simply move to next stage without making any sorting by
clicking on Next button at the bottom of window. In later case, when no
sorting is applied, order of display of field in the current table is in the
13
order of lookup table.The next window decides the display behavior of the
lookup field.
Fig. 14
7. Make sure that the Hide key column check box is selected. Once you
agree with display of the lookup column then click Next.
Fig. 15
8. Assign name to label your lookup column, by default it is the name of the
field used in lookup table. Click on Finish button to completethe
LookupWizard.
9. Save table structure before closing the table. If you have not assigned
primary key for the table before closing, then MS Access desires from you
to assign primary key for the table.
10. Click on Yes option to add a primary key to the table and assign primary
key for the table. The primary key is used to assign unique identity to all
the records in the table, further details about the primary key is explained
later in the unit.
Notice the impact of the lookup feature on display of the table by opening it
under the datasheet view. The name of the employee appears as drop-down
list, when you add new record to table. Now, you cannotenter wrong
employee ID,you need not to remember employee ID and type the name of the
employees. The database does not add records with non-existing employee ID
in the Employees Payment table after establishing link with employees table.
14
Fig. 18
Open a database. Expand the list of database‟s table objects in the navigation
Pane. Double click on the table‟s name to open it in the datasheet view. The
datasheet view is the default view mode. Records are displayed in tabular form
under the datasheet view. When fields in the table cannot be accommodated in the
width of database window then use horizontal scroll bar to display fields, which
are not visible in the window. Similarly, use vertical scroll bar to display records,
which cannot be accommodated in window. Users can simultaneously see
adjacent records under the datasheet view, which can be accommodated in
database window; you can easily make comparison in adjacent records. Records
can be easily edited or added under the datasheet view.
9.7 Modify structure of the existing table
The Structure of table can be changed quickly in database view so display table in the database
view.
9.7.1 Change data type of the field
When a table is opened in the data sheet view,theTable Toolstabappears on the
ribbon. Click on the head of the field where field‟s type is to change. On the
Table Tools tab, under the Data Type & Formatting subgroup, click the arrow
() on the combo box of the Data Type: label to get a drop-down list of data
type supported by the MS Access and then select a data type need for the focused
field.
Fig. 17
9.7.2 Add a new field
Take the table to the datasheet view. Click on New Fieldicon under the Fields &
Columns sub-group of the Table Tools tab, the Field Templates pane appears in
the extreme right corner of the database window to insert one or more fields into
table.
15
Fig. 18
Select one or more fields from the Field Templates pane and drag them to the
table. The pointer change to doted rectangle, when over the table, take pointer
to point where new field is needed now release the mouse button. The field
appears in the datasheet.New field can also be added by double clicking on
field type needed in the table from Field Templates pane, the selected field is
inserted on the right side of field under focus in the table,
Fig. 19
You can also produce lookup effect with the help of Add Existing Fields icon
under the Fields & Columns subgroup of the Table Tools tab. It addsrelated
fields from other tables in to existing table. When you click on Add Existing
Fields, youwill get theField List dialogue window on the right side of table to
add look-up feature in active table. This dialogue window lists all the tables in the
active database, expand these tables and link-up fields of a table to fields of other
tables in existing database.
You can also add new fields to a table in the Design viewmode. Right click on the
adjacent field where you want to insert a new field, click on Insert Rowsoption
from the pop-up menu, a new blank field is inserted into table, right below the
field having focus. Define a name of the newly inserted field and set other
properties as explainedearlier for that field. You can also add fieldby selecting the
field, where new field is needed. Click on Insert icon of fields and columns
subgroup of Table Tool ribbon. The new field is added on the left of focused
field.
16
9.7.3 Delete fields
Take the table in the design view.Right click on the field name to be deleted, click
on Delete Rowsoption from the pop-up menu. You can also delete field by
selecting the field and clicking on Delete option under the fields and columns
subgroup of the Table Tools tab. Once you delete a field from the table, all data
stored in that field get vanished.
9.8 Data types supported in table under MS Access
The MS Access supports 10 different types of data to record information in atable
AutoNumber:A field with AutoNumber field type is assigned positive integer
value in incremental way for every new record. As you add a new record in the
table, the value of field with AutoNumber property increases by one from its
value in the last record. Field with AutoNumber field may be used as the Primary
Key.This data type assigns unique value to each record. The field with
AutoNumber type can be assigned value in random manner, by setting its New
Values property under the Field Properties to Random from the combo box.
Number: Fields can contain only numeric values. The number fields use the
Field Size property to controlthe maximum number that can be recorded in the
field. The Field Size property under the Field Properties window can be set to
byte, integer, Long Integer, Single, Double or Decimal.There is a combo box
against the Field Size column to select one of the field size. The maximum and
minimum numbers that can be stored in each field type are shown in table1.
Text: Allows alphanumeric data (letters, numbers, special symbols etc.). Textis
the default data type for each new field added to table. The default width of this
field is 35 in the earlier version of MS Access. In MS Access 2007, the default
width of text field can be controlled from the Excel Options of the Office button
menu. It is explained latter. The maximum number of characters in text field is
255.
Memo: Text field cannot store a string with more than 255 characters. If you have
a string with more character then set the field‟s data type as memo. Memo field
can store information up to 2 GBdata in each record. If you enter data manually,
you can enter and view at most (maximum) 65,535 characters in the field with
data type memo.
Date/Time: This field can record date and/or time values. Dates are
automaticallyvalidated against the calendar. The display of field with data type
date/timeis determined by theRegional Settings of your computer. Internal storage
structure of date/time records remain same in spite of change in display format of
date and time.
Yes/No: Displays as a checkbox and stores one of the two possible values (yes or
no, true orfalse). Access uses -1 for Yes and 0 for No values for internal storage
of data with field type Yes/No. It is displayed as Yes or No on the screen.
OLE Object: Used for storing images, documents, graphs and other external
objects. OLE Object fields create bitmap images of the original object, and then
display that bitmap in fields of the table with data type OLE in your database.
You must have OLE Server registered to run a database with OLE object
Hyperlink: Hyperlink data type is used to store address to a website, networked
document, or for sending an email.
17
9.9 Primary Key
Before finalizing structure of a table, you must assign Primary Key for that table
so that each record of the table can be identified uniquely.You cannot assign same
value to primary fieldsof two or more records. You cannot leave primary key field
blank for any records. The MS Access ensure that primary field value never be
null (blank) and duplicated while you are entering data in the table. The primary
key is used to locate specific records from the table or create links across tables in
multiple tables database. When a table is displayed in design mode then its
primary key field is flagged with a key ( ) on its left side. MS Access assigns
the primary key by default each table to ID field auto number with field type. The
primary key may not always has relevance in the database. If you are interested in
assigning primary key to some other field, take focus to that field and then click
the Primary Key ( ) symbol from the Tools subgroup of the Table Tools tabs
of the ribbon. A table has only one primary key. When you reassign primary key
to other field of the table, the primary key symbol is automatically removed from
the earlier primary key.For example, you can store records of employees and use
employer ID number as the primary number as it is assigned uniquely to each
employee of the organization. If your table does not have any unique value field
then you can use auto number field as primary key to the database. The MS
Access automatically creates an index for the primary key to expedite the
execution of queries and other operations performed on primary key.
You can use primary key of tables to establish links with other tables. For
example an Employees‟ profile table have employee ID number as the primary
key. Another table keeps records of payments of salary to individual employee.
The payment records are kept on the basis of employees ID number. You cannot
pay salary to a person, who is not employeeof the organization. You can establish
link in both tables,to know profile of employees to whom salary is made. This
link also ensures no wrong payment under the salary account. Thus, the Employee
ID is the primary key for the Employees‟ profile table and it acts as foreign key in
the Employees‟ payment table. Thus primary and foreign keys establish link in
tables. A foreign key acts as the primary key in other table, which are linked with
the current table.
Fig. 21
18
Specify the name of folder where database is stored in the Navigation pane on the
left side of the window and then click on the database name to be opened and
click on the Open button or you can double click the name of the database to be
opened.If, at this stage, you may get a security warning under the ribbon
“Security Warning Certain Contents in the database has been disabled”,
Click on Options button,select the "Enable this content" radio button (in the
pop-up window), and then click OK, otherwise you can perform highly restricted
operations on the database. You must ensure that database is free from virus and
system threats codes before enabling the contents.
Fig. 22
The MS Access supports database stored in various formats and designed with
other RDBMS software. The combo box placed in front of Files of type: label in
fig. 21 display list of file formats supported by the MS Access. Select the
appropriate database format to be opened, this step filters the listing of files in the
right pane of fig. 21. If you are not sure about the format of the database then
select All files (*.*) option from the combo box.
When you open a database file, it opens by default in shared mode. You can put
your database in the shared mode, if you are planning to share it other users
simultaneously over the computer network. A number of users can view,add,
delete or edit records at a time in the database, when opened in shared mode.MS
Access databasecan have up to 255 concurrent users.
9.11 Navigate a database
All objects in the opened database are listed under navigation pane. You can
customize the display of the listing of objects of the database. Click on downside
triangle () at the top of the navigation pane, you will get the following window,
listing different styles to display objects contained in the database. Click on
Tables and Related Views to keep all objects across tables related to specific
table together. You can also groupand list similar type of objects across table at
one place by clicking on Object Type option from the following window.
The menu appears on click on triangle of the navigation pane highlight objects of
the opened database displayed in the navigation pane. Items in the list with tick
marks () are visible in the navigate panel. When there is tick mark on the All
Access objects option then you get all the objects of the opened database in the
navigate panel. An object of the database can be hidden by clear the tick marks
() on the name of that object. Items with no tick mark are hidden in the
navigation button.
19
Fig. 23
The display of the navigation pane will be like this, when you select Object
Typeoption.
Fig. 24
When you select Tables and related objectsoption then objects are listed along
with their associated table
Fig. 25
The Create tab of the ribbon offers various options to create different type of
database objects. The commands under the Create tab are grouped as Tables,
Forms, Reports and Others. The Othersub-group of the Create tab offers
commands to design Queries and Macros. The creation of reports, formsand
query are discussed in the next unit.
Table 2
Apart from these buttons in the navigation bar, there is an area in the navigation
bar to surf records of table, to notify the filter criteria and a search box to identify
the record with specific value for a field.
9.13 Search for a record
When you enter text in the Search box in the navigation bar to set the criteria to
locate specific records, the first matching valueof texts entered in the search box
in any of the fields of records of the tableis highlighted as you type the string in
the search box. The search operation highlights field, where text typed in the
search box is a part of the contents of the field. You can use search option of the
navigation bar to quickly search records having specific string in any field of
table.Press Enter key to move focus to other record with matching string in any
field.
If you are interested in finding text in specific fields then first select these fields.
You can select the concerned fields by taking pointer close to header of column of
the table to be selected, pointer change to down side arrow (), click now to select
21
this column. When you have to select more than one columns then first press
Shift key and without releasing this key, select all the fields to be searched then
release the Shift key. When you have to select more than one columns then first
press shift key and without releasing this key, select all the fields to be searched
then release shift key. Click on Find or Replace button under the Find subgroup
of the Home tab or use Ctrl + F shortcut. Function and operation of the Find and
Replace commands are alike the except replace dialogue window as shown in fig.
25, has additional text box to specify the string that will replace the found
string.You will get the following dialogue box on clicking on Find (left side)or
Replace (right side) button. This dialogue box appears only when table, query or
form is active. The window has two tabs Find (left side) and Replace (right side).
The dialogue window under Find tab is on left and Replace tab is on right.
Fig. 25
At the bottom of the window there is Search Fields As Formatted check box,
this box is by default checked. You can search records with specific format when
this check box is checked. However, the searching will take longer time, when
Search Field as Formatted check box is selected. So clear this check box, when
not needed. In the Find What: textbox, type the string to be searched in the
table.
Specify the field to be searched otherwise search will be performed on the entire
table, click the appropriate option in the Look In list. The Match combo box
specifies the criteria to apply the search operation, whether text typed in Find
what: textbox will be searched as a part of field, whole field or at the start of
field. Select Any Part of Field option, to get the broadest possible search. Click
On Find Next button to find next matching word as per the criteria specified by
you. Click on Cancel button in the Find dialog box to close the Find and
Replacedialog box.
When you want to replace the searched text with new one then click on the
Replacetab and enter the replacement string in the Replace with: textbox. When
you click on Replace command the existing text is get replacedwith new string
and next matching field is highlighted, when you do not replace the highlighted
searched text than click on Find Next command button. You can replace all the
repetition of searched string typed in Find what textbox with string typed in
Replace with: textbox by single clicking on Replace All command.
9.14 Sort records
The records in table can be arranged in ascending or descending order of the value
of specific fields. When records of a table are displayed in datasheet view, click
on the arrow key () on the right side of the heading of field (field name), you
will get the pop-up menu with options to sort data on that field, click on the icon
A to Z to arrange recordsin ascending order of values of selected field.Click on Z
to A icon to arrange records in descending order of values of selected field.
Records in the table can also be sorted with options available under the Sort &
22
Filter subgroup of the Home tab. There are icons to sort records of the table
under the Sort & Filter sub group of the table.
Fig. 26
9.15 Filter records
The filter feature is used to confine the display of records to criteria set by user.
This feature is very helpful, when your database has large number of records.
Table can be controlled or edited easily, when filtered. You can set the criteria to
filter records. One way to specify criteria to filter table is to click on arrow key on
the right side of the filed label where you have to set the filter criteria. It displays
values of this field from all the records of the table with marked check box against
each value as shown in fig. 27. You can filter records manually in small database
by clearing checkbox of values not needed in the display. Right click on the
fields, where filter criteria is to be applied, take pointer over the Text Filters
option of the pop-up menu, cascade menu appear to specify the filter criteria,
enter the criteria, and click on OK command to execute the filter criteria set by
you.The field where filter is applied have icon along with name of label. You
can also set the filter criteria by clicking on Filter option ( ) of the Sort and
Filter subgroup of the Home tab. The filter command ( ) offers options for
sorting on filed under focus. The filtering criteria can be cleared and table can be
brought back in original position by clicking on arrow key of Advanced option
under the Sort & Filter subgroup of the Home tab and then click on Clear All
Filtersoption. You can revert the filtering by Undo command from the Quick
Access toolbar or Ctrl + Z shortcut.
Fig. 27
23
9.16 The interface and behaviour of MS Access
You can customize the user interface and behaviour of the Ms Access. Click on
the Office Buttonicon, and then click on Access Options button at the bottom of
the Office Button menu. You will get the following windows on the screen.
Fig. 29
Commands of similar type are grouped together.The left side of the window
displays list of commands groups‟ headings. You can customize user interface
and behaviour of the MS access with the help of these groups. Click on the
Object designer group in the left pane and get the following window. This
dialogue box offers options to customize the behaviour of objects ofa database
under the MS Access. MS Access supportstable, query, forms and reports objects.
Fig. 30
If you need online assistance about MS Access then click on Resourcesbutton in
the Navigationbar of the Access Options windows, you will get list of good
resources recommended by the Microsoft. The default length of text field in
Access 2007 is set to 255. It will consume lot of space for each record, most of
the time this length is not utilized completely by records.Setthe maximum length
of text field to 50 to 100 characters. The Current database option in the left pane
allows customisingthe display of active database while it is in designing and
editing modes. This option also customize display of ribbon and status bar.Once
you set the behavior of the MS Access, click on OK button to close theAccess
Options window. Common shortcuts used under the MS-Access are as follows.
24
Del Clear the value of highlighted field of active
table, if entire record is selected before pressing
Delete key then the entire record is deleted.
Ctrl + X Cut the selected text under the focus and keep
it in the clipboard
Fig. 31
However, this method could not be applied when there are thousand or more
records in the table. You can use delete query in such a situation to delete records
with specific field value.The Delete query is explained in the next chapter.
25
9.19 Let us sum up
MS Access offers powerful set of tools to store and manage the large size
database. It can easily generate reports and retrieve information supportive in
decision making. In this unit, you have understood the designing of a table and
setting attributes of fields of the table. You gain mastery in adding, deleting and
editing records in a table. You have learnt about the options offered by MS
Access under the Access Options of the Office button control to customize the
behavior of the MS Access package. The next unit will explain the advanced
features of MS Access, so that you can quickly create and adapt various tools of
manage database and generate reports to the changing needs of business.
26