Training Module Access

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 137

MS - Access

Training Module
9th January 2010
Training Module – MS Access

Introduction to Database Development

Basic Features and Functions

Enhance Features & Functions

Errors & Security Features

Practice & Hands-On

Limitations
Introduction– MS Access

What is Microsoft Access ?

Microsoft Access is an application used


for creating databases.
Training Module – MS Access

Why Access ….! Why Not Excel?


This is a fair question. After all, Excel is not a database management system. It is
spreadsheet software, and it stores units of information in rows and columns of
cells, called worksheets. The most common task performed in Excel is the
management of lists such as telephone numbers and personnel data

In comparison, Access stores data in tables that look much the same as worksheets
but are designed for complex querying in relation to data stored in other tables and
locations, and even in fields in other tables.

So, while both programs work well for managing data, each one has clear
advantages depending on the type of data you are managing and what you want to
do with it.
Training Module – MS Access

When To Use Access…?


 Require a relational database (multiple tables) to store your data.
 Have a very large amount of data (Millions of entries).
 Have data that is mostly of the long text string type (not numbers or defined
as numbers).
 Rely on multiple external databases to derive and analyze the data you need.
 Want to run complex queries.
 Have many people working in the database and want robust options to expose
that data for updating.
Introduction– MS Access

"In Access, you have a primary key. In Excel, you have a cell
reference. In life, you have a PAN number. It's the best unique
identifier you have."

Ever noticed how, when at the office or calling an insurance company, you're asked
for your PAN number as well as your name?

Last name and even full name are often not unique. Unique identifiers are almost
always numeric. They preserve the integrity of your data and allow no duplicate
records or data in cells that you don't recognize (called Null values). Numeric
identifiers also provide the quickest way to retrieve data when searching or
sorting.
Introduction– MS Access

What is a database?
 A database is a collection of similar information; storing
it on a computer provides a means of analyzing and
Processing this information.
Introduction– MS Access

How does Access achieve this?


 Access stores information in tables. Data can then be entered directly into a
table or into a form (an interface for adding and editing data) which then
places it into a table.

 Creating forms in Microsoft Access 2007 You can use filters and/or queries to
search a database. Access also has a report function which enables you to
analyze the results of a search in printed format or in another application such
as Microsoft Excel or Microsoft Word.
MS Access 2007 – 10 Benefits

 Get better results faster with the Office Fluent user interface.
 Get started quickly using prebuilt solutions.
 Create multiple reports with different views of the same information.
 Create tables quickly without worrying about database complexity.
 Enjoy new field types for even richer scenarios.
 Collect and update your information directly from the source.
 Share your information with Microsoft Windows SharePoint Services.
 Track Windows SharePoint Services lists with the rich client capabilities of
Office Access 2007.
 Move data to Windows SharePoint Services for better manageability.
 Access and use information from multiple sources.
Introduction– MS Access

A database is a collection of information that's related. Access allows you to


manage your information in one database file. Within Access there are four
major areas:

Tables • store your data in your database

tables
Queries • ask questions about information stored in your

Forms • allow you to view data stored in your tables

that you have created


Reports • allow you to print data based on queries/tables
Opening MS Access
Opening MS Access

We can also open Access by Run Command in Start button:

- Open Run > Type “msaccess”> Press Enter / Ok Button

Access-2007 Access-2003
File Extensions accdbx accdb
Creating a Database

1) Select Blank Database 2) In the File Name field enter a name for the database
Click Create
Creating a Database

Microsoft Access automatically creates a new table in the database called


“Table1”.

This is a temporary name until the table is saved.


Understanding the Views

There are 2 basic views when you work in a table:

Design View Datasheet View


• Used to set the data • Used to enter the
types, insert or data for the records.
delete fields, and By default, Access
set the Primary key. places you in
Datasheet View

To Switch to Design view


1) Click the View button on the Home Ribbon
2) Type a name for the table
3) Click OK
Data Types In Ms-Access
To Enter Fields in a Table:

1) Type a name for the first field in the table


2) Press Enter
3) Select a data type
4) Press Enter
5) Type a description for the field
6) Press Enter

Continue this until all necessary fields have been entered into the
table.

Note: The order that you enter the field names is the order the fields
will appear in the table and on a form.
To Enter Fields in a Table:
Entering Data in a Table

