14
Module 1 OFFICE AUTOMATION May - 2010 / BLY ADCPM MS ACCESS 2007 Page - 1 ~ ~ ~ INDEX ~ ~ ~ TOPIC PAGE INTRODUCTION of MS ACCESS 2007……….............. .................. 02 WHAT is DATABASE …………………………….......... .................. 02 WHAT is DBMS ………...…………………………........ .................. 02 STEPS in DESIGNING a DATABASE …………............. .................. 02 STARTING MS ACCESS 2007 …………………............ .................. 02 CREATING a NEW DATABSE ...…………….…............ .................. 03 ~ 04 FEATURES of MS ACCESS ……………………............ .................. 04 TABLES ………………………..…………………......... .................. 04 ~ 06 SORTING …………………………….……………...... .. .................. 06 ~ 07 INDEXING …………………………………………....... .................. 07 RELATIONSHIP ...………………………………........... .................. 07 ~ 08 QUERIES …………………...………………………...... .................. 08 ~ 12 FORMS ……………………………………………........ .................. 12 REPORTS …………………………………………...... .. .................. 13 ~ 14

MS Access2007

Embed Size (px)

DESCRIPTION

ms access

Citation preview

Page 1: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 1

~ ~ ~ INDEX ~ ~ ~

TOPIC PAGE

INTRODUCTION of MS ACCESS 2007……….............. .................. 02

WHAT is DATABASE …………………………….......... .................. 02

WHAT is DBMS ………...…………………………........ .................. 02

STEPS in DESIGNING a DATABASE …………............. .................. 02

STARTING MS ACCESS 2007 …………………............ .................. 02

CREATING a NEW DATABSE ...…………….…............ .................. 03 ~ 04

FEATURES of MS ACCESS ……………………............ .................. 04

TABLES ………………………..…………………......... .................. 04 ~ 06

SORTING …………………………….……………........ .................. 06 ~ 07

INDEXING …………………………………………....... .................. 07

RELATIONSHIP ...………………………………........... .................. 07 ~ 08

QUERIES …………………...………………………...... .................. 08 ~ 12

FORMS ……………………………………………........ .................. 12

REPORTS …………………………………………........ .................. 13 ~ 14

Page 2: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 2

INTRODUCTION OF MS ACCESS 2007:

Microsoft Access is a very powerful component of MS Office2007. It is used to organize and manipulate data of Relational Database Management System (RDBMS). It is very easy and user friendly. It can store voluminous amount of data. Access allows you to sort data in an organized manner. It also allows you to carry out all the functions and stores information in the form of table so that you can build your database. Each row in a table which narrates to the information of a particular person is called a record. The special features of Access are forms, reports and queries which help the user in retrieving the desired information as and when required.

In MS Access, tables consist of data and queries allow you to organize and extract information from your data. Forms facilitate simplified onscreen Data entries for tables and reports print data in a presentation format.

What is DATABASE?

Database is an organized collection of related information. Database contains information about one particular enterprise. Data is arranged in the form of a table, where columns are known as fields and rows are known as records.

What is DBMS?

A Database Management System (DBMS) is a system that stores and retrieves information in a database. A computer DBMS is a program that can be used to store and retrieve data on your computer.

Steps in Designing a Database:

1. Determine the purpose of your database: The first step in designing a database is to determine its purpose and how it is to be used. You need to know what information you want from the database.

2. Determine the tables you need: Determine the tables can be tricki8est step in the database design process. That’s because the results you want from your database- the reports you want to print, the forms you want to use, the questions you want answered.

3. Determine the fields you need: Each table contains information about the same subject, and each field in a table contains individual facts about the table’s subject.

4. Refine your design: After you have designed the tables, fields you need to study the design and detect any flaws that might remain. It is easier to change your database design now than it will be after you have filled the tables with data.

5. Enter data and create other database objects: When you are satisfied that the table structures meet the design principles described here, then it’s time to go ahead and add all your existing data to the tables. You can create any queries, forms, reports etc. that you may want.

Starting MS ACCESS 2007:

To Start MS ACCESS, you may follow these steps:

Click at Start Button.

Click on All Programs and now click Microsoft Office.

Now select Microsoft Office Access 2007.

Page 3: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 3

To Create a new Database:

Steps to create a new database:

Page 4: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 4

First go to start button and click on it.

Now go to all program and then select the MS Access 2007

Now MS Access 2007 Screen appears.

Click on blank icon database.

Now type the name of the file.

Now click on create button.

MS Access database will save the file with given name and show a default table1.

Features of MS Access:

Using Microsoft Access, you can manage all your information from a single database file. Database file in MS Access are stored with extension .MDB. Within the file, you can divide your data into separate storage containers called tables. You can view, add and update table data by using online forms; find and retrieve the data as you want by using queries; and analyze or print data in a specific layout by using reports.

MS Access offers following features to let you manage your data:

Tables: To store the data, you can create one table for each type of information that you track. To bring the data from multiple tables together in a query, form, report you can define relationship between the tables.

A Table refers to a storage container storing data pertaining to single object, subject or purpose.

Components of a Table:

Byte: A byte is a group of eight bits and is used to store a character.

Date Item/Field: A data item is the smallest unit of named data. It may consist of any number of bits or bytes. A data item represents one type of information and id often referred to as a field or data item. Fields are the columns containing one type of information.

Record: A record is named collection of data item which represents a complete unit of information. Records are the rows representing one complete unit of information. A logical record contains contents of all the fields.

Table: A table is a named collection of all occurrences of given type of logical record. A table is a group of all records.

Table Window: In the upper portion of the window you can specify the fields that you want in the table.

In the lower portion of the window you can set the properties for each field.

Page 5: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 5

Creating a Table:

In the Database window click the Create Panel.

Select the Tables group, and then choose according to your requirement Table Template or Table Design.

First column in each row will contain field names which can be up to 64 character including spaces.

After naming the field you can choose the data type for that field. Using the dropdown list which is displayed by clicking on the down arrow in the second column.

When you add a field MS Access automatically assigns it to the Text data type.

Properties of the Table:

A propety is a element allied with each field which controls the access or display of data in that field. One property is the format property which tells the format to use while displaying data.

To set the Field Size Property:

Click any box in the row that defines the field.

Click the field size property box and then select the appropriate choice.

Primary Key: In a table, each record is identified with a unique value, in a field of table; there are unique values for all records. This unique value identifies the record.

Primary Key is a field that uniquely identifies the records in a table.

To set the Primary key:

Click Create Panel; select the Table Design from the Tables group.

Now click on the Primary key button.

Click the field you want to use for the primary key. To create a multiple field primary key, hold down CTRL key and then click the field selector to the left of the each field that you want to include.

Access adds a key indicator to the left of the field or the fields you specify as the Primary key.

Page 6: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 6

Note: You can give the name to the fields of a Database in Design View

of the table. But you can enter the data in a table only in Datasheet View.

To View Data in a Table:

In the Database window click the Table button to display the list of tables in the database.

Double click the name of the table you want to see.

MS Access displays the table in Datasheet view. Datasheet view displays data from the table in columns and rows similar to a spread sheet. You can resize the columns in a datasheet and can resize the records.

To Move a Field in a Table:

Select the field by clicking the field selector to the left of the field name.

Click the field selector again and drag it to new position.

To Delete a Field in a Table:

Select the field by clicking the field selector and then press the DEL key.

To Edit Data in a Table:

After opening the table in Datasheet view, click any field in the table to position an insertion point in the field.

Make changes in data or type new data.

Click a different record to save the changes.

To replace the entry in a field with the entry in the same field of the previous record, click in the field and press CTRL + ‘.

To Delete a Record:

Open the Table in Datasheet view.

Select the record which you want to delete.

Note: The shortcut key to select current is CTRL + Spacebar and current is Shift + Spacebar. To select multiple records press Shift + Spacebar and then Shift + Up-Arrow or Down-Arrow.

Click Delete Record.

Sorting:

Sorting refers to arrangement of records in a specific order of a value in the ascending or descending order. You can sort the records on multiple fields or keys, but such sorting is not possible in datasheet view. This type of sorting can be achieved through queries.

Sorting by using Single Field/Single Key:

Open the desired table in Datasheet view.

Click and select the field on the basis of which records are to be sorted.

Click on Home Panel and then click Sort Ascending or Sort Descending to arrange the records in ascending order or descending order respectively.

Indexing:

Indexing can be achieved by setting the Indexed property of field to Yes. In order to create an index for a field, you have to follow these steps:

Open the table in design view.

Page 7: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 7

Click the field whose index is to be created.

Set the Indexed property to Yes.

Close the window and save the changes and the index will be created.

Relationships: There are many kinds of relationships as One to One Relationship, One to many Relationship and Many to Many Relationship.

One to One Relationship: In One to One relationship a record in table1 cannot have more than one matching record in table2 and a record in table2 cannot have more than one matching in table1. The information in the two tables can be combined to one table.

Suppose you have two tables one table containing information about the Employee Names and Addresses the other containing the information such as the Salaries of the employees. So when the One to One relationship is needed you can set up.

When the two tables have same primary key field in both the two tables.

If the two tables have different primary keys then choose one of the tables and put its key field into another table as foreign key.

Foreign Key: Foreign key is a field or combination of fields that are related to primary key of another table. Foreign key can be Null. If a foreign key consists of more than one field and any of those fields is Null, all fields must be Null. Null refers to a value that indicates missing or unknown data. Null values can be entered in fields for which information is unknown.

One to Many Relationship: It is the most common type of relationship in the relational database. In this a record in the first table can have more than one matching record in the second table but the record in second table has at most one record matching with first table.

Many to Many Relationship: In this relationship one record of the first table can have matching with more than one record in the table2 and the record in table2 can have more than one matching with table1.

To set Relationship between Two Tables:

Open a database or switch to the Database window for the open database.

From the Database tools, choose Relationships.

Now Relationships dialog box will be appear.

In the primary table drop down list box, select the table whose primary key you want to relate to another table.

MS Access displays the primary key field of the table below the list box.

In the Related Table drop down list box, select the table that contains related data.

If you creating a One to One relationship, select the One button in the type option group.

Page 8: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 8

For each primary key field, select the field in the Select Matching Fields drop down list box contains related data.

Choose the Add button, Access created the relationship between the data in two tables and the data in two tables will automatically be related in new queries or sub forms.

Query: Queries are used to view, change and analyze data in different

ways. You can bring together data from multiple tables and sort it in a particular order, perform calculations on groups of records.

Queries are the database tools that are used to view, change and analyze data in different ways. A query is a link between tables and forms or reports.

Types of Queries:

There five types of queries that you can create in MS Access.

Select Queries: A Select query is the most common type of query. A select query is the query, which can retrieve data from one or more tables by using the user specified criteria and can later display the retrieved data in desired order.

Parameter Queries: A parameter query is a query that lets the user retrieve records depending upon the value specified by the user at runtime. It means when a parameter query is run it displays its own dialog box wherein use is asked to provide some value on the basis of which the record are retrieved from the table.

To create Parameter Query:

Create a Select query.

In query Design view, drag the fields from the field list to the query design grid.

In the Criteria cell for each field you want to use as a parameter, type a prompt enclosed in square brackets. This prompt will display when the query is run. The text of the prompt must be different from the field name.

To view the results, click View on the Home panel and then type a value for the parameter. To return to query Design view, click view again.

Crosstab Queries: A crosstab query calculates a sum, average, count or other type of total for data that is grouped by two types of information with one displayed down the left hand side of the datasheet and another across the top of the datasheet.

Action Queries: An action query is a query that makes changes to many records in just one operation. There are four types of action queries: delete, update, append and make table.

Delete query: This type of Action query used to delete a group of record from one or more tables. With this type of query you can delete entire record, not just selected fields within records.

To Delete a Relationship:

Page 9: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 9

If you haven't done so already, open the Relationships pane.

On the Database Tools tab, in the Show/Hide group, click Relationships.

Note the fields involved in the relationship so that you can go restore the relationship after you delete your data.

Right-click the relationship (the line) connecting the tables involved in the deletion operation, and then click Delete on the shortcut menu.

Or Select the relationship and press DELETE.

Update query: This type of action query makes global changes to a group of records in one or more tables. With Update query you can change data in existing tables.

Steps to create Update Query:

On the Design tab, in the Query Type group, click Update.

This procedure shows how to change the select query to an update query. When you do so, Access adds the Update to row in the query design grid.

Locate the field that contains the data you want to change, and type your expression (your change criteria) in the Update to row for that field.

You can use any valid expression in the Update to row. On the Design tab, in the Results group, click Run.

An alert message appears.

Click Yes to run the query and update the data.

Append query: This type of Action query adds a group of records from one or more tables to the end of one or more tables.

Create and Run an Append query:

The process of creating an append query follows these basic steps:

Create a select query.

Convert the select query to an append query.

Choose the destination fields for each column in the append query.

Run the query to append the records.

Make-table query: This type of Action query you can creates a new table from all or part of the data in one or more tables

Steps to create a Make table query:

First click on create menu.

Click on query design.

A show table dialog box appears from where you select the table in which you want a make table query by using add button and close the dialog box.

Design menu will be open, now go to query type and click on make table query.

Page 10: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 10

Now open a make table dialog box.

In which go to table name and type the table name and click on

OK.

Now go to query design and select the fields which you want to show in the make table.

After selecting the fields, close the query design by click on cross button.

A save as dialog box will appear, here type the query name and click on OK.

To run a Make table query:

First click on table tab and see the table name which you typed at the time of saving make table query, but there will not be seen.

Now click on query tab and click on make table query.

Now again click on table tab and see the table name again .at this time the make table will appear under

the table tab.

SQL Queries: An SQL query is a query which is created using an SQL statement.

Creating Queries:

A query is a link between tables, forms or reports. Queries can be created through wizards as well as manually. If you create a query through wizards, it itself guides you how to do so and if you create a query from scratch, you have to take care of everything on your own.

To create a Query through Query Wizard:

In the database window, click Query Wizard under the Create Panel.

A dialog box will appear.

Choose the design as you want your query type and click OK.

Page 11: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 11

A screen will appear before you named Simple Query Wizard, choose the table from which you want to make query.

Now in the Available Fields column, your table fields will be shown.

Select the fields which you want to show in the query

with the > or >>

sign. You select

the field with > sign one by one

but with >> sign

you can add the all field at a time.

Now the Selected Fields column will fill with fields, and then click Next.

Now a screen will open click asking Would you like a Detail or summary query? Choose Detail and click Next.

Again a screen will open now click Finish.

To create a Query through Design View:

Click on Query Design under the Create panel in Database window.

Now you will see the Show Table dialog box on your screen. In the show Table dialog box select the desired table and then click on the Add button. The table will be added to the Query Design window. Now click on the close button to close the show Table dialog box.

Now you will see the Query Design window on your screen. This is where you build the query. The Query Design window consists of two areas. The field list section at the top of the window contains a list of the fields in the table or tables you have added to the query.

To add the fields to the design grid from the table or tables in the field list section of the Query Design window, double click on the field you want to add. Alternatively you can click and drag the field

Page 12: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 12

from the field list to the field row in the design grid. Repeat this process until you have added all the fields you need in the query.

Once you have added fields to the design grid in Query Design view you have effectively created a very simple Query. To see the results of the query you have to save your query window using command Sava As. And then switch to Query Datasheet View. If you continue to build a query you can switch between Query Design view and Query Datasheet view to check your progress until you obtain the results.

Forms: A form identifies the data that you want to collect and gives way to enter data into your database. Form helps to easily view, enter and change data directly in a table, you can create a form.

A Form is an interface in user specified layout that lets users view, enter, change data directly in the table.

Creating Forms:

To create a Form with Form Wizard:

Go to Create panel, click at the Forms group.

Then select the Form.

Now choose your table and Form style as Tabular or Stacked.

To create a Form in Design view:

If you want to design the Form yourself, you have to select the Form Design from the Forms group under the Create panel.

Now Design panel will appear before you. You can choose and drag the tools on your Form window with the help of Controls group.

After that you can add the fields which you have already define in the table/query, by clicking Add Existing Fields.

Creating a form by using the Blank Form tool:

On the Create tab, in the Forms group, click Blank Form.

Access opens a blank form in Layout view, and displays the Field List pane.

In the Field List pane, click the plus sign (+) next to the table or tables that contain the fields that you want to see on the form.

To add a field to the form, double-click it or drag it onto the form. To add several fields at once, hold down CTRL and click several fields, and then drag them onto the form at the same time.

If you want to add a wider variety of controls to the form, switch to Design view by right-clicking the form and then clicking Design View

. You can then use the tools in the Controls group on the Design tab.

Reports: Report is used to view all the information about one particular

product at once. A report is information which you can organize and format to fit your specifications. A report gives way to retrieve and present data as meaningful information you can use and distribute.

Page 13: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 13

A Report is an effective way to present data in printed format. It is a formal, presentable printed document that lists data in a formatted manner.

Creating Report:

Reports are created on the base of table. Firstly design or select your table on which you want to create the Report. To create the report, you have to follow these steps:

To Create a new report with the Report Wizard:

First click on the Reports group existing in the Create Panel.

Now click on the Report Wizard.

A screen will appear before asking a question, Which fields do you want on your report? Select the table and select the fields.

Now click on Next.

Then a new Screen will be open asking a question, Do you want to any grouping levels? Click on Next.

Again a screen will open asking a question, What sort order do you want for your records? Select your desired order for sorting

and click Next.

Now a screen will appear with asking a question, How would you like to layout your report? Choose the layout style as your

requirement. And decide the orientation of your Report.

Click on Next.

Page 14: MS Access2007

Module 1 OFFICE AUTOMATION May - 2010 / BLY

ADCPM MS ACCESS 2007 Page - 14

After clicking Next, a screen will display before you asking What style would you like? Choose your style and click Next.

Now a screen will be shown as What title would you like your Report? Type the title of your report and click on the Preview of the report and then click on Finish.

To Create a Report in Design view:

Go to Create panel, click on Report Design.

Now Report design window gets opened, here you see that to perform your design, a report is prearranged with two rulers, one horizontal on the top section of the report and one vertical on the left section.

Then you have a toolbox equipped with buttons, text boxes and other items you can use to give a lot of flexibility to your application.

You also have the originating table, the field list on your screen in case you want to add an item that you did not include in the beginning.

Click at Add Existing Fields to view field list Window.

Formatting in Reports:

Firstly open the report in Design view.

Now to format a text box or text boxes, select the text you want to format with the select tool.

Then click at Fonts group.

Now use the commands on the formatting toolbar to change the look of the text.