Sei sulla pagina 1di 14

Microsoft Access Database

What is a database? It's an organized collection of data. A database management system (DBMS) such as Access provides you with the software tools you need to organize that data in a flexible manner. It includes facilities to add, modify or delete data from the database, ask questions (or queries) about the data stored in the database and produce reports summarizing selected contents. Microsoft Access provides users with one of the simplest and most flexible DBMS solutions on the market today. Regular users of Microsoft products enjoy the familiar Windows "look and feel" as well as the tight integration with other Microsoft Office family products. An abundance of wizards lessen the complexity of administrative tasks and the ever-present Microsoft Office Helper (you know the paper clip!) is available for those who care to use it. Before installing Access, be sure that your system meets Microsoft's minimum system requirements.

Versions
Access 1.0 Access 1.1 Access 2.x (Office 4.x) Access 95 (Office 95) Access 97 (Office 97) Access 2000 (Office 2000) Access 2002 (Office XP)

Creating an Access Database


To create a new database in Access follow these steps: 1. 2. Start Access From the menu choose File < New

3.

The "New File" side bar will be displayed on the right-hand side of the screen

4.

5.

Left-click the option "Blank database...", which will then ask you to name your database. Helpful Hint: Access databases are saved with the .mdb extension. Name your file (we chose TizagDB) and press Create. This will automatically save your blank database, so remember where you put it!

6.

The Access Database interface should now be displayed and you are well on your way to learning Access!

Now that the database has been created we can begin to create our first Access Table. A table resides within a database and holds information specific to a certain area.

Access Tables
A table in Access is quite different then a table in real life. Here's an example of a table in Access:

There are for key components we want you to learn right now:

1. 2.

3.

4.

tbl_Sales: The name of our table is the example is "tbl_Sales". Note that we could have simply called our sales table Sales, but by including a prefix tbl_ there is absolutely no confusion and is a great Access habit to pick up! Columns: A column is one vertical section of the table (i.e. up-and-down sections). The vertical columns have their label at the top and these labels should describe the type of information that will be stored. The columns in this table are: Employee, Product, Price and SaleNumber. Rows: A row is one horizontal segment of the table (i.e. left-to-right sections). One record takes up exactly one row. For example, in this table one sale at Bob's Shoe Store was a pair of slippers, which sold for $5.00. This record was entered left-to-right as follows: EmployeeBob, Product-Slipper, Price-$5.00, SaleNumber-3. Cells: A cell is simply the intersection of a row and a column. Can you find the cell that contains the value $150.00? Which row and column intersected at this cell? When you enter information into Access it will often be one cell at a time!

Creating an Access Table


When you create a table in Access you have to know what the table will store and what format that information will be in. For example if you wanted to store the product identification numbers involved in a sale, then you might label that column "ProductID" and specify that only numbers should be stored for that column.

1.

With the Tables object tab selected, double-click the "Create table in Design view"

2.

This will bring up the Table Design View

3.

4.

There are three columns here that should be explained in detail: o Field Name: This is where you type the name for your column. A common practice is to make it one word and to use capitalization for multiple words squished into one (e.g. SaleNumber) o Data Type: This column is where you specify the type of data that will be stored. If you are storing money then select Currency. The most common types of data are: Text, Number, Currency and Date/Time. o Description: Here you can type optional notes to remind yourself or provide useful information for others who might be viewing this file later. The first column in our tbl_Sales example was Employee, so let's enter in Employee in the Field Name column and choose Text from the Data Type column. If click inside the Data Type column you will see that it is actually a drop down select box with many options to choose from. Select the Text option.

5.

Enter the following information for our remaining three columns of tbl_Sales: o Field Name: Product, Data Type: Text o Field Name: Price, Data Type: Currency o Field Name: SaleNumber, Data Type: Number

6.

Before we are finished here, we need to make a Primary Key. A primary key is restriction that we place on a column stating that there can be no duplicate values in that column. Rightclick in the SaleNumber row and choose Primary Key from the pop-up menu.

7.

We have finished our table's outline so click the X in the top right to close the design view (don't close Access, just the Design Window).

8.

This will also bring up a prompt to name your Access Table. Click yes and enter "tbl_Sales" for your table's name.

The Next Step: Entering Data (Records) Creating an Access Database


Now that we have completed the construction of our table we can finally begin to enter in our sales information. The next is the process of entering data into an Access table

Access Records
To begin entering records, double-click the table you want to add records to.

1.

Double-click the table tbl_Sales

2.

This brings up the Table Window and you can see that our table contains no data, yet.

3.

4.

five sales are as follows (note: Bob is currently the only "employee"): 1. Sneaker - $40 2. Sneaker - $60 3. Slipper - $5 4. Heel - $12 5. Dress - $150 Enter the information for first sale as follows: o o o o Employee: Bob Product: Sneaker Price: $40 SaleNumber: 1