Once you have entered the fields and set the data types it is now time to enter
the records in a table.
To Enter Data in a Table:
1) Make sure you are in Datasheet View
2) Enter the data into the table by pressing the tab key to move from one cell
to another
3) When you have completed the record (row), press Enter
Entering Data in a Table

Use the arrows at the bottom of the table to navigate among records. You are able
to navigate from the first record, previous record, next record, last record, and
create a new record (as shown in the picture below).
Notice that the total number of records in the table is shown at the right end of
the navigation arrows.

At the Right bottom of the table, you may see the shortcut buttons

1. Datasheet View
2. PivotTable View
3. PivotChart View
4. Design View
Sorting Records in a Table

By sorting your records in a table, you are easily able to view/locate records in
your table.
To Sort Records in a Table:
1) Position your cursor in the field that you wish to sort by, by clicking on any
record in that field.
2) Click either the Sort Ascending or Sort Descending icon
Import / Link Data into Access

Sometimes, you will be required to pull data from Excel and from some other
sources and put it into Access. To do this,

go to External Data and click Excel. Import the source data into a new table

In the current database by browsing for the file you wish to import. From there,
you will be prompted through several options, which include selecting your
primary key, as well as selecting the data type.
Import / Link Data into Access

We can Import / Link data into Access from many sources Like

• From a Text File.


• From Another Access File.

• From a Spreadsheet ( Xls File ).

• From a web page.


Import / Link Data into Access

Import / Link Data from a Text file


You can bring data from a text file into Microsoft Office Access 2007 in two ways. If you
want a copy of the data that you can edit within Access, import the file into a new or
existing table by using the Import Text Wizard.

If you simply want to view the latest source data within Access for richer querying and
reporting, create a link to the text file in your database by using the Link Text Wizard.

A text file contains unformatted readable characters, such as letters and numbers, and
special characters such as tabs, line feeds and carriage returns. Access supports the
following file name extensions —.txt, .csv, .asc, and .tab.
Import / Link Data into Access
Import / Link Data from a Text file

During the import operation, you can specify how the source file is organized, and whether
you want to create a new table or append the data to an existing table.
Import / Link Data into Access
Import / Link Data from a Text file

When the process goes further, you have to choose the import style, as per the description
of your data.

Access will guide


you to understand
the data, And
would suggest the
import style

Confused between “Delimited Data"& “Fixed Width”?


So we understand this first >
Import / Link Data into Access
Import / Link Data from a Text file

To use a text file as a source file for importing or linking, the contents of the file
must be organized in such a way that the importing and linking wizards can divide
the contents into a set of records (rows) and each record into a collection of fields
(columns). Text files that are organized properly fall into one of two types
 Delimited files : 
In a delimited file, each record appears in a
separate line & the fields are separated by
a single character, called the delimiter. The
delimiter can be any character that does
not appear in the field values, such as a
tab, semicolon, comma, space, and so on.
The following is an example of comma-
delimited text.
Import / Link Data into Access
Import / Link Data from a Text file

 Fixed-width files:-
In a fixed-width file, each record appears on a separate line and the width of
each field remains consistent across records. E.g. the first field of every record
is always seven characters long, the second field of every record is always 12
characters long, & so on.

If the actual length of a field's value varies from record to record, the values
that fall short of the required width must be padded with trailing space
characters. The following is an example of fixed-width text.
Import / Link Data into Access
Import / Link Data from a Text file

After specifying your data description and if your is data in delimited format,
please choose your delimiter…

Check the “First Row Select your delimiter and then press click button.
Contain field name button”
to make your first row, your
data Column heading
Import / Link Data into Access
Import / Link Data from a Text file

If your data hasn't got a column heading, you can give your column heading here and set
your data type…

And then press the next button.


Import / Link Data into Access
Import / Link Data from a Text file

Defining Primary Key in your table ….

Select no primary key and


click Next …

There are two types of Keys in Access Primary Key & foreign Key?
Import / Link Data into Access
Primary & Foreign Key ………

Primary Key

A primary key is one which uniquely identifies a row of a


table. This key does not allow null values & also does not
allow duplicate values

If a column is declared as primary then there wont be any repeated values in that
column throughout that table, as well as it wont take any null values and we can
use primary key only once in a table.
Import / Link Data into Access
Primary & Foreign Key ………

Foreign Key

