0% found this document useful (0 votes)
7 views

Access

The document provides a comprehensive guide on using Microsoft Access, including defining a database, creating a new database, and understanding its components such as tables, queries, forms, and reports. It details the steps for creating and managing tables, setting field properties, and establishing relationships between tables. Additionally, it covers data types, primary keys, and various functionalities to enhance database management.

Uploaded by

surendran.phd.it
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Access

The document provides a comprehensive guide on using Microsoft Access, including defining a database, creating a new database, and understanding its components such as tables, queries, forms, and reports. It details the steps for creating and managing tables, setting field properties, and establishing relationships between tables. Additionally, it covers data types, primary keys, and various functionalities to enhance database management.

Uploaded by

surendran.phd.it
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 119

Microsoft Access

What is a Database
 A Database is a collection of related data.
For example, a phone book is a database of
names, addresses and phone numbers.
Starting Microsoft Access

To run Microsoft Access:


1. Choose Start menu.
2. Select All Programs.
3. Select Microsoft Office.
4. Click on Microsoft
Office Access 2003
Create a New Database
1. Click New on the File menu or in the New File
task pane, under new, click Blank Database.
2. The File New Database dialog box will appear.
3. Give the new database a name and save it before
proceeding.

Type the
name
4. Type the name of the database in the File Name
box. Click Create button.
The components of the Access
and Database windows
Database Window
Database Window
1. The Title bar: shows the name and file format of the
database.
2. The Database Window Toolbar: Use the Open button
to work with objects, or use the New button to create
new objects.
3. Object Toolbar: Click one of the object types, such as
Tables or Forms.
4. Use New Objects Shortcuts list to create new database
objects.
5. The list of database objects changes according to
which object type you have clicked under objects.
Objects
Access database includes such objects as:
1. Tables: Are collections of similar data.
2. Queries: Are requests to access information.
3. Forms: Are on the screen arrangements that make it easy
to enter and read data.
4. Reports: Are paper copies of queries.
5. Pages
6. Macros: Are tools that can help automate complex or time-
consuming repetitive manual tasks.
7. Modules: Are programs that advanced users creating with
access basic a programming language.
Creating New Table
Designing database from scratch requires considerable
attention to details. You need to decide which
information to collect; what names to give each field,
specify the types of field you will be using.
…Cont
 Button:
1. New  Create New Object
2. Open  Open Object
3. Design  View the content and
properties of object
To create new table:
1. Choose the object Tables.
2. Click New.
View of a Table

You can view your table in two ways:


1. Design View: You create the table structure
manually. Specify the field names, data type, and
indexes.
2. Datasheet View: After you have created a table in
design view, you can view it in Datasheet view. You
create table by typing information into a blank
datasheet.
1

2
Table Design View
 Click on the object Table from Database
window then click on Design button.
Table Design View
 Then the table design will appear as in this figure.
Filed type comments
Column
name

Column
properties
Table Design View
1. Field Name click on the first empty field
name box and type a unique name.
2. Data Type and Properties : access offer
eight data types for its field.
3. Description
4. Every field in a table has a set of a
Properties : A field property is a specific
characteristic of a field .
Data Type
1. Text: Alphanumeric data; including letters,
numbers; spaces and punctuation symbol

2. Memo: Alphanumeric data. Use when you


need to type several sentences describe a
record. Field capacity is up to 64,000
characters.
3. Number: Numeric data can be used in
calculation
4. Date/Time Dates: use for dates and times
5. Currency: use the data type for currency
values such as dollars
Data Type
6. AutoNumber: A numeric value that access
automatically increments by 1 for each record
you add to a table

7. Yes/No: Use this field to store yes/no,


true/false, or on/off result

 LookUp Wizard: When the value that you need exists


in a list of static values you use the Lookup wizard to help
you establish to define a combo box that will display the
list of values on a form or report.
Creating Field in the Table
1. Click Tables object.
2. Double click Design View.
3. Enter the field names in the Field Name column.

