MS Access
Introduction
What is Data
Data can exist in many forms for
computer use.
Data stored on computers should be
digital but lots of types of data in the
real world involve physical
measurements of continuously varying
data.
These need to be converted into digital
data for storage and manipulations on a
computer
2
3
Data Types
Text
Alphanumeric
Numbers
Integer
Long integer
Single
Double
Date/time
Currency
AutoNumber
Boolean
Yes/no
True/False
-1/0
4
Math Operators
+ Addition
- Subtraction
* Multiplication
/ Division
 Integer Division
^ Exponentiation
Mod Modulo (remainder) division
5
Relational Operators
= Equal
<> Not equal
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
6
Boolean Operator
And Logical And Both operands are true
Or Logical Or Either one of the
operands or both of
them are true
Xor Excusive Or Only one of the
operands (not both of
them) are true
Not Negation Operand is not true
7
String and Miscellaneous
Operators
& Concatenation
Like Similar to
Between
…and…
Between 2 values inclusive
In (list) One from the list
Is Null True if the field is empty
Data Structures
8
• Data is often stored in files, which consist of records, which
in turn consists of fields.
•For example a Company might want to store its employee
information in the following format –
Reference No/ Name / Date-started / Department
The structure of the Employee file would be –
Ref No Name Start-Date Department
1416 J. Smith 30/05/2003 Sales
1417 K. Shah 11/02/1999 Manager
1431 R. Marques 15/10/2001 Finance
1452 T. Rodriques 27/09/1995 Sales
1461 V. Schruitz 09/12/2005 Finance
Rec -1
Rec-2
Rec-3
Rec-4
Rec-5
Field1 Field2 Field3 Field4
Employee
File
Data types of each field for the
Employee File
9
Ref No - Numeric Data
(Integer)
Name - Text
Date - Date Format
(dd/mm/yy)
Department - Text
Flat File Structure
Ref
No
Name Date Depart
ment
101 Deepa Jain 12/01/2000 Accts
102 Sam Pai 01/09/2004 HR
103 Ekta Joshi 09/09/2002 Accts
104 Sumit Ojha 07/08/2001 Sales
Database
A database is a collection of information
that is organized so that it can easily be
accessed, managed, and updated. In
one view, databases can be classified
according to types of content:
bibliographic, full-text, numeric, and
images.
In computing, databases are sometimes
classified according to their
organizational approach.
10
Why are databases used?
They promote data consistency. When
data is updated on a database it is up-
to-date for any application which uses
the database.
Data duplication is reduced.
It is relatively easy to expand the
database as per new requirement.
Security of data is easier to monitor and
maintain
11
12
Relational Database
Relational databases consists of a
separate tables which are related.
Each table contains a primary key field
that is also available in one other table.
With this it is possible to combine data
from different tables to produce a
report.
Tables also contain Foreign keys that
relate tables in the database to one
another. Field name may be same or
different.
Advantages of Relational
Databases
Faster data retrieval
Easier expansion of the database by
adding extra or new tables
Need to change data in only one table
as all other references get updated
automatically because of data integrity
13
Example of Relational Database
14
A garage sells cars and keeps a database of sales, customers
and servicing. The Primary key is Car Number. Invoice
Number and Engine Id are Foreign Keys
Car
Number
Make of Car Value
($)
Date the
Car was
sold
Mileage
at sale
A 111 BBB VW GOLF 20500 20/01/09 18100
C 202 ART SEAT LEON 19450 15/03/09 25509
N 015
BRM
TOYATO
AYGO
12700 18/12/08 16702
N 541 KIT FIAT PUNTO 13400 04/09/08 12212
S 229 RRP HONDA CIVIC 16600 17/11/08 21099
Garage Sales Table
Example of Relational Database
15
Invoice
Number
Car Number Customer Name Customer
Details
Annual
Mileage
242986 R 541 KIT J. Klaus 12, Ford Rd 15000
243001 S 229 RRP K. Chan 134, Main St 25000
243221 N 015 BRM D. Meija 56 Ligo Rd 18000
243811 A 111 BBB B. Bipan 244, St Kitt Rd 20000
244002 N 015 BRM T. Guntar 87 Pebble Drive 15000
Engine Id Car Number Service
Mileage
Date of last
service
Any recalls
outstanding
AF123452 C 202 ART 40000 20/01/09 Yes
AST23455 R 541 KIT 32000 15/03/09 No
BB219009 A 111 BBB 38000 18/12/08 No
CD567899 N 105 BRM 30000 04/09/08 No
FFF34567 S 229 RRP 39000 17/11/08 Yes
Customer Detail Table
Service Table
Questions – Example - 1
How many records can you see in the
Garage Sales Table?
How many fields are there in each
record?
Which field contains:
Numeric Data Only
Text Data Only
Date type of Data only
Marina G. Erechtchoukova 16
Questions – Example 2
How many records are there in the
Customer Detail Table?
How many fields are there in the
Service Table?
What type of database is being used
between the three tables?
Which field is a Foreign Key?
Marina G. Erechtchoukova 17
18
Access Database Objects
Tables contain rows called records and
columns called fields.
Queries are requests for specific
information from a database.
Queries are virtual tables built on a
given SQL statement
19
Access Database Objects
(cont. …)
Forms are parts of user interface.
Forms are used to enter, edit or browse
data from a database
Reports present requested information
and allow to create hard copies.
20
Create a Database in MS Access
2007 and up
Click on the round Office button
Choose New from the drop-down
menu
In Create Blank Database window
specify the database name
Click Create
21
Create Table
Using Wizard
Design View
Specify field names
Data types
Properties
Determine a primary key
Save the table
22
Access Tables
Design view
Table structure is created and may be edited
Datasheet view
Display table content in spreadsheet-like grid,
Used for entering, editing or deleting data
from tables
23
Queries
Specify the source of data
If multiple tables are used, specify
relationships between tables
Select desirable fields from the table(s)
and options related to the fields
Specify a criterion
24
Query Criteria
To be selected a record must satisfy a
criterion
Expressions may contain the following
operators:
Math Operators
Relational operators
Boolean Operators
String Operators
Miscellaneous Operators
25
Access Forms
Create using Form Wizard
Create using Form Design view
Specify source of data will be presented by
the form
Table
Query
Specify fields related to the form
Add labels, titles, graphics and so on
26
Form Design view
Form Header –a place for titles,
graphics, additional information
Form Details section – the fields used to
create a form and control elements
related to the fields
Form footer –a place for any items
which will appear at the bottom of the
form
27
Form Controls
Must be bound with fields from the
source table or query
Contain data from correspondent fields,
labels or other controls (like command
button) or another form called subform
28
Viewing Forms
Open database
Click Forms tab to display all available
forms in the database
Select the form
Select Open
To view data use Form Navigation
Tools. To prevent data Editing, use
Locked Property for the Text Boxes
29
Creating Subforms
Represent 1:N relationships
To add a subform to a form
Create a form that will be a subform
Click on Subform/Subreport button and
then click on a form where the subform
should appear
Specify the source for the subform
Specify the fields to link the form and
subform
30
Reports
Reports present table contents or query
results in an easily assimilated format
Reports have Design view and Print
Preview
Report Design View is similar to the
Form Design view
31
Report Design View
Page Header contains data and graphics
appearing at the top of each page
Report Header contains the data and
graphics appearing at the top of the first
report page
Detailed section contains data from tables or
queries
Page Footer contains the data and graphics
appearing at the bottom of every page
Report Footer contains the data and graphics
appearing at the bottom of the last report
page
32
Report Types
Columnar reports – a single record on a
page
Tabular reports – datasheets: fields
from the tables are presented as
columns
Justified reports combine two previous
types of the reports
33
Creating Reports
With a Wizard
Design view:
Specify source for the report
Select Fields from the Fields List
Add labels
Add format
Switch the view to see the result.