A foreign key is one which will refer to a primary key of


another table at the time of setting relation between two
tables to catch the data from multiple tables.

If a column is declared with this key then we have to use a reference i.e. we need
to give the column which will have the same values as this column and the table
that column belongs to.. this referred column of other table will be the primary
key of that table.
Import / Link Data into Access
Import / Link Data from a Text file

Please set a specific name to your table to complete the import process
Import / Link Data into Access
Import / Link Data from a Text file

At the end of the import operation, you can choose to save the details of the import
operation as a specification. An import specification helps you repeat the operation at a
later time without you having to step through the Import Text Wizard each time.
Import / Link Data into Access
Import / Link Data from a Text file

And now you are ready to work on it…

TIP:-
if you forgot to set the column heading at the time of importing, You can do column
heading name by clicking twice on the column heading

Type your column heading here:- -------------------


Import / Link Data into Access

We can Import / Link data into Access from many sources Like

•From a Text File.

•From a Spreadsheet ( Xls File ).

•From Another Access File.

•From a web page.


Import / Link Data into Access

Import / Link Data from a Xls File

Common scenarios for importing Excel data into Access:-

 You are a long-time user of Excel but, going forward, you want to use Access to work
with this data. You want to move the data in your Excel worksheets into one or more new
Access databases.

 Your department or workgroup uses Access, but you occasionally receive data in Excel
format that must be merged with your Access databases. You want to import these Excel
worksheets into your database as you receive them.

 You use Access to manage your data, but the weekly reports you receive from the rest of
your team are Excel workbooks. You would like to streamline the import process to
ensure that data is imported every week at a specific time into your database.
Import / Link Data into Access

If this is the first time you are importing data from Excel

 There is no way to save an Excel workbook as an Access database. Excel does not provide
functionality to create an Access database from Excel data.

 When you open an Excel workbook in Access

(in the File Open dialog box, change the Files of Type list box to Microsoft Office Excel
Files and select the file you want),

Access creates a link to the workbook instead of importing its data. Linking to a
workbook is fundamentally different from importing a worksheet into a database.
Import / Link Data into Access
Start the import operation:-
 On the External Data tab, in the Import group, click Excel.

 In the Get External Data - Excel Spreadsheet dialog box, in the File name
box, specify the name of the Excel file that contains the data that you want
to import.

 Click Browse and use the File Open dialog box to locate the file that you
want to import.
 Specify how you want to store the imported data.

 To store the data in a new table, select Import the source data into a new
table in the current database. You will be prompted to name this table
later.
 To append the data to an existing table, select Append a copy of the
records to the table and select a table from the drop-down list. This option
is not available if the database does not contain any tables.
Import / Link Data into Access

And the shortest way to import data from Excel is:-

COPY your data from Excel & Paste into access

Swift move to
your access file
and the paste
the data
Import / Link Data into Access

Access will ask you that


“Does the first row of your data contain column heading ?“

Click Yes, if it is so otherwise click no


Import / Link Data into Access

And your Excel data will look like this …. 

Your table name


will remain the
same as your
sheet name were
in Excel.
Import / Link Data into Access

But before Copy & Paste, please keep some key Elements in your mind …

Element Description
The number of source columns that you want to import cannot exceed 255,
Number of columns because Access does not support more than 255 fields in a table.
Ensure that the cells are in tabular format. If the worksheet or named range
Tabular format includes merged cells, the contents of the cell are placed in the field that
corresponds to the leftmost column, and the other fields are left blank

If one or more cells in the worksheet or range contain error values, such as #NUM
Error values and #DIV, correct them before you start the operation.
To avoid errors during importing/copy the data, ensure that each source column
Data type contains the same type of data in every row.
If the first row in the worksheet or named range contains the names of the
columns, you can specify that Access treat the data in the first row as field names
First row during the import operation. If your source worksheet or range doesn't include
the names, it is a good idea to add them to the source before you start the import
operation.
Import / Link Data into Access

We can Import / Link data into Access from many sources Like

• From a Text File.

• From a Spreadsheet ( Xls File ).

• From Another Access File.


Import / Link Data into Access

Import / Link Data from a Another Access File

We can also import another Access table into Access … by following the same
process as we saw to import Text and Excel files..

Click the External Data and select Access from the menu to
import the access file into your database. Access will
ask you about the table name which you want to import in
your current database. We can also link the table by following the same process.