2. Enter the remaining four sales so that your table looks like:

3. You're done entering the data! Close the table .

Choosing a Table to Query


Before you can create a query you have to navigate to the Query Tab in your Access database. Select Queries from the Objects Pane.

Although you could use the Wizard, we will use the process of creating an Access query with the "Design view". Double-click "create Query in Design view" 1.
Add the table tbl_Sales

2.

Your Query window should now have the tbl_Sales table added to it

You have just completed the setup process for making a query. Every time you make a query you have to first choose which table(s) you want to select data from. Currently, our database only has one table, so we don't have a lot of choices here. Now we can begin to create our custom Access query.

Creating a Custom Query

If we want a query that will just return the list of items sold and for how much. To make this query we are going to have specify the fields we want to see and ignore the others. Access lets you quickly select fields you want to see by a simple drag and drop method. For ever field that a table has there is an entry in the quick table viewer. Notice that the quick view of tbl_Sales displays the fields: *, Employee, Product, Price and SaleNumber. Note: The field * is a wildcard, meaning it will select all the fields if you choose *. We only want Product and Price, so let's start by dragging Product down from tbl_Sales to the first column. Notice that when you drop the Product field into the first column it populates two of the fields and checks the "Show" box:

Drag and drop the Price field into the adjoining column and you should have something like:

Close the Query window and save your file query as qry_ProdSales.

Running Your First Query!


Double-click your newly created query and you should see something like this:

Basic Query Review


When you want to create a query that just uses a select few fields you can simply drag and drop these fields in design view. The next lesson will go into much more detail on creating custom queries, but remember this, you already have the knowledge to write queries in Access! Pretty impressive!

Access Forms
Access provides an easy way to enter data into your Access tables with forms. In Access you have the ability to quickly make and customize these data entry forms to streamline the data input process. Learning how to properly create an Access form will save you a great deal of time! Using our previous example, imagine that Bob, from Bob's Shoe Store, has recently hired someone to enter all the sales data at the end of each business day. The only problem is this person does not know how to use Access, so Bob needs to make them a custom form in Access! This lesson will guide you through the process of creating a data input form in Access

Creating an Access Form


The form wizard is actually very useful .Let's create a simple data input form for the new employee!

1.

Navigate to the Forms section in Access

2.

3.

Double-click "Create form by using wizard" We want all of the fields from tbl_Sales to be included in this form, so first select tbl_Sales from the drop down box "Tables/Queries"

4.

The single right arrow will add one selected field at a time, but we want all the fields. The shortcut to add every field from a given table or query is to click the double arrow button. Do that and click Next.

5. 6. 7.

Choose a Columnar layout and press Next Choose any style and press Next (we chose "Sumi Painting") Change the form's title to frm_EmployeeEntry

and click Finish Open up your form and check it out!

Entering Data Using Access Forms


Now that the form has been created, we just needs to enter in the data. Open up frm_EmployeeEntry (easy!)

1.

At the bottom of the form is a set of arrows to navigate through the records. To get to the end of the existing records and begin entering data you need to click the arrow with an asterisk(*).

2.

Clicking that button will bring you to the first blank record, which would be the sixth in our case. You would then enter all the data for that record and click the right arrow to advance to the next blank record. After all the new records have been entered, close the form and pat yourself on the back.

When you enter data into this form it will automatically add it to our existing tbl_Sales because we specified that table when we created our form.

Access Reports
Having all your data stored in Access is great for maintaining a database, but it isn't the best when you want to share the data or view it away from a computer. The solution to this problem is to create an Access report that will let you design a ready-to-print document of your desired database information.

Creating an Access Report


Lets we wants a report to show the sales for each product, as well as the total sales for his company.Let's explore how you would create this basic sales report in Access.

1.

Navigate to the Reports section in Access

2.

3.

Double-click "Create report by using wizard" Select the query we created in the Access Query lesson qry_ProdSales and add both fields to the report.

4. 5.

Click Next At the grouping step, add the Product field by clicking the right arrow and click Next

6.

At the sorting step, select Price from the drop-down-box then click Summary Options ...

7.

Check the Sum box, so the report will include totals for the Price field and click OK

and click Finish

8. Click Next to advance to the layout options 9. Choose a Stepped layout and a Portrait orientation, then click Next 10. At the Style screen choose Bold and click Next 11. Name the report rpt_Sales and click finish

and click Finish Open up your report and check it out!

We can now print out this handy report and review sales in an easy-to-read fashion. If you would like to make any changes to the report just right-click rpt_Sales and choose the "Design View" option from the popup menu.