4. Select data types in the Data Type column.


5. Enter optional descriptions in the Description
column.
6. To define a second field in the table press Tab
key.
7. Add all the required field.
Primary Key
Primary Key is a field that contains unique values,
once you designate as a primary key for a table
MS-Access will prevent any duplicate or Null
values from being entered.
 To set a Primary Key:
1. Select field or fields you want to define as primary
key by clicking the row selector for the designed
field.
2. Click Primary Key on the Toolbar.
…Cont
If you don’t set a primary key, Access will ask you if
you want it to create a primary key.

To Remove Primary Key:


1. Open the table Design View.
2. Click the row selector for the current primary key
and then click Primary Key on the toolbar.
:Example

Car type color Model


number
36728 bmw black 1999

65474 bmw red 1999

74633 bmw red 1999

67467 honda black 2000


?Which of those are the primary key
Designate Two or More Fields as the
Primary Key (Composite Key)
To select multiple fields, hold down the CTRL key
and then click the row selector for each field.

Saving a Table:
Choose Save form File menu. Or click on Save
Naming of the Tables

Not begging with a blank .1


Can not named the same table name .2
in the same D.B
Not than more 64 character of length .3
 Closing a Table:
To close a Table click

 Opening a Table:
1. Click Tables object in Database window.
2. Double click the table you want to open.
3. To open the table in the design view, click
the table and then, click Design on the
Database window toolbar.
Add New Field to your Table
1. Open the table in Design View.
2. To insert the field within the table, click in the
row below where you want to add the field,
and then click Insert Row on the toolbar.
3. Click in the Field Name column and type a
unique name for the field.
4. Select the data type you want.
Deleting Row
1. Select field you want to delete by clicking that
field’s row selector.
2. Click Delete Row on the toolbar.
Entering Data
You can enter and edit text directly in tables in
Database view.
Tab to the first field into which you want to enter
something. When you get to desired field, start
typing. Press TAP or Enter to move to the next
field of interest.
Changing the default direction of database
objects
To change the default direction of database objects:
1. On the Tools menu, click Option, and then click
the international tab.
2. In the Default Direction option group click:
• Click Left-To-Right to have new objects
displayed in a left to right direction.
• Click Right-To-Left to have new objects
displayed in a right to left
Step 1 Step 2
Changing Individual Table Directions
1. Open a table in Datasheet View.
2. Click anywhere in the text field.
3. On the Format menu, click Datasheet.
4. In the Direction option box, select the direction you
want.
Setting Field Properties
 Access offers eight data types for its fields, and each
type offers a variety of options called Properties.
Purpose Property
The maximum length of a text or numeric Field Size
field.
allows you to specify how numbers, dates, Format
times and text are displayed and printed.

allows you to simplify data entry for fields Input Mask


that have the same format. Such as phone
number.
Allows you to define a default field label to Caption
appear on forms and report, instead of the
field name you specified in table structure.
To specify a value that will be automatically Default
entered into the field whenever you create a Value
new record.

To specify error check. Validation


Rule

Place your desired error message. Validation


Text

Use this Yes/No field to tell Access if an entry is Required


required in the field you are designing.
Allows you to store a zero-length string of a text. Allow Zero
Length
Use this Yes/No field to tell Access if a field is to Indexed
be indexed for speedy lookups.
Text Field Properties
There are ten possible Text properties:
1. Field size: the field size of a Text Field can be
anything from 1 to 255 characters.
2. Format: the format property forces entries to
appear according to the characteristics you
specify.
For example, To convert all the text to the upper case,
regardless of how it is entered, you can place a (>) in
the space next to Format Line.
Number Field Size Property
Number field properties affect both the precision
of numbers and their appearance.
Field Size: the following table
summarize the available
Field size choices and
their specification.
Field Size
Description Field Size
Uses 1 byte to store the whole numbers Byte
from 0 To 255
Use 2 bytes to store the whole numbers Integer
from -32768 To +32767
Use 4 bytes to store integer numbers only Long Integer