If you will link the table from another Access database, your linked table will
show the sign same as showing in the top left corner of the below picture
Working With Queries

What are Queries

In simple words Queries are questions you ask of your database. They
allow you to select certain fields out of a table, or pull together data
from various related tables and display it together. Queries can be used
to perform calculations, and to edit the data in your tables.

When you run a query, Access pulls data out of tables and puts the data in a database for
you to see. The original table and database stay connected, so that if you make changes to
the data in your database, the results of the query also change. When you save a query,
you save the query design, rather than the results, so that you can ask the same questions
again.11111
Working With Queries

Queries have two views: -


Design view and Datasheet view.
Design view:- You specify which tables you want to see, which tables they come
from, and the criteria that records have to meet in order to
appear on the resulting database. Criteria are tests that records
have to pass.
Datasheet:- You view the records that are found to meet your criteria.

We can create Queries by choosing "Query Wizard "& Query Design“


Working With Queries

Types Of Queries

Select Create new table in your database based on the results of a query.

Make Table Makes a new table based on the criteria within the query from an existing table.

Update Updates records in an existing table based on the criteria within the query

Delete Deletes records from a table based on the criteria within a query.

To Append your data in a another table of your database based on the criteria within a
Append query..
Working With Queries - Select

Select Query

When you want to select specific data from one or more sources, you
can use a select query. A select query helps you retrieve only the data
that you want, and also helps you combine data from several data
sources. You can use tables and other select queries as data sources for
a select query.
A select query is a database object that shows information in Datasheet
view(Datasheet view: A view that displays data from a table, form, query, view, or
stored procedure in a row-and-column format. In Datasheet view, you can edit
fields, add and delete data, and search for data.)

A query does not store data, it displays data that is stored in tables. A query can
show data from one or more tables, from other queries, or from a combination of
the two.
Working With Queries - Select

Creating a Query by using Query Design

Go to Create Tab Select Query Design


Using Select Query
Retrieve data from Single Table

Showing all
table in your
database
Working With Queries - Select

Suppose we need to retrieve those customer data where customer


balance is greater then Rs. 500.

Please select customer master table


and press ok..

Double click on the field name(s) which you


want to capture in your query:-
Select
Mobile_No
Account_Bal
Working With Queries - Select

As you select your desired field your query will look like:-
We need to understand below mentioned
row as shown in the picture

Field:- Will show the fields you select.


Table:- Table name of the selected
field.
Sort:- Your can sort your result by
selecting this option.
Criteria:- Where you can put your condition
as per your requirement.
Working With Queries - Select

As we want to see those customer number where customer balance is > 500,
type >500 in criteria as shown in the picture below.

And then press run button (on the left top corner of your screen)

And your result will be on your screen …………………………………….


Working With Queries - Select
Query Result:-

You remember the


sort field in your
design query

If you select the sort


option "Descending“
so your query result
will differ accordingly
Working With Queries - Select

Using query comparison operators

When working with select queries, you may need to specify one or more
criteria to limit the scope of information shown. You specify criteria by using
comparison operators in equations and calculations.

The categories of operators are Mathematical, relational, logical, and string.


In select queries, operators are used in either of the Field.

Here’s a good rule of thumb to observe:

Use mathematical and string operators for creating calculated fields; use
relational and logical operators for specifying the criteria.
Working With Queries - Select

Common Operators Used in Select Queries


Mathematical Relational Logical String Miscellaneous

* (multiply) = (equal) And & (concatenate) Between...And

/ (divide) <> (not equal) Or Like In

+ (add) > (greater than) Not Not Like Is Null

– (subtract) < (less than) Is Not Null

Not In
Working With Queries - Select
Common Operators Used in Select Queries

Using these operators, you can make out groups of records like these:

• Product records As per the MRP of the Recharge.

• A range of records, such as all sales between November and January.

• Records that meet both AND and OR criteria, such as all record that have > Rs.
500 Usages & Or not either a particular service class.
Working With Queries - Select
Common Operators Used in Select Queries

Where you can use these operators:- Go to Create >> Query Design >> Select
Recharge Table.

In criteria ROW you can use this


operator (As shown in the picture)

Here are some more Examples:- Open your database and Try It ( txn_amt = MRP )
Working With Queries - Select
Common Operators Used in Select Queries