Chapter 5 ms access-1

  • 1.
  • 2.
    What is Data Datacan exist in many forms for computer use. Data stored on computers should be digital but lots of types of data in the real world involve physical measurements of continuously varying data. These need to be converted into digital data for storage and manipulations on a computer 2
  • 3.
  • 4.
    4 Math Operators + Addition -Subtraction * Multiplication / Division Integer Division ^ Exponentiation Mod Modulo (remainder) division
  • 5.
    5 Relational Operators = Equal <>Not equal < Less than > Greater than <= Less than or equal to >= Greater than or equal to
  • 6.
    6 Boolean Operator And LogicalAnd Both operands are true Or Logical Or Either one of the operands or both of them are true Xor Excusive Or Only one of the operands (not both of them) are true Not Negation Operand is not true
  • 7.
    7 String and Miscellaneous Operators &Concatenation Like Similar to Between …and… Between 2 values inclusive In (list) One from the list Is Null True if the field is empty
  • 8.
    Data Structures 8 • Datais often stored in files, which consist of records, which in turn consists of fields. •For example a Company might want to store its employee information in the following format – Reference No/ Name / Date-started / Department The structure of the Employee file would be – Ref No Name Start-Date Department 1416 J. Smith 30/05/2003 Sales 1417 K. Shah 11/02/1999 Manager 1431 R. Marques 15/10/2001 Finance 1452 T. Rodriques 27/09/1995 Sales 1461 V. Schruitz 09/12/2005 Finance Rec -1 Rec-2 Rec-3 Rec-4 Rec-5 Field1 Field2 Field3 Field4 Employee File
  • 9.
    Data types ofeach field for the Employee File 9 Ref No - Numeric Data (Integer) Name - Text Date - Date Format (dd/mm/yy) Department - Text Flat File Structure Ref No Name Date Depart ment 101 Deepa Jain 12/01/2000 Accts 102 Sam Pai 01/09/2004 HR 103 Ekta Joshi 09/09/2002 Accts 104 Sumit Ojha 07/08/2001 Sales
  • 10.
    Database A database isa collection of information that is organized so that it can easily be accessed, managed, and updated. In one view, databases can be classified according to types of content: bibliographic, full-text, numeric, and images. In computing, databases are sometimes classified according to their organizational approach. 10
  • 11.
    Why are databasesused? They promote data consistency. When data is updated on a database it is up- to-date for any application which uses the database. Data duplication is reduced. It is relatively easy to expand the database as per new requirement. Security of data is easier to monitor and maintain 11
  • 12.
    12 Relational Database Relational databasesconsists of a separate tables which are related. Each table contains a primary key field that is also available in one other table. With this it is possible to combine data from different tables to produce a report. Tables also contain Foreign keys that relate tables in the database to one another. Field name may be same or different.
  • 13.
    Advantages of Relational Databases Fasterdata retrieval Easier expansion of the database by adding extra or new tables Need to change data in only one table as all other references get updated automatically because of data integrity 13
  • 14.
    Example of RelationalDatabase 14 A garage sells cars and keeps a database of sales, customers and servicing. The Primary key is Car Number. Invoice Number and Engine Id are Foreign Keys Car Number Make of Car Value ($) Date the Car was sold Mileage at sale A 111 BBB VW GOLF 20500 20/01/09 18100 C 202 ART SEAT LEON 19450 15/03/09 25509 N 015 BRM TOYATO AYGO 12700 18/12/08 16702 N 541 KIT FIAT PUNTO 13400 04/09/08 12212 S 229 RRP HONDA CIVIC 16600 17/11/08 21099 Garage Sales Table
  • 15.
    Example of RelationalDatabase 15 Invoice Number Car Number Customer Name Customer Details Annual Mileage 242986 R 541 KIT J. Klaus 12, Ford Rd 15000 243001 S 229 RRP K. Chan 134, Main St 25000 243221 N 015 BRM D. Meija 56 Ligo Rd 18000 243811 A 111 BBB B. Bipan 244, St Kitt Rd 20000 244002 N 015 BRM T. Guntar 87 Pebble Drive 15000 Engine Id Car Number Service Mileage Date of last service Any recalls outstanding AF123452 C 202 ART 40000 20/01/09 Yes AST23455 R 541 KIT 32000 15/03/09 No BB219009 A 111 BBB 38000 18/12/08 No CD567899 N 105 BRM 30000 04/09/08 No FFF34567 S 229 RRP 39000 17/11/08 Yes Customer Detail Table Service Table
  • 16.
    Questions – Example- 1 How many records can you see in the Garage Sales Table? How many fields are there in each record? Which field contains: Numeric Data Only Text Data Only Date type of Data only Marina G. Erechtchoukova 16
  • 17.
    Questions – Example2 How many records are there in the Customer Detail Table? How many fields are there in the Service Table? What type of database is being used between the three tables? Which field is a Foreign Key? Marina G. Erechtchoukova 17
  • 18.
    18 Access Database Objects Tablescontain rows called records and columns called fields. Queries are requests for specific information from a database. Queries are virtual tables built on a given SQL statement
  • 19.
    19 Access Database Objects (cont.…) Forms are parts of user interface. Forms are used to enter, edit or browse data from a database Reports present requested information and allow to create hard copies.
  • 20.
    20 Create a Databasein MS Access 2007 and up Click on the round Office button Choose New from the drop-down menu In Create Blank Database window specify the database name Click Create
  • 21.
    21 Create Table Using Wizard DesignView Specify field names Data types Properties Determine a primary key Save the table
  • 22.
    22 Access Tables Design view Tablestructure is created and may be edited Datasheet view Display table content in spreadsheet-like grid, Used for entering, editing or deleting data from tables
  • 23.
    23 Queries Specify the sourceof data If multiple tables are used, specify relationships between tables Select desirable fields from the table(s) and options related to the fields Specify a criterion
  • 24.
    24 Query Criteria To beselected a record must satisfy a criterion Expressions may contain the following operators: Math Operators Relational operators Boolean Operators String Operators Miscellaneous Operators
  • 25.
    25 Access Forms Create usingForm Wizard Create using Form Design view Specify source of data will be presented by the form Table Query Specify fields related to the form Add labels, titles, graphics and so on
  • 26.
    26 Form Design view FormHeader –a place for titles, graphics, additional information Form Details section – the fields used to create a form and control elements related to the fields Form footer –a place for any items which will appear at the bottom of the form
  • 27.
    27 Form Controls Must bebound with fields from the source table or query Contain data from correspondent fields, labels or other controls (like command button) or another form called subform
  • 28.
    28 Viewing Forms Open database ClickForms tab to display all available forms in the database Select the form Select Open To view data use Form Navigation Tools. To prevent data Editing, use Locked Property for the Text Boxes
  • 29.
    29 Creating Subforms Represent 1:Nrelationships To add a subform to a form Create a form that will be a subform Click on Subform/Subreport button and then click on a form where the subform should appear Specify the source for the subform Specify the fields to link the form and subform
  • 30.
    30 Reports Reports present tablecontents or query results in an easily assimilated format Reports have Design view and Print Preview Report Design View is similar to the Form Design view
  • 31.
    31 Report Design View PageHeader contains data and graphics appearing at the top of each page Report Header contains the data and graphics appearing at the top of the first report page Detailed section contains data from tables or queries Page Footer contains the data and graphics appearing at the bottom of every page Report Footer contains the data and graphics appearing at the bottom of the last report page
  • 32.
    32 Report Types Columnar reports– a single record on a page Tabular reports – datasheets: fields from the tables are presented as columns Justified reports combine two previous types of the reports
  • 33.
    33 Creating Reports With aWizard Design view: Specify source for the report Select Fields from the Fields List Add labels Add format Switch the view to see the result.