Use 4 bytes to stores numbers with 7 digits Single


of precision
Use 8 bytes. The default stores numbers Double
with 15 digits of precision
Field Format Property for Number
Field
 The Field Format property lets you choose the
onscreen and printed appearance of numbers.
There is a drop-down list that lets you see and
pick the desired formats, which include
commas, currency symbols, scientific notation.
Description Setting

Display the number as entered. General

Use the thousand separator, follow the setting Currency


specified in the regional settings of window.
Use the euro symbol € . Euro

Display at least one digit; and two numbers Fixed


after decimal places.
Use the thousand separator; and two numbers Standard
after decimal places.
Multiply the value by 100 and append a percent Percent
sign (%).
Use standard scientific notation. Scientific
…Cont
 You can specify a Decimal Position in the
Decimal Places section of the Field Properties
list.
Date/Time Field Format
 The Date/Time data type lets you enter dates
and times in a variety of formats.
Caption
 The Caption Property lets you specify
replacement text for the name of the field, as it
appears onscreen. Caption have the same
affect as labels.
Yes/No Field Format
 Use the Yes/No data type when you want to
give users a field with only two entry choices:
Yes or No, On or Off, True or False.
1. Choose Yes/No from Data Type column.
2. Click on Format properties.
3. Click on drop-down list,
which contain different
format for Yes/No field.
Default Value
 Default Value specify a value that will be
automatically entered into the field whenever
you create a new record.
 For example, if you want the word member to
appear in the field, you type Member in the
space for the Default Value.
 To display the date of today automatically as a
default value ( type = Date() ).
 To display the date and time of today
( type = Now () ).
Validation Rule
 Validation Rule: is  Validation Test: when
property that specify an entry violates the
error checks. validation rule, the
error message text
will appear onscreen.
Indexes
 Access uses Indexes to speed up finds and
other operations where it has to look for data
in one or more field.
To create an Index:
1. Select the field to be indexed in the top half of the Table
Design view window.
2. In the bottom half of the window, select General tab and
click the line for Indexed.
3. Open the drop down list for Indexed and Select:
- Yes (Duplicate Ok).
- Yes (No Duplicate).
 Depending on whether there will be more than
one record with the same value in the indexed
field.

 To view the indexes for you table, click the


indexes icon on the toolbar.
Relationship
• After you have set up different tables for each
subject in your Microsoft Access database.
• The first step is to define relationships between
your tables. After you have done that, you can
create queries, forms, and reports to display
information from several table at once.
• The kind of relationship depends on how the
related field are defined
Relationship
• A One-To-Many relationship is created if only
one of the related fields is a primary key or has
a unique index.
• A One-To-One relationship is created if both of
the related fields are primary keys or have
unique indexes.
• A Many-To-Many relationship is used when a
record in the first table can have many records
in the second, and vice versa.
A Junction Table must be created with One-To-Many links to
original tables.
One To Many
• When there can be more than one record for a
linking value on one side of a relationship, you
end up with a one to many relationship. One
of the fields in the link is a primary key and
other is not.
• Before you create a relationship between
tables:
1. You should know the Primary Table and the
Related Table.
2. The relationship should be applied between
tables with common fields.
3. The related fields do not have the same
names, but they must have the same data
type and contain the same kind of information.
4. Create a field in the Related Table to match
the primary key data type and properties in
the Primary Table.
5. After creating a relationship between tables,
you can not delete or edit any fields.
:Example
Create a relationship between Book and Borrower tables
1. Close any table you have opened. (you can’t create or modify
relationship between open table) .
2. Click the Relationship icon from the toolbar.
3. If your database does not have any relationships defined, click
Show Table from Relationship menu, or click on Show Table
icon.
4. Drag the field that you want to relate from one to the
related field in the other table.
5. In most cases, you drag the primary key field from one
table to a similar field in the other table. The related
fields do not have to have the same names, but they
most have the same data type and contain the same
kind of information.
6. Click on Edit Relationship from Relationship menu. The
Edit Relationship dialog box is displayed. Check the
fields names displayed in the two columns to ensure
they are correct. If you can change them if necessary.
7. Click Create button to create the relationship.