Want to see Service Class Wise Mobile Count …. ?


What would you do …. ?

Use this On the right top corner on your query design


view.. As you click on the Totals button, you
will find the Extra row
Working With Queries - Select

Select data with multiple tables We can also retrieve data from more than one
table in access.. Lets see HOW?
Please select another table from which you want to get the data. For example
please select the “MOU Report” table from show table window.
Working With Queries - Select

To capture the data from multiple tables in access, we need to set a relation
between the tables..

Like Lookups in Excel.. In Lookup function we need to have one field common in
between our data, the same concept in Access is called “Relationship “

What is Relationship
between the tables?
Relationship in Access

Relationship

A “Relationship“ is a link that is created and maintained


between two tables that enables data to be accessed from
both the tables simultaneously. Once the table have been
created, there is need to specify the relationship that exists
between the tables.
When you design a database, you divide your information into tables, each of which
has a primary key. You then add foreign keys to related tables that reference those
primary keys.

These foreign key-primary key pairings form the basis for table relationships and multi-
table queries. It is important, therefore, that these foreign key-primary key references
stay synchronized.
Relationship in Access

Relationship

As you can see in the above picture the line between the two similar fields in
different tables, This is called relationship.
Relationship in Access

Relationship

To set Relationship between two fields we need to keep the following in mind:-

• Data types of the both field should be the same.

• So if you are setting the relationship between the mobile numbers in


Customer Master and MOU Master then the data type of the mobile
numbers in both the tables should be same. E.g. – The mobile numbers
can have the data type “Text”.
Relationship in Access

Setting of Join Property

Double Click The


line to set the join
property
Relationship in Access

Setting of Join Properties

Join Properties is the most


important part of setting
relationship between tables.
You can see the pictures showing
Table and column name as per
your table relationship.

The bottom part of the join


properties window is showing
Lets see the all three parameters of joined
three options to set the relation
properties …
properties based on how your
joined tables behave at the time
of data capturing and what kind
of data you want.
Relationship in Access

Setting of Join Properties

If you check the:-

• 1st Option:- Query will return ONLY those numbers or row where joined
field have similar data.
• 2nd Option:- Query will return all number of your left table and also
give the desired data from the right table where the field of both
tables are equal.
• 3rd Option:- Query will return all number of your right table and also give
the desired data from the left table where the field of both
tables are equal.
Relationship in Access

Capturing data from multiple tables

As we have already done.. Now we have all the customer numbers having
balance > 500 Rs balance. Now we also want to see the MOUs of
these customers.

Double click on the field name


from the table you want the data
for
Working With Queries - Select
Query Result:-

Pervious New
Query Query
with with
Single Multiple
Table Table
Working With Queries – Make Table

Make Table Query

A make table query retrieves data from one or more tables,


and then loads the result set into a new table. That new
table can reside in the database that you have opened, or
you can create it in another database.

You use a make table query when you need to copy the data
in a table or archive data based on some criteria.
Working With Queries – Make Table

Make Table Query

Process to Run a Make Table query is same as “Select” query. Set your
desired format or data as we have already done in Select Query and
then select the "Make Table Query” from the Query Tools option.
Working With Queries – Make Table

Make Table Query

As you click on the Make Table Query Option.. Access will ask you the
New Table name which you want to make. As you enter the name of
your new table name
Access will create the table with your desired data.
You can also the save the
new table in the same database or into a
another database by selecting the “
Current Database” Or “Another Database” as shown in above
picture.
Working With Queries - Update

Update Query

Update Query updates specified values in a table for all records or for
those records that match a specified criteria.

It is possible to update records manually in a database table, either via a form


or through the tables datasheet, however this may take a very long time.
Changing records manually is not only time consuming, it is also inefficient,
and lends itself to errors as you update the records.

The best way to handle this type of event, the updating of many records in a
database table, is to use an Update Query to make the changes to data in one
operation. You will save yourself time, and eliminate the possibility of manual
errors.
Working With Queries - Update

Update Query
Suppose we have table called Service Class Table

And we have “service_class“ name and


“Total Amount”. Want to update the Total
amount for any service class …….

As you can see service class 5031 have


different amount Like “20“ & “10”. And we
want to update the “total amount with 20“
in this service class so we will use Update
Query. Lets See how ...!
Working With Queries - Update

Update Query1

