Access 2002
Access 2002
Rajendra Salokhe
Page 1
CHAPTER 1
TABLE OPERATIONS AND REPORT
Access is a powerful relational database application made available by Microsoft Corporation. It is
part of the Microsoft office package. ACCESS enables you to create , organise and manage your
data . Access is popularly used as backend tool for Visual Basic.
Database is a systematic collection of data and related information. It is an organised selection
which you can easily retrieve. It is an integrated collection of automated data files which may be
related to each other. In Access database is the collection of tables, queries, Forms, Reports etc.
Data is unprocessed information. If you note down the names and addresses of your friends it is a
data.
Related information is the information stored in tables, queries ,Forms, Pages , Reports, Macros etc.
Relational database is a database where no tables are related but you can relate them when required.
Relational Database Management (RDBMS) supports Client/Server architecture and Distributed
databases. The relationship between tables may be specified at the time of table creation. It supports
high security . Many tables can be grouped under a database.
Data is organised in tables. A table is collection of data pertaining to specific topic. A single table
contains information in row and columns. The rows are called records and the columns are called
fields.
A sample table is as follows
4 Columns
3 Rows
FIG 1.01
There are three rows in this table and 4 columns. The columns are rollno, physics, chemistry and
maths.
CREATING A TABLE
Let use start practically by creating the above table
Step 1 : Double click on the ACCESS icon or choose
START->PROGRAM-> MICROSOFT ACCESS
You will get a screen as follows.
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 2
Click here
FIG 1.02
FIG 1.03
Type field
names and
select type
Format Properties
Type the field names and select their type as shown in the figure. In the left side bottom window the
property 'indexed' is set to 'Yes(No Duplicates)' only for the 'rollno' field. And index makes it easy to
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 3
find data in the fields. An index speeds up queries on the indexed fields as well as sorting and
grouping operations.
When you are through with defining all the columns just close the table window.
Save the table by name 'studentdetail'. You will see this
name added to the database window.
Step 3 Entering the Data
Select Tables
Right click on
table name
and select
open to enter
data
FIG 1.05
Right click on the table's name and select open.Fill the data into the cells.
FIG
1.06
Do not bother if the ID column is shown on to the table. This is a column automatically inserted by
Access. This shows the row or record number. Similarly on extra row is shown at the bottom.
Close the window when you have completed inserting the data. Anytime you can right click on the
table name , open the table and Add/Modify the data.
Step 4
Creating a Report.
However I am making it early to create a report. But let us create a simple report from this small
table and you will find the things easier. Reports provide you an effective way to present the data..
When we make a report we have a control over how to represent it. Access provides Wizards to
create reports. These wizards are very helpful and allow to quickly create the report. The data for
reports is taken from the tables however the titles and labels are permanently stored in the report
format.
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 4
Double click
here
Click on
Reports
FIG 1.07
Select 'Reports' from the left window. Double click on 'Create report by using Wizard.'
Move the fields
with this button
FIG 1.08
The report wizard first screen will appear. Select the fields one-by one and click on the > symbol. If
you want to select all the fields then you can click on >>. Similarly you can deselct the fields by
clicking on < arrow. We have selected the rollno, phy,chem and math fields.
FIG 1.09
Go on clicking NEXT button till you get the above screen. Change the title to 'XYZ School'
Select 'Mo
dify the Report design' and then click 'Finish' button. You will get the screen as shown.
We want to modify the report because we want to add the total of marks.
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 5
FIG 1.10
Make a little room into the Page Header section by pulling it down
from the left side with mouse. You can also move the title to the
centre.
Draw a label
FIG 1.11
Click on 'Label' or 'Aa' symbol on the toolbar and draw a label after 'MATH'.
Now in the detail section we want the calculation to take place. So click on 'ab|' or 'Text Box' on the
tools menu. And draw a text box below the heading 'Tota
l' in the detail section. The text box name as
'Text 16' appearing on the screen may be deleted.
FIG 1.12
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 6
Right Click on the 'TOTAL' textbox and select 'Properties' . The properties screen will appear.
FIG 1.14
Anytime you can right click on the report name and select 'Design View ' to change the report
format.
Right click on
the report name
FIG 1.15
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 7
Now that you have a hand on experience of creating a table and report we will go about with a little
theory. We have chosen NUMBER format for all the fields . However there are other field types
also.
FIELD TYPES
TEXT : Text type data contains characters , numbers (numbers as character) . Text you can
not perform numeric operations as addition,subtraction, multiplication etc on the text data .
NAME , ADDRESS , PIN etc. are some of the text types.
NUMBER : NUMBER field is used for calculative data. This is numeric data on which we
want perform mathematical operations. BASIC, DA , GROSS_SALARY etc are some of the
field type which use NUMBER type data.
DATE/TIME : This type is used for storing dates. There are many formats in which dates
can be stored. DATE_OF_BIRTH , DATE_OF_JOINING etc. are some of the date type
datas.
MEMO : MEMO fields are used to store large amount of data. If you want a note on specific
information then MEMO type is used. Since these fields consume a lot of space the use of
this type is rare.
CURRENCY : This field is used for storing numbers related to currency transactions.
Yes/No : This field stores only Yes/No values or True/False values. These are logical values.
e.g. if you want to indicate weather a bill is paid or not then you can use this type of field.
OLE object : In this field you can embed objects as pictures , graphs from EXCEL etc. OLE
means Object Linking and Embedding. When you link an object this way any change in the
object form will implement change in the object embedded.
Hyperlink : You can store an internet link in this field so that clicking on the address the
web page on internet is displayed.
Lookup Wizard : It starts a wizard that places lookup contraints on the field. The lookup
values may refer to the table , query or the value you enter.
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 8
FIG 1.16
STEP 1 : Double click on the 'Create Table using wizard ' and the 'Table' wizard will popup.
STEP 2: There are 2 categories 'Business' and 'Personal' . you can choose both and view the tables
available. Presently we have selected the 'Personal' category.
FIG 1.17
> arrow.
Add the required fields into 'Fields in new table box' by clicking on
Click next
STEP 3 : Select name for the table or keep the same name. Click next.
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 9
FIG 1.18
STEP 4 : Since we do not want to set relation click once more on NEXT button.
FIG 1.19
STEP 5 : Enter data shown as above and more. Close the browser window. Use tab key to move in
the fields.
CREATE TABLE FROM ANOTHER TABLE
If you want to create a table from another table whose structure is same as of the first table you can
use the Copy/Paste commands . By structure we mean what remains of the table when we delete all
the data. i.e. the field names only.
However you have to remember that some of the properties like primary key properties of the
created table may not be the same.
FIG 1.20
You will be asked for the new table name and the same will be shown in the database window. You
can double click on the name to open the table. It is required that the data entry should be done.
This option can be used to copy all data i.e Structure and Data or append the data to the existing
table. i.e Add data of the current table to the existing table.
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 10
Use COPY ,
PASTE to create
table with same
structure
FIG 1.21
FIG 1.22
STEP 2: You will be required to change the field names. Right click on Field1 choose Rename and
rename the field as Rollno. Similarly rename other fields as Name , Address, City , Pin and Dob.
STEP 3 : Close the window and save the table. Name the table 'studentmaster'
FIG 1.24
STEP 4 : Answer YES for primary key. Your table is now saved.
The primary key and other key concept is explained in chapter 4.
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 11
ENTERING DATA :
There are three ways to enter data
1. In Datasheet view
2. Use Edit mode
3. Use Data entry mode.
FIG 1.25
Change the Data Type of rollno field to NUMBER
Change the Data type of DOB field to DATE/TIME.
Change the format of DOB to Medium Date or short date .
Short date has a format dd/mm/yyyy e.g . 19/06/2006 . Medium date has a format 19-JUN2006
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 12
The date format can be changed to English style by selecting Regional and Language options from
the windows control panel. Select English(U.K.) type there.
Look for this icon in
windows control panel.
FIG 1.26
Right click on the table name and click on 'Open' . The table willpen
o in the data sheet view. This is
similar to Excel worksheet.
FIG 1.27
Similarly complete the table with other values. Note how date is entered.
There is a box at the bottom which is called record selector box, You can navigate the sheet with the
help of various buttons on this box. There are buttons to move on the first record, last record, next
and preceding record.
The record number box
New record button
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 13
FIG 1.28
Click on the New Record button . A new record will be added at the end of the table.
ENTERING DATA USING DATA ENTRY MODE
FIG 1.29
Click on records menu and select 'Data Entry' . Only new added record is shown.
Use tab key to move in the fields.
Our studentmaster table now has the following data. Do not bother about the ID field.
FIG 1.30
DELETING A RECORD
Click here
FIG 1.31
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 14
FIG 1.32
Or you can Right Click on the record and select 'Delete record ' from the pop
-up.
DELETING MULTIPLE RECORDS
Click the record selector for the first record . Then select a group of records by holding down the
shift key. Press delete when the selection is over.
FIG 1.33
In the design view click on the row selector below which you want to add a new field.
Click on 'Insert Row' button as shown in the above figure.
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 15
FIG 1.34
A new blank field will be inserted. Name it address1. Close the windows Now feed data in all
address1 fields by opening the table.
FIG 1.35
Clicking on the field selector will select
the entire column.
STEP 2 : Right Click on the selected column or choose FORMAT-> Hide Columns menu.
STEP 3 : The column will be hidden.
Select hide
Columns to hide
a column
FIG 1.36
STEP 4 : You can unhide the column from FORMAT-> Unhide columns.
The unhide dialogue box will appear. Check the name of the columns you want to unhide.
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 16
Unhide column
dialogue box
FIG 1.37
The ID column will be unhidden.
FIG 1.38
STEP 2 : With mouse drag the column icon to required place
Drag ->
FIG 1.39
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 17
FIG 1.40
In the above example the PHY column has moved to the right of CHEM.
FIG 1.41
STEP 2: Type PHYSICS as the name. The column name will change to PHYSICS.
REPLACING DATA
Data replacement help you to change a particular occurrence of the data with other value. Supposing
you enter MUM in place of MUMBAI while entering the data then you can change all the
occurrence of MUM with MUMBAI through this replacement method.
The options like Replace all are dangerous as they do not give you an opportunity to correct the
error you make. You have to be doubly sure when you use this option. Finding the next occurance
and replacing is always the safer option
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 18
FIG 1.42
Replacing Pune
with Mumbai
STEP 3 In find and replace box the value Pune is shown. This is to be replaced with Mumbai so type
Mumbai after 'Re
place with'
STEP 4 Click on 'Replaceall' so thatall the occurrences of 'Pune ' will be replaced with 'Mumbai'
FIG 1.44
You can also use the wild cart to search field values . Some of the examples are as below
Example
What it matches
Sample find
P*
values starting with P
Patekar , Punekar
*kar
Values ending with kar
Karmarkar , Chiplunkar
D?te
One character for ?
Date , Dite
J[aio]n
One of aio
Jan, Jin , Jon
P[x-z]
Range
Px, Py, Pz
A#
Number in place of #
A1 , A2, A3 etc
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 19
DEFAULT VALUES
Sometime we need that the table field should accept a default value . Which means when we add a
record the field should be filled with this value automatically. We have to specify the default values
in the Table design view.
STEP 1 : Right click on the table name . Choose Design View.
STEP 2: Click in the City field.
STEP 3 : In General Tab (Left down window) . Type Pune in default value.
Any new record you will add will have the default value 'Pune'. You may change it if required.
INPUT MASK
Input masks are useful to display the field values in required formats. Input masks work only on
character and date fields. As you can display PIN as 415-605 with the help of input mask. We have
earlier used a 'Medium Date ' mask for the date field.
Input mask consists of literal display characters as parentheses, periods, and hyphens and mask
characters that specify where data is to be entered as well as what kind of data and how many
characters are allowed.
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 20
FIG 1.46
Click here
FIG 1.47
STEP2: Click on the add new record button. Which has a symbol as >* . In the Customise input box
wizard.
Input Mask
FIG 1.48
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 21
FIG 1.49
The following characters can be included in the input mask.
Character
0
9
#
L
?
A
a
<
>
Field using
input mask
Function
number from 0 to 9 , no +/- signs
0 to 9 and space
Optional number, space and +/- sign
Letter required A-Z
optional letter
letter or number
optional letter or number
character gets converted to lowercase
character gets converted to upper case e.g >LL
------------------------------------------------------------------------------------------------------------
EXERCISE
Rajendra Salokhe
Page 22
Exercise 1 : Create a table (Employee Table) with following fields . Enter values and print report.
EmployeeNo
BasicSalary
DA
GrossSalary
Deductions
NetSalary
NetSalary will be calculated as GrossSalary - Deductions
Question 1: How can you create a new table?
Question 2 : How do you rename the field ?
Question 3: How can you add a new field to existing table ?
Quetion 3: What are the various field types ?
Question 4 : How can you replace data in the table ?
Question 5 : What are input masks ?
Question 6 : What are default values ?
Question 7 : How can you delete a record ?
http://www.geocities.com/arutacomp/
or
[email protected]
other books :
AutoCAD 2007
Visual Basic 6
------------------------------------------------------------------------------------------------------------
Rajendra Salokhe
Page 23
------------------------------------------------------------------------------------------------------------