access tutorial2

26
1 MICROSOFT ACCESS TUTORIAL What is Microsoft Access? Microsoft Access is an office application program and also an example of data base management system (DBMS) this is used to create, expand and maintain database. It is also software designed for keeping records such as Hospital records, school records, personal record etc. Apart from Microsoft Access there are other examples of database management system they are as follows; Oracle Fox Base Fox Pro Clipper Paradox Dbase for windows Lotus Approach Microsoft Office Access is part of the Microsoft Office Professional suite which also includes the industry standard spreadsheet and word-processing software, Excel and Word. Like this other software in the Office Suite, Access was designed to be used by ordinary people who are not necessarily IT professionals. Despite being easy to for all of us to learn, it is still a powerful information management tool. Once you master the basics of database design, you can then move onto more advanced areas if you wish. For most people, however, just learning the basics is all that is needed for their requirements. Learn Access 2007 Although Access is a powerful database, it can be easily learnt by non-professionals. Access can be tackled at various levels of proficiency. To begin with you just need to know the simple basics which can be picked up very quickly, and then build on your knowledge from there. This tutorial is intended to get you started on the learning curve.

Upload: digital-bridge-institute-abuja

Post on 28-Jan-2018

95 views

Category:

Self Improvement


0 download

TRANSCRIPT

Page 1: Access tutorial2

1

MICROSOFT ACCESS TUTORIAL

What is Microsoft Access?

Microsoft Access is an office application program and also an example of data base management system (DBMS) this is used to create, expand and maintain database. It is also software designed for keeping records such as Hospital records, school records, personal record etc.

Apart from Microsoft Access there are other examples of database management system they are as follows;

Oracle Fox Base Fox Pro Clipper Paradox Dbase for windows Lotus Approach

Microsoft Office Access is part of the Microsoft Office Professional suite which also

includes the industry standard spreadsheet and word-processing software, Excel

and Word. Like this other software in the Office Suite, Access was designed to be

used by ordinary people who are not necessarily IT professionals. Despite being easy

to for all of us to learn, it is still a powerful information management tool. Once you

master the basics of database design, you can then move onto more advanced areas

if you wish. For most people, however, just learning the basics is all that is needed for

their requirements.

Learn Access 2007

Although Access is a powerful database, it can be easily learnt by non-professionals. Access can be tackled at various levels of proficiency. To begin with you just need to know the simple basics which can be picked up very quickly, and then build on your knowledge from there. This tutorial is intended to get you started on the learning curve.

Page 2: Access tutorial2

2

Access skills

When you undertake this Microsoft Access tutorial, you will be learning a valuable new skill, whether you intend to use it at work, in education or at home. Whatever your reason for learning Access 2007, I hope that you will enjoy the learning process, and feel a great sense of achievement when you gain proficiency in the first level of Access database development.

Access 2007's New Look

Before starting the main part of the tutorial, we are just going to familiarize ourselves with the new look Access 2007 User Interface - or Access Screen.

The Access Screen

The Access 2007 Screen is very different to that in previous versions. The menus have been replaced by the Access 2007 Ribbon; there is the MICROSOFT OFFICE BUTTON instead of the old file menu; and the old database window has been replaced by the Access 2007 NAVIGATION PANE. There is also a GETTING STARTED screen to create or open a database file when Access is launched.

Page 3: Access tutorial2

3

Access Ribbon

The ACCESS RIBBON works somewhat differently to the old Access Menus. There is a row of ribbon tabs with headings such as HOME, CREATE, EXTERNAL DATA, and DATABASE TOOLS. Clicking on each tab presents you with its own individual ribbon with its own particular icons. Each icon on a ribbon is contained within a group of icons that perform similar tasks. So, for example, the Create tab has groups for TABLES, FORMS, REPORTS and OTHER

Microsoft Office Button

The MICROSOFT OFFICE BUTTON is in the top left corner of the Access screen. It replaces the old Access file menu. So to perform functions such as saving, opening, new file creation, and printing etc, you need to click this button. To the right of this button is the Quick Access Toolbar intended to provide you

With quick access to some of the more common commands used in Access 2007. There are three default icons on this toolbar - save, undo and redo. You can also customise this toolbar to add additional commands as required.

Access Navigation Pane

The Access NAVIGATION PANE replaces the old database window. It is here where you will see the icons for all the tables, forms, queries and reports that you create. When you want to open one of your database "objects", you just click on one of these icons, and the required object will open in the main Access window.

Page 4: Access tutorial2

4

TERM AND DEFINATIONS

DATA: This can be defined as a raw material used for information or is a fact