Select “Query Design” Add the table you want to update


and Click on the update option from your Left top Corner.

As you click on the “Update Query“ your query design


format will change accordingly.

Field:- Field Name Which you


want to update.
Table:- Table name of Field.
Update To:- Enter the new
value.
Criteria:- Enter the criteria
based on your query
will update the data
Working With Queries - Update

Update Query1

Select “Field name” from the table and in the Table Row “table name“ will show
automatically.

Update To:- write “20” because we want to update


total value of service class 5031 as “20”.

Criteria:- you have to mention your clear criteria and


based on that criteria access will update
your records.. We want to update the
Value “20” for each record where Service
class is “5031”. Click on the criteria and
then press the "Builder” from the Design
option shown on the TOP right corner.
Working With Queries - Update

Make Update Query

As you click on the “Builder"Button, One window will appear where you have to
Build your criteria.
With the help of builder expression
we can build our own logics and
formula to get / update the desired
info.
Click on the Table option and then
select your table “Service Class”. In
the next box list of all fields will
appear which are available in your
selected table. Double click on the
field name “service_class”.
Working With Queries - Update

Make Update Query

Enter in the upper box as you can see in the picture.

Type your Service Class


Name Like “= 5031”,where
You want to update your
records

And then Press Ok


Working With Queries - Update

Update Query

Given criteria in the builder Expression will Reflect in the Criteria Row
Working With Queries - Update

Press the “RUN” command And then Click Yes, Now you have updated your
records as per given criteria.

Access will show the


message saying How
Many records have been
updated through your
Query

Note:- Please be careful while updating records. If you are not confident about your
criteria, it is suggested that before updating records please take a Backup copy of
your database.
Working With Queries - Update

Updated
Records
Working With Queries - Delete

Delete Query

The Delete query in MS Access is a DML (Data Manipulation Language)


command used to remove one or more rows of data from a relational
database table.  The number of rows deleted is dependent upon the
existence and criteria within the where clause of the delete query.

Of all the queries, the delete query is the most dangerous. Unlike the other
types of queries you’ve worked with, delete query remove records from tables
permanently. Like other action queries, delete query acts on a group of
records on the basis of scoping criteria.
Because of the permanently destructive action of a delete query, always
make back-up copies of your tables before working with them.
Working With Queries - Delete

Delete Query

Will take the same example as we had done in the update query… but
this time we won’t update the records. We will in fact delete the records
based on the given criteria.

We have table “Service Class” and you


want to remove all service class named
“5066”. To do this will use Delete Query.
Working With Queries - Delete

Delete Query

Select “Query Design”. Add the table you want to delete


and Click on the delete option from your Left top Corner.

As you click on the “Delete Query” your query design


format will change accordingly.

You can see the picture where the delete criteria is


mentioned “5066”. After that click on the RUN command
to perform the delete query.
Working With Queries - Delete

Delete Query

Click “Yes” to complete the operation, otherwise Click “No” to stop


Working With Queries - Delete

Delete Query

If you choose “Yes"Access will remove all the records where Service Class was “5066”
Working With Queries - Append

Append Query

As the word append suggests, an append query attaches or adds


records to a specified table. An append query adds records from the
table you’re using to another table. The table you want to add records
to must already exist. You can append records to a table in the same
database or in another Access database.
Append queries are useful for adding information to another table on the basis of
some scoping criteria. Even so, append queries are not always the fastest way of
adding records to another database.

For example, if you need to append all fields and all records from one table to a
new table, the append query is not the best way to do it. Instead, use the Copy and
Paste options on the Edit menu when you’re working with the table in a datasheet.
Working With Queries - Append

Append Query

We have two table:- Customer Master -1 & Customer Master – 2

Customer Master-1 has some data around 371790 Rows & on the other
side Customer Master- 2 has just 8 records.

We want to append some record in Customer Master- 2 from Customer


Master -1 based on some specific criteria like "Date Of Activation “,
“Status” of the customer etc..
Working With Queries - Append

Customer Master -1 Customer Master -2


Working With Queries - Append

Append Query

We want to append Some record from Customer Master -1 into


Customer Master- 2 where “Activation Date” is 5/11/2008

Select “Query Design” Add the table from you want to


append records to another table, Click on the Append
option from your Left top Corner.
Working With Queries - Append

Append Query