8. When you close the Relationship window Access will ask


if you want to save the layout.
9. When you open Book table , this sign will show beside
fields.

• If you drag a field that is not a primary key and does not
have a unique index to another field that is not primary
key and does not have a unique index, an Indeterminate
relationship is created.
Editing an Existing Relationship
To delete a relationship :
1. Click relationship from the toolbar, if the tables
whose relationship you want to delete are not
displayed, click Show Relationship.
2. Click the relationship line for the relationship
you want to delete, and then press Delete Key
To Edit a relationship:
Double click the relationship line for the
relationship you want to edit, set the
relationship options.
Viewing the Existing Relationships
To View the existing relationships:
1. Switch to the Database window.
2. To view all the relationship defined in the
database, click Show All Relationship from the
toolbar.

To view only the relationships defined for a


particular table, click the table, and then click
Show Direct Relationships on the toolbar.
One to One Relationship
A One To One relationship is used where one
record in one able is linked to only one record
in another. This can be used to split a table
with many fields or if part of a table is removed
for security reasons or if the second table
contains optional data.
A One-to-One relationship is created if both of the
related fields are primary keys.
To create One-To-One relationship
1. Create a new table in Design view with two
fields:
• Employee_No, with Number data type and make it as
a Primary Key.
• Salary field with Currency data type.
• Save the table as Salaries.
2. Open the Relationships window, and display
Salaries and Staff List tables.
3. Make the link between the primary keys. The
Edit Relationships window will appear.
4. Select Enforce Referential Integrity check box.
5. Click Create.
Many to Many
A Many-to-Many relationship is used when a
record in the first table can have many records
in the second, and vice versa. A Junction Table
must be created with One to Many links to the
original tables. It must contain two fields (the
primary keys from both tables).
To create Many-to-Many relationship
1. Create a new table that includes the primary
keys for the two tables. In our example of
Order ID and Product ID, ensure that they have
the same data type and properties.
2. Save the new table as Order-Product and close
it.
3. Open the Relationships window.
4. Add the new table to it.
5. Drag the Product ID field from the Products
table to the Order-Product table then create
the relationship.
6. Also drag the Order ID field from the Orders
table to the Order ID fields in the Order-
Product table, and then create the
relationship.
Queries
The advantage of a query is that you can decide
which fields will be shown and then what
information will be sought.
A query is based on a table. It uses the fields and
records contained in the table, which are then
displayed as required..
 Two way to create Query:

1. Create query by using wizard


2. Create query in Design view
Creating Query by Using Wizard
To create a new query by using a Query Wizard:
1. Open the Database window. Click the mouse
on the Queries tab to prepare for a new query.
2. Creating the Query: Double click Create Query
by using wizard.
• Choose which
table on which to
base your new
query.
• Choose the fields
you want to use in
the query by
clicking on arrow
button to move
the fields across
to the selected
fields box.
The Simple Query Wizard
The Simple Query Wizard assists
you in the creation of a new query.
…Cont
• Next: A new window will appear

• You are asked to give the query a name.


• Click Finish. The query is completed and the
data is displayed in the table format with only
the selected fields.
Creating Query without using Query
Wizard
To create a new query without using query wizard:
1. Select Queries object then click New. The New
Query dialog box will appear.

2. Select Design View then select OK.


3. The Show Table dialog box will appear.

Show Table

Add
Button

4. In show Table dialog box select the table you


want then click Add.
5. Close the Show Table dialog box.
6. The query Design window appears with the
table object in the top portion and a clean grid
below.