generation about a person place or things.

INFORMATION: it is an already processed data.

FILE: This can be defined as a place were records are been kept or it is a collection of

records.

RECORD: This can be defined as a collection of logical related fields.

FIELDS: This can be defined as the collection of logical related data. Or it is the

smallest item of information in a database.

DATABASE

Database can be defined as a collection of tables and other logical related objects

were records are kept

CREATING A NEW DATABASE IN MICROSOFT ACCESS

The first step in creating an Access database is to create a blank database file. This is done from the Getting Started Screen when you launch Access. The file is saved onto one of your PCs folders (which you specify). The procedure for doing this is outlined below.

1. Launch Access

To begin, launch Access by clicking on the desktop icon, or choose Access from the start up menu.

This brings up the GETTING STARTED WITH MICROSOFT OFFICE ACCESS screen.

Page 5: Access tutorial2

5

2. Select Blank Database Template

Towards the top left of the screen you will see a "Blank Database" icon. Click this icon to bring up the Blank Database side bar on the right hand side of the screen. This is where you will enter details about the database file that you are about to create.

3. Enter filename for your Access 2007 database

Begin by entering the name that you want to call the database in the filename textbox.

Page 6: Access tutorial2

6

4. Browse and select folder

Next click the folder icon and browse for a folder to put your database. Once selected you should see the file path below the textbox.

5. Click Create

All you need to do now is click the "Create" command button below, and your database file saves to the location that you specified, and opens for you to work on.

OBJECTS IN DATABASE

Whenever a database is created in Microsoft Access the following objects are found.

Tables Queries Forms Reports Macros

The object above are were records or related records in a database are kept.

What is a Table?

A table is objects in a database were records are store in rows and columns. It is were records are directly entered in a database.

How Access stores data in Tables

Like all other databases, Access 2007 stores data in tables. They look a lot like the cells of a spreadsheet with columns and rows. Each horizontal column represents a table record, and each vertical column represents a table field. See Table example below:

A simple Table

ID Number First Name Surname Age

1 John Jones 35

2 Tracey Smith 25

3 Anne McNeil 30

Page 7: Access tutorial2

7

In the example Table above, there are four fields containing information about an individuals ID number, First Name, Surname and Age. Below the field headings there are 3 records containing information or data for each individual. As such, a database table is a list with each column containing the same specific sort of information. Each row of information is an individual record that might relate to a particular person, a business, or a product etc.

When planning a database table, most database designers will decide which column headings or fields they are going to use. This is the basis of the table structure. The actual data is added later and is not a part of the design process.

CREATIN A NEW TABLE USING DESIGN VIEW

1. Open database file

If you created a blank Access database in the previous tutorial lesson, you are now ready to create a new table. Begin by opening your existing database file if it is not already open. Do this by clicking on the Access desktop icon to bring up the getting started screen again. You should see the file name that you just created towards the top of the right hand side bar (If you can’t see it, click the folder icon to browse for the file). Click on the file name to bring up your blank database.

If, at this stage, you get a security warning underneath the ribbon, click where it says options, select the "enable this content" radio button (in the pop-up window), and then click ok.

Your blank database file should now be fully open.

Page 8: Access tutorial2

8

2. Create Access Table

Select the CREATE tab on the Access ribbon.

Next select the TABLE DESIGN icon from the TABLES group. This creates a new table.

3. Create fields in DESIGN VIEW

This brings up the TABLE DESIGN GRID where you enter each field name and its data type. After entry the field names and data type close the table design view and save the table with name of your choice.

After that the primary key box appears click on NO from the displayed box

The first field we are going to create is the ID field which is going to contain a unique reference number for each record. Enter the name "ID" into the first column of the first row in the grid. Because we want Access to automatically generate a unique reference number, select AUTONUMBER from the drop down list in the data type column.

On the next row the field is going to be called FIRSTNAME and the data type is going to be TEXT. On the third row the field name is SURNAME with the data type again being TEXT. And finally, the last field name is AGE and the data type here is going to be NUMBER.

4. Data entry in DATASHEET VIEW

Although entering data onto the datasheet table is not a part of the design process, the table now exists as a database object, and you can test it by entering some information into the cells.

Page 9: Access tutorial2

9

Select the first cell in the FIRSTNAME column and enter the name JOHN. For SURNAME enter JONES, and for AGE enter 35.

NB just ignore the column underneath the heading ADD NEW FIELD. We created all the fields we needed in design view.

You have now entered the first record in the table - record 1 for John Jones aged 35. You can now press the return key and the record will save automatically. You are now ready to enter the second record on the next row - TRACEY SMITH 25. Press return and then fill in the data for the last record we are going to do for now - ANNE McNEIL 30