As you select the append query, Access will ask you the table name
where you want to append the records.
Working With Queries - Append

Append Query

Select the table name from dropdown button or you can append your
records to another table of some other database by choosing “Another
Database”.

Select the Customer


Master -2, And press
Ok.
Working With Queries - Append

Double click on the


field name which you
want to append in
the table selected by
you.

Or if you want to
append all fields,
Select field name
with SHIFT KEY.
Working With Queries - Append

If both the tables have the same field heading, so Access will take the field
name automatically..

Otherwise you to choose the field name manually from Append To Row. As
shown in the below mention picture.
Working With Queries - Append

After choosing the field name you have to set the criteria in criteria row, Based
on this criteria your records will be copied to another table.

We want to append all records where Activation data is "05/11/2008”

Will write the same date in “Activation Date” Column.

Then press RUN command


Working With Queries - Append

Access will show the Message accordingly to your criteria .

?
Error …..!, lets see what was the Problem … Read the Error carefully and
Move to the Next slide.
Working With Queries - Append

Error was showing the “Duplicate Output destination” which means we are
appending some column twice..

Yes you are Right.. "Account_Bal”.

Field Account_Bal is repeating in “Account_Bal” & again on “Cust_Status”

Select the correct field from Append To Row, And Press RUN again..
Working With Queries - Append

You are about to append 787 Row (s) based on your criteria …

Press ok to copy 787 records into customer master - 2.. Click on No to hold the
operation.
Working With Queries - Append

Customer Master -1 Customer Master -2


Working With Queries Wizard

Some More important


Query by Query Wizard
Working With Queries Wizard

Creating a Query by using Query Wizard

Go to Create Tab Select Query Wizard


Working With Queries Wizard

Creating a Query by using Query Wizard

Mainly we use Three types of Query

 Crosstab Query Wizard

 Find Duplicate Query Wizard

 Find Unmatched Query Wizard


Working With Queries Wizard

Crosstab Query Wizard

A crosstab query in Microsoft Access is a special type of query that can be


created when you want to describe one numerical quantity in terms of two
other fields.

Suppose you have a table that contains the sales figures of your entire
inventory for the whole year, and you want to know how much money was
made per product during each month of the year. This would be a perfect
opportunity to construct a crosstab query to display the information.

Just like Pivot table in Excel…


Working With Queries Wizard

Crosstab Query Wizard

How many times have you used Pivot table in Excel, Crosstab Query is just like
the pivot table.. It’s the shortest way to see your data in a summarized way.

We have the data like Customer Master & in the same table we have Service
Class, Status of the customer etc.

Want to see this data like, What is my Customer Status by Service Class?, How
many customers are in Grace & How Many are Active…?

So Get Ready…
Working With Queries Wizard

How To Make Crosstab Go to Create>Query Wizard> Crosstab Query

List of tables in
your database

Select Customer Master and


Press Next …..
Working With Queries Wizard

How To Make Crosstab

List of field(s)
selected by you

List of available
fields in your
selected table

Select “Service Class” and Press


Next ……………………………………
Working With Queries Wizard

How To Make Crosstab

Now we want to see customer


status. So for Column header we
need to select “Cust_Status “
field.

Select cust_status and then press


Next …..
Working With Queries Wizard

How To Make Crosstab

What number you want to


calculate for each Column and
Row ………….

We need the count of mobile


numbers.. So select the mobile
number from field column and
then count from the function

And then press Next...


Working With Queries Wizard

How To Make Crosstab

Save your crosstab query with


desired name.

And Press FINISH button


Working With Queries Wizard

And The Result Is:-

Service Class

Count Of Customer
by cust_status
Working With Queries Wizard

Creating a Query by using Query Wizard

 Find Duplicate Query Wizard


Working With Queries Wizard

Find Duplicate Query

Access 2007 has a built-in query wizard to help you find and fix
duplicate records in a table. This wizard can be quite powerful
since it not only helps you identify the duplicate records, it
allows you to include additional fields so that you can find
exactly where the duplicate records reside in your data table.
Working With Queries Wizard

Find Duplicate Query

The Basic functionality of Find Duplicate Query is to find duplicate records in a


particular table. There are many other ways to do this but the shortest and
easiest way for beginners is using this “Find Duplicate Query Wizard”.

For Example:- We have a Recharge report of some time of period and we


want to know that how many customers have recharged
twice or more than that, so we can use this query.
Working With Queries Wizard

Find Duplicate Query

To Open Find Duplicate Query


go to Create Tab > Query Wizard > Find Duplicate Query > Ok
Working With Queries Wizard

Find Duplicate Query

Select the table where you want to find the duplicate records:-

Select Recharge Report


And Press the Next Button
Working With Queries Wizard

Find Duplicate Query

Now what do you want to find?


We have find out the duplicate mobile numbers?

Select Mobile Number and


press the next button
Working With Queries Wizard

Find Duplicate Query

One of the main advantages of Access is that it can finish thing much faster

Give your query a name and


then press FINISH
Working With Queries Wizard

Find Duplicate Query

Here is the your duplicate records -

In first field the query is showing the


mobile numbers which are duplicate, and
next column is showing how many times
the number is available.
Working With Queries Wizard

Creating a Query by using Query Wizard

 Find Unmatched Query Wizard


Working With Queries Wizard

Find Unmatched Query

'Find Unmatched Query Wizard', allows you to find records in


one table that do not have related records in another table.

However, this wizard only allows you to use one criteria to select
the non-matching records.
Working With Queries Wizard

Find Unmatched Query

The Basic functionality of Find Unmatched Query is to find unmatched


records in between two tables. There are many other ways to do this but the
shortest and easiest way for beginners is using this “Find Unmatched Query
Wizard”.

For Example:- We have our Customer Master and MOUs report. We want to
check that how many customers have not generated MOU’s.
To solve this purpose we will use “Find Unmatched Query”.
Working With Queries Wizard

Find Unmatched Query


To Open Find Unmatched Query
go to Create Tab > Query Wizard > Find Unmatched Query > Ok
Working With Queries Wizard

Find Unmatched Query

Select the table Name:- We


have the records of our
customers in the Customer
Master table so we will select
the Customer Master table
First.

Select the Customer Master


and then press Next.
Working With Queries Wizard

Find Unmatched Query

From which table you want to


check those numbers which
have no MOUs.

So for this we will select the


MOU report.

Select MOU Report Table and


Press NEXT.
Working With Queries Wizard

Find Unmatched Query

As you will select the MOU


report table,

Access will give the field list


for both the tables.

You have to select what we


need to check.. Select the
Mobile number from both
sides and then press NEXT
Working With Queries Wizard

Find Unmatched Query

In your reports what are the


fields you require from your
Customer Master table.

Select the fields from the list


and press NEXT.
Working With Queries Wizard

Find Unmatched Query

In your report what are the


fields you required from your
customer master table.

Select the fields from the list


and press NEXT.

We will select the Mobile


Number, Service Class and
more fields if you want.
Working With Queries Wizard

Find Unmatched Query

Save Your Query

And Press FINISH


Working With Queries Wizard

Find Unmatched Query

And these are the


numbers who has not
generated any MOUs .

Means the unmatched


records between the
table Customer Master
& The MOUs report.
Please check the file Size
of your database ?
Access cannot handle more
the 2GB file size….!
Managing the Access Database

Want to reduce it … ?
Use “Compact & Repair”

To ensure optimal performance, you should Compact and Repair


your Microsoft Access files on a regular basis.

Also, if a serious problem occurs while you are working in an Access


file and Access attempts to recover it, you might receive a message
that the repair operation was cancelled and that you should
compact and repair the file.
Managing the Access Database

Why Compact and Repair a Database?


As you add and update data and change its design, a database file becomes
larger. Some of this growth comes from new data, but some comes from other
sources:

• Access creates temporary, hidden objects to accomplish various tasks.


Sometimes, these temporary objects remain in your database after Access no
longer needs them.

• When you delete a database object, the disk space that the object occupied is
not automatically reclaimed — the database file still uses that disk space,
even though the object has been deleted.
How to Compact & Repair Database?

To run Compact & Repair in Access 2007

1. Select the round office button.


2. Select Manage.
3. Select Compact & Repair Database.
How to Compact & Repair Database?

Now recheck your file size..


Compact and Repair an Access file automatically every time you close it : -

Open the Access database or Access project that you want Microsoft Access to compact
automatically.

1. Select the round office button.


2. Select Access Option
3. Select Current Database.
4. Mark the compact on close button.
5. Press Ok.
Thank You

You might also like