Design
Grid
Query Design Window

Data
quiry
filed
table
Query Design Window
Parts of query design window:
The top portion displays the table on which you
have chosen to base your query.
The bottom portion of the window contains the
rows on the grid are used to refine your queries
and are described bellow:
 Fields: show the fields you want to add to your
query.
 Table: used to clarify which table the field
belongs to when dealing with a multiple-table
query.
 Sort: used to sort out the resulting table into
ascending or descending order by the field in
this column.
 Show: used to specify whether the field should
be displayed in the resulting table.
 Criteria: used to set criteria for selecting
records to be displayed in the resulting table.
 Or: used it to specify another criterion.
Views of a Query
• Click the View button on the toolbar.
• To display the Datasheet click.

• To return to the query in Design View click


Add Table to a Query Grid
To add table to a query grid, do the following:
1. Open a Query in Design View.
2. Click the name of the object you want to add
to the query.
3. Click Add, and then click Close.
…Cont

Table

Field
You
choose
Table
of Field
Sort

Show
Criteria
Querying a database involves more than limiting
its display to specific fields. You usually want to
extract records from the table that meet a
given condition. To limit the records that
display in a datasheet, you enter a Conditional
statement in the Criteria row of the grid.
Example:
…Cont
To retrieve all you employees who last name is Harvey:
1. Ensure that the Queries tab is active. Click New
command button, then Double click Design View.
2. In the Show table dialog box that appears select
Employee table, click add button, click close button, the
query Design window appears with the Employees table
in the top portion and a clean grid below.
3. Double click on all desired field in the table object to
add the field to the next available column in the grid.
…Cont
4. Type Harvey in the Criteria row for the Last Name
Column.

LastName
Column

Criteria ”Type “Harvey


…Cont
5. Run the query.
The Screen should appear like this table:
Example: Extracting Employees who are Male and Whose
Salary less than 12000.
Type Male in Criteria Gender Column.
Type the expression <12000 in the Criteria row for the
Salary Column.

Example: Extracting employees who Started working after


1/1/1996.
Type the expression >1/1/1996 in Criteria row for the
Starting Date column ( expression of date surrounded by
# ).
Changing a Field’s Caption
 When you use an aggregate function
on a field, Microsoft Access
combines the function and that field
names to name the field in the
datasheet (e.g. SumOfSalary).
1. Open a query in Design View.
2. In the design grid, right click
anywhere in the column of the field
whose caption you want to change,
and then click Properties.
3. In the Caption property box, type
the new caption for the field.
Fields Row

Design
Grid
Delete Query
You can use the Delete Query to deletes of entire groups of
records.
1. Select the table whose record you want to
make another table.
2. In the Query Design View, click the Query type
icon, and then click Delete Query.
3. In the Table Name box, enter the name of the
table you want to create or replace.
4. Click Current Database to put the new table in
the currently open database. Or click another
Database.
Update Query
You can make global changes to a table.
1. Select the table whose record you want to
make another table.
2. In the Query Design View, click the Query type
icon, and then click Make Table.
3. In the Table Name box, enter the name of the
table you want to create or replace.
4. Click Current Database to put the new table in
the currently open database. Or click another
Database.
Forms
 Forms: are designs (layout) you create to
improve the appearance of data from your
tables. Forms can be displayed and printed, the
main use of forms is onscreen, to improve the
interface for the data entry.
Create Form
1. Create Form in Design View
2. Create Form By Using Wizard
Create Forms Using Wizard
1. Click Forms tab.
2. Double-click Create
form by using wizard.
3. The Form Wizard dialog
box will appear.
4. Choose the table from
the Table/Queries box.
5. To include a field:click
the field in the list to
select it.
6. Click Next when you
have moved all fields.
1

2 3
1. Tables/Queries:

2. Available Fields:

Tables/Queries

3. Selected Fields:
Sample of the
Selected
layout

Layout
7. A new window gives a
choice of layout.
8. The wizard will offer some
style, choose one and
click on the Next button.
9. Final Wizard dialog
box, which ask to
create a title for the
form.


10. Click Finish.
Moving from Field to Field
Navigation Bar

Move To First Record Move To next


Record Move To last Record

Number of columns

Current Record Add newِ


Record

Moving from field to a field in a form:


The bottom of a form window provides some arrow buttons
that can make it easy to move from field to field.
Form View
You can view your Form in two ways: Form View
and Design View.
1. Design View: you create the form structure manually,
and control the appearance of the Form, change the
fonts or font sizes, align text, or apply special effects.
Use the toolbox to add controls.

Toolbox

‫نافذة تصميم‬
) Form (‫النموذج‬
…Cont
2. Form View: After you have created a Form in
Design view, you can view it in Form View. You
can look at only one record at a time and
adding new records.
3. Datasheet View: you can view records in row
and column format, so you can many records
at one time.
To switch between views of a Form:
Click the View button on the toolbar. The View
button is a toggle button.
Sections of Form
In Design View, Sections are represented as
bands, and each section that the form contains
is represented once.
Switch to Design view, display all the form
sections by selecting Page Header/Footer and
Form Header/Footer from the View menu.
Sections of Form:
1. Form Header: display information that remains
the same for every record, such as a title for
the form. Appears at the top of the screen in
the Form View.
2. Page Header: Display information at
the top of every printed page.
3. Detail section: Is where you specify
which fields will be displayed, what
they will look like.
4. Page Footer: Displays information at
the bottom of every printed page.
5. Form Footer: Displays information
that remains the same for every
record, Appears at the bottom of
the screen in the Form View, after
the last detail section.
Section Size
Change either height or width:
1. Change either height or width by placing the
pointer on the bottom edge or right edge to
the section.
2. Drag the pointer up or down to change the
height of the section. Drag the pointer left or
right to change the width of the section.
Multiple Table Forms
Create form with data from different tables:
1. Establish a relationship between the desired
tables in the database.
2. Create a new query using the desired tables.
3. Specify the field you want to appear in the
form, and then save the query.
4. Create a new form based on the query.
5. A form window will appear in Design view,
click the Field List icon on the toolbar to
display the field of the query.
New
Button

6. Drag the field to the detail


in the form.
7. View the records.

Field
List
Report
 Reports are used
to present
summarize, and
print the table
data. Using a
report you can
calculate totals
and subtotals
across a set of
records and
tables.
Create a Report by Using Auto
report
1. Click Reports under Objects.
2. Click the New button on the Database window
toolbar.
3. In the New Report dialog box, click one of the
following Wizard.
 AutoReport: Columnar Each field appears
on a separate line with a label to its left.
 AutoReport: Tabular the Field in each record
appear on one line, and the labels print once
at the top of each page.
…Cont
New
Button

New
Report
Dialog

Select
the table
or query
…Cont
4. Click the table or
query that contains
the data you want
to base your report
on.
5. Click OK.
Create Report by using Wizard
Report Wizard is the easiest to use because
Access performs all of the work without
prompting you for any information.
Creating a Report:
1. Double Click on Create Report by using
Wizard.

Report
Choose Table
Wizard
dialog box
Choose
Field
2. Choose table on which to base your new
Report.
3. Click Next, new dialog box will appear to
specify the desired grouping option
Group the
record by
the content
of a
particular
field
4. Click next, new dialog box will appear to
specify the desired sorting options for the
derail records.

Sort the field


Ascending or
descending
5. Click next, new dialog box will appear to
specify the desired report style. app
:Orientation of Page
1. Portrait
2. Landscape

Style Name
( Format of Layout)
6. In the final dialog
box, you enter a
name for the Report,
then Click Finish.

Name of
Report
Views of a Report
 Click the View button on the toolbar.
 To display the Print Preview window click.
 To return to the report in Design view click.

You might also like