Your datasheet table should now look like this:

Working with Access Tables

Once you have an Access Table populated with data, you have the option to work with it right away. Indeed, some people may not go on to create forms, queries, and reports once they have created their first table. With a single table you can, for example, store, edit, filter, search, and calculate a set of database records. Now that you have created your first table and stored a number of records, we will take a look how you go about working with tables. We shall use your newly created table with some additional records to illustrate how to do this.

Page 10: Access tutorial2

10

Access FORMS are user friendly

In the previous lesson, you created an Access Table and entered three records. However, to get the most out of Access it makes sense to create a data entry FORM. By doing so you are making your database more users friendly. It is easier and quicker to enter data onto a form than it is into a table, not least because you have more control over the layout and labeling of your form. In this lesson we will learn how to create a FORM that uses your newly created table as the DATA SOURCE.

DATA TYPE

A data type can be defined as the type of data or character that a field should accept when records are been entered into tables in datasheet view.

The following types of data type can be used when creating a new table in table design view using Microsoft access.

1. TEXT: It is a data type that can accept any type of input from the keyboard.

E.g. alphabet, numbers or special characters.

2. AUTO NUBER: This type of data type is used to number records serially

whenever they are entered into the table in datasheet view.

3. CURRENCY: This type of data type accept only currency e.g. Dollars ($)

Page 11: Access tutorial2

11

4. MEMO: This type of data type is used to accept short description, short note or

comment

5. NUMBER: This type of data type can only accept numbers or numeric

characters.

6. (Object Linking Embedding)OLE OBJECT: This type of data type is used link

an image or object with the record in a table.

7. DATE/TIME: This type of data type accept date and time depending on the

format of the system e.g. DD/MM/YYYY and MM/DD/YYYY and HH/MM/SS

i.e. HH= Hour, MM= Minutes, SS= Seconds

8. YES/NO: This data type is used to accept logical operation or two (2) state

conditional statements i.e. YES/NO, ON/OFF, HIGH/LOW etc.

EXAMPLES OF FIELD NAME AND DATA TYPE

FIELD NAME DATA TYPE

NAME TEXT

SEX TEXT

AGE NUMBER

SERIAL NUMBER AUTO NUMBER

COMMENT MEMO

DATE DATE/TIME

PICTURE OLE OBJECT

FIELD SIZE

This command is used to indicate the maximum number of character that a field

should accept when data are been entered into a table.

HOW TO SET A FIELD SIZE IN THE TABLE ESIGN VIEW

1. Create the table in table design view

2. Place the cursor inside the field whose size you want to set.

Page 12: Access tutorial2

12

3. Click on the field size room or place the cursor inside the field size room and

delete the existing field size and specify the field size of your choice.

4. Save the table and close the table design view window

5. Open the table from the datasheet view and enter your records.

PRIMARY KEY

A primary key is the key or command that is used to protect a particular field

against the duplication of data or repetition of data. It is the key that uniquely

indentifies a data or records in a table.

There are two ways of assigning primary key to the fields in a table in a database

these are

1. The user assigning a primary key

2. Microsoft Access assigning a primary key

HOW USERS CAN ASSIGN PRIMARY KEY

1. Create the table in the table design view

2. Right click on the field you want to assign the primary key and click on

primary key from the pop menu list OR place the cursor on the field, then click

on the primary key icon from the table design view.

3. Save the table with a name and close the table design view

4. Open the table from the database window in the datasheet vie and enter your

records

N/B.

Microsoft Access will assign the primary key to a new field called ID (Identification)

with auto number called the data type.

HOW TO REMOVE THE PRIMARY KEY

1. Open the database that contains the table

2. Select the table and click on create from the menu bar

3. From the displayed access ribbon click on design view

4. From the table design view, right click on the field that contains the primary

key and click on the primary key from the pop menu list OR place

Page 13: Access tutorial2

13

your cursor on the field and then click on the primary key icon from the table

design view bar

5. Save the changes you have made to the table and close the table design view

window.

QUERY

A query can be defined as an object in a database that is use to extract records from

either a table or form existing in the same database based on the given criteria or

command.

TYPES OF QUERY

Select Query

Action Query

Structural Query Operator (SQL)

A SELECT QUERY:

This type of query is used to extract or select records from a table in a database

based on the given criteria or command.

HOW TO RUN A SELECT QUERY

1. Create a table in the database or open an already existing database

2. From the menu bar click CREATE TAB and then go to the OTHER group on the far right of the ribbon.

3. Then click on the QUERY DESIGN ICON to bring up the query design grid.

4. The next stage is to select which table you are going to use in this query from the SHOW TABLE pop up window.

Page 14: Access tutorial2

14

5. So far there is only one table in your database - TABLE1. This should be highlighted when the window opens, but if not, just click on it once.

6. Click on ADD then you close the pop-up window by clicking x or close tab.

Select fields from Table

7. In the table1 box, you will see a list of its field names. We are going to use all the fields in this query, so select each one individually by double clicking on their names. You will now see the field names at the top of each column in the Query Design Grid.

Page 15: Access tutorial2

15

Enter query criteria

8. As you may remember, the purpose of our query is to extract records where the persons name is greater than or equal to 35. To do this we enter the criteria into the appropriate cell of the query design grid. In this case you need to go to the AGE column of the CRITERIA row, and enter the formula >=35.

Save and Run Query

9. Click the Run icon from the RESULTS GROUP of the Access Ribbon and save the table with the name of your choice. You should now be presented with a datasheet displaying your query results - JOHN JONES 35 and JOE BROWN 39. Base on the provided table below

ID Number FirstName Surname Age

1 John Jones 35

2 Tracey Smith 25

3 Anne McNeil 30

4 Joe Brown 39

5 Sue Moore 33

What we want Access to do is extract all the records in the above table where the person’s age is greater than or equal to 35. Access Queries can do far more than this, of course, but this simple task should serve as a useful learning exercise.

Page 16: Access tutorial2

16

QUERY OPERATOR

These are characters or special characters that are used on query criteria to specify the range of data or records that is to be selected or extracted from a particular table in a database.

TYPES OF QUERY OPERATOR

Relational Query operator Logical query Operator

Relational Query Operator: these are character used on a given criteria to select records from a table e.g. (>, <, >=, <=, <> ,=)

Logical Query Operator: This type of operator usually combine two or more relational operators before extracting records from the specified table e.g.

i. OR Operator: this operator will only select records from an existing table if one(1) , more than one(1) of the criteria or all the criteria specified in a query command are satisfied e.g. >20, or 19

ii. And Operator: This operator will only select record when all the conditions specified in the criteria are satisfied. The AND operator is commonly use to query for date

WILD CHARACTERS

These are characters that are used in query criteria to represent any type of

character used to enter data into a table. The common types of wild characters that

are used include?, *,”etc.

EXAMPLES OF QUAERY CRITERIA

1. To select those employed or admitted in one year e.g. 1996, enter this in the

query design view >=1/1/1996 AND <=31/12/1996.

2. To select data or records that contains certain number of character e.g. 4

character, enter this “????” while each (?) represent character

3. To select those employed or admitted in more than one year e.g. from 2000 to

2012 enter this >=1/1/2000 AND <=31/12/2012

4. To select records that begins with a specified character e.g. that begins with K,

enter this K* in the query design view under field u want to query.

Page 17: Access tutorial2

17

5. To select records that ends with a specific character e.g. that ends with K

enter *K

ACTION QUERY

This is the type of query that is used to extract records from an exiting table in a

database based on the given criteria and in addition performs other task.

TYPES OF ACTION QUERY

Make Table Query

Delete Query

Append Query

Update Query

Make Table Query: This type of action query is used to select records from a table

based on the criteria given and in addition, create a new table were the selected

records are kept.

Delete Query: This type of action query is used to delete records existing in a table

based on the criteria given.

HOW TO CREATE A DELETE QUERY

1. Create a select query and specify your criteria.

2. Click on delete query Icon from the drop down Access

ribbon.

3. Click on the run Icon and click on yes from the query dialog box that

will be displayed.

4. Close the query design window and do not save i.e. saving is optional

5. Open the table from the database and view the updated record in the table

datasheet view.

APPEND QUERY: This type of action query is used to copy or append records from

one table into another table existing in the same database.

UPDATE QUERY: This type of action query is normally used to update or change

existing type of records in a table to reflect the current position of the database.

Page 18: Access tutorial2

18

HOW TO CREATE AN UPDATE QUERY

6. Create a select query and specify your criteria.

7. Click on Update query Icon from the drop down Access ribbon.

8. Place your cursor on the update to row under the field whose data

you want to update and specify your criteria to update to.

9. Click on the run Icon and click on yes from the query dialog box that

will be displayed.

10. Close the query design window and do not save i.e. saving is optional

11. Open the table from the database and view the updated record in the table

datasheet view.

Create Access form

There are a number of ways to create an Access form they are.

Form design view Form wizard

CREATING FORM USING FORM WIZARD

1. Select form wizard

Open your database if it is not already open. Click the CREATE tab on the

ACCESS RIBBON and then select MORE FORMS from the forms group.

A drop down list of form types appears. You need to select FORM WIZARD from this list.

2. Select table and fields

Page 19: Access tutorial2

19

The Form wizard then opens as the pop up window below.

On the first page of the form wizard we select which table we are going to use as the DATA SOURCE. Since there is only one table in this database so far, it should already be selected for us in the TABLES/QUERIES combo box.

Underneath there is a list of the four fields in your table. You could select each field individually by highlighting the field name and clicking the single arrow >. We can, however, select all four just by clicking the double arrow >>. Once they have been transfered into the right hand box they are selected. We can now click NEXT to go to page 2 of the form wizard.

Page 20: Access tutorial2

20

3. Form Layout

This is where we choose the FORM LAYOUT. We are going to leave this on the default setting of COLUMNAR. Click NEXT again to move onto page three of the form wizard.

Page 21: Access tutorial2

21

4. Form Style

Here we select a style that from the list box. Preview a style by clicking on its name. This step just determines how the form looks aesthetically. Once you have selected a style to your taste, click NEXT again.

5. Form Title

Page 22: Access tutorial2

22

This is the last stage of the wizard. Here we are going to choose the name for our form - lets say FORM1. We are going to leave the radio button selected for OPEN THE FORM TO ENTER OR VIEW INFORMATION

All we need to do now is click FINISH and our form should like something like this:

6. Navigate Records via Access Form

As you can see, the form opens with the first record in your original table displayed. You can navigate through each record using the NAVIGATION BUTTON at the bottom left of the form window.

To move to the next record click the right arrow button on the navigation control. To move to the last record click the >| button on the navigation control. To move backwards through the recordset use the left arrow buttons. You could edit any record from the form, which will update the data in your table. For now, though, just try navigating through the three records without changing any data.

7. Create New Record via Access Form

Now that you know how to move through the recordset, lets finish off by adding two more records. To do this click the star button on the right of the navigation control. This should bring up a blank record. Add JOE for firstname, BROWN for surname, and 39 for age. Click the star again to bring up a new blank record, and enter SUE MOORE 33. When you have finished click x on the form window to close.

ACCESS REPORTS PRESENT DATA

What is a Report?

Page 23: Access tutorial2

23

A report is an object in a database that is used to display records selected from either a table or a query in the same database. The reports also shows selected records in pages unlike four per page when design view is used but records are displayed differently when the report wizard is used.

Access REPORTS is also way of displaying and printing information from your database. Developers often use Reports to display the results of a Query.

Like other Access database objects, there a number of ways to create an Access REPORT. We are going use the REPORT WIZARD.

CREATING A REPORT USING REPORT WIZARD

1. Open Report Wizard

Begin by selecting the CREATE TAB on the Access Ribbon. Then click REPORT WIZARD from the REPORTS group to open the pop up window.

2. Select Report Data Source and Fields

The first page of the Report Wizard is almost identical to that of the Form Wizard. On this page we will select QUERY1 as the DATA SOURCE for the Report. This is done by selecting the query from the list in the TABLES/QUERIES combo box. Then select all fields from QUERY1 by clicking the double arrow to the right of the text box labelled AVAILABLE FIELDS. The field names will now appear in the SELECTED FIELDS text box on the right. Click next to go to the second page of the wizard.

Page 24: Access tutorial2

24

3. Report Grouping Levels

Page two of the wizard is where you can add grouping levels if required. So we could, for example, group each person in our report with others of the same age. We dont need to do this for this particular example, but it is certainly a useful feature that we might want to learn more about later. But for now, just click next.

4. Record Sort Order

Page three of the wizard is where you determine what order the records are displayed in your report. So for example you might want to display records in ascending order of age. For this example, however, we are going to put your records into alphabetical order for SURNAME and FIRSTNAME. Begin by clicking the top drop down box and selecting SURNAME, and in the box 2 below select FIRSTNAME. This means that records are sorted alphabetically by surname, and if two surnames are the same, the FIRSTNAME is used to determine which record comes first etc. Click Next

Page 25: Access tutorial2

25

5. Report Lay Out

This page of the Wizard is where you set the lay out for your report. There are various lay out options, but in our case we shall keep to the default setting of TABULAR. Click next.

6. Style

For style, select the style of your choice from the list and click next.

Page 26: Access tutorial2

26

7. Name of Report

Name your report REPORT1 and then click FINISH. Your access report will now be displayed on the screen, and should look something like this: