Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Spring 2002
Contents
Intermediate Microsoft Access 2000 ........................................................................................... 2
Downloading a Data File .............................................................................................................. 2
Creating Relationships Between Tables...................................................................................... 3
Creating a Relationship............................................................................................................. 3
Setting Referential Integrity...................................................................................................... 4
Using a Subdatasheet ................................................................................................................ 5
Adding Additional Tables to the Relationships ........................................................................ 5
Analyzing Tables........................................................................................................................... 7
Using the Table Analyzer Wizard............................................................................................. 7
Action Queries............................................................................................................................. 11
Creating an Action Query ....................................................................................................... 12
Designing Advanced Queries ..................................................................................................... 12
Creating a Function Query...................................................................................................... 12
Advanced Query Wizard............................................................................................................ 13
Crosstab Query Wizard........................................................................................................... 13
Find Duplicates Wizard ......................................................................................................... 13
Find Unmatched Wizard ......................................................................................................... 14
Creating a Chart ......................................................................................................................... 14
Using the Chart Wizard ......................................................................................................... 14
Importing and Exporting Data .................................................................................................. 16
Importing an External Data ................................................................................................... 16
Importing an Excel File ........................................................................................................ 17
Exporting a Database Object ................................................................................................ 20
Exporting a Data to External Formats .................................................................................. 21
Exporting Objects to Other Access Database ....................................................................... 22
In this part, you will learn how to relate tables, and how to create advanced query features,
forms, and reports. You can create relationships between the tables you have created. In
addition, you can create other objects, such as query, form, and report. Once your information is
stored, it is important to be able to display it from the tables using relationships, queries, forms,
and reports.
4. The Save As dialog box opens. Select 3 Floppy [A:] (or Z:) from the Save in drop
down list.
5. In the File name: and Save as type: text boxes, keep the default file name.
6. Click on the Save button.
Note:
When you relate tables, the tables are related by the join fields. In this exercise, SSN
field in the Students table and SSN field in the Classes table are the join fields. The join
fields in both tables must have the same data types, which means, if SSN field in the
Students table is a text field, then the SSN field in the Classes table must be a text field
as well. However, it is not necessary that the join fields have the same field name.
To remove a relationship, right click on the join line to bring up your shortcut menu and
select Delete.
Setting Referential Integrity
When you create a relationship between two tables, you can set referential integrity. Setting
referential integrity is not mandatory, but it is strongly recommended when creating a
relationship. Referential integrity makes sure that the relationship is valid, which means, it
checks if the joined field in the primary table is the primary key, if the joined fields in both tables
are related, and if they have the same data type and belong to the same database. When the
relationship is verified, Access displays the type of relationship on the joined line (see Figure
3.1). It also prevents accidental deletion or editing of data.
To use referential integrity:
on the Database toolbar.
1. Click on the Relationships button
2. If youve already created relationships between tables, double-click on the join line
between the table field lists (Figure 3). The Edit Relationships dialog box opens (see
Figure 2.2). If there is no relationship between two tables, establish the relationship first.
Join Line
Figure 3 Relationships Dialog Box
Using a Subdatasheet
Once you related two tables in a one-to-many relationship, you can use a subdatasheet that
allows you to see, edit, and enter records that are related to a record in one table.
To use a subdatasheet:
1. Double click on the Students table in the Database window to open it. The Students
table opens in datasheet view (see Figure 4).
Note:
When Students table datasheet opens, notice the plus signs
to the left of the records.
These plus signs indicate that this datasheet has a subdatasheet. Because the Students
table is related to the Classes table, the subdatasheet is taken from Classes table.
Note:
Figure 4.1 shows that David Kim has four class records, which means, he is currently
enrolled. You may notice that John Smith has no class record, which means, he is not
enrolled. The advantage of establishing relationships between tables is that you can enter
new data directly into a subdatasheet. For instance, if the student enrolls in a new class,
open the subdatasheet (Classes table) of the student and enter the information, such as
course ID, course titles, and day. Notice that you do not have to enter student
information, such as student name, student address, and phone number, into the Classes
table.
Adding Additional Tables to the Relationships
Once you have established relationships between two tables, you can add additional tables to the
relationships. For example, each class requires some textbook, sometimes more than one. You
can save all the information about the textbook in the Text table, and relate this table with
Classes table (Figure 5). The relationships between more than two tables work like cascades.
From Students table, you can open Classes table, and again, from Classes table, you can open
the Text table (Figure 5.1).
Note:
Figure 5.1 shows that David Kim has four class records; BUS 101, CIS 410, Eng 102,
and ANTHRO 250. In addition, the class BUS 101 has two Text records, which means
this class requires two textbooks: Introduction to Business and Fundamental Business.
Analyzing Tables
In most cases, you can create many tables and be able to create relationships among these tables
when you design a database. However, sometimes you will find that your tables are not created
in the most efficient way. For example, you might have duplicate information in the same field.
In that case, you need to split the table into two or more related tables.
Using the Table Analyzer Wizard
Before you split a table, you will need to analyze the table to see if it is designed in the most
efficient way. The Table Analyzer Wizard checks the table to determine if the information is
duplicated in the fields across many records. If the table needs to be split, the Table Analyzer
Wizard splits the table and creates new ones, while leaving the original table intact. For
example, in Figure 6, the School table has duplicate information under Class ID, Course Title,
Day, and Time fields. So, we need to split this table into two tables.
Duplicate
Fields
2. Click on the Next Button. The Table Analyzer Wizard: Solving the Problem dialog
box opens (see Figure 6.2).
3. Click on the Next Button. The next Table Analyzer Wizard dialog box opens allowing
you to select the table you want to analyze (see Figure 6.3).
4. Select the table you need to analyze, and click on the Next button. The next dialog box
opens (see Figure 6.4) to determine if you want the wizard to decide what fields go in
what tables.
Figure 6.4 Table Analyzer Wizard: Deciding What Fields Go in What Tables
5. Select the Yes, let the wizard decide option button, if necessary, and click on the Next
button. The next Table Analyzer Wizard dialog box opens (see Figure 6.5).
10. The last dialog box opens (see Figure 6.8). Click on the Finish button. The Table
Analyzer Wizard creates two new tables (Class and Student tables) from the School
table as shown in Figure 6.9.
Action Queries
The term Action Query defines a query that does something more than simply selecting a
specific group of records. An action query modifies or creates table. You can use an action
query when you want to change a large amount of data in an existing table.
Intermediate Microsoft Access 2000 - 11
There are four types of action queries in Access: Make-table query, Update query, Append
query, and Delete query (see table 1 for description).
Table 1 - Action Query Description
Action Query Type
Description
Make-table query
Update query
Append query
Delete query
Function
Description
Group By
Sum
Avg
Min
Max
Count
These two
customers are
duplicate
records, and
one of them
needs to be
deleted.
Be careful!
Although these two
customers have the
same store name,
they may not be
duplicate records
because they have
different contact
name and phone
number.
Creating a Chart
Charts allow you to represent information in a database graphically. You can enhance Forms
and Reports by adding graphics (charts), pictures, and other objects. The easiest way to create a
chart is to use the Chart Wizard. The Chart Wizard assists you in creating charts by leading
you through a series of dialog boxes that allow you to choose options for the chart.
Using the Chart Wizard
You can start the Chart Wizard from either the Forms object or the Reports object.
To create a chart:
1. Click on the Forms or Reports button
from the Objects bar in the Database
window, and then click on the New
button to open a New Form or Report
dialog box (see Figure 13).
2. Select Chart Wizard and select the
table or query on which you want to
base the chart from the drop-down list.
Then click on the OK button. The
Chart Wizard opens (see Figure 13.1)
Figure 13 - New Form Window
3. Select the fields containing the data you want to display in the chart from the Available
Fields list box and move it to the Fields for Chart list box by clicking on the right arrow.
Click on the Next button. The next Chart Wizard dialog box opens (see Figure 13.2) to
select the chart type.
4. Select the desired type of chart and click on the Next button. The next Chart Wizard
dialog box opens (see Figure 13.3).
Field buttons
Data Source box
Figure 13.3 - Chart Wizard: Selecting Data Source and Data Series
5. Select data source and data series and click on the Next button. The next dialog box
opens (see Figure 13.4).
Note:
When you create a chart by using the Chart Wizard, the Chart Wizard automatically
decides which field should be the data source and which field should be the data series.
You can switch the data source and data series by dragging the field button to the Data
Source box or Data Series box (see Figure 13.3).
6. Enter a name for the chart, and then click on the Finish button to create the chart (Figure
13.4). Figure 13.5 shows a chart created by the Chart Wizard.
Note:
After you create a chart, you can edit the chart by opening the Chart Object menu.
Highlight the chart and right click on the mouse. Select Open from the Chart Object
menu. You can change the chart type, such as: pie, bar, or column from the Chart Type
menu, and chart titles, legend, or data labels from the Chart Options menu in the Chart
menu.
5. Choose the file that you want to import and click on the Import button. The Import
Spreadsheet Wizard opens (see Figure 13.3).
6. Choose the Show Worksheets option button if necessary, and click on the Next button.
The next Import Spreadsheet Wizard dialog box opens (see Figure 14.4)
7. Click on the First Row Contains Column Headings check box if necessary, and click on
the Next button. The next Import Spreadsheet Wizard dialog box opens (see figure 14.5).
Note:
Import Wizard automatically assigns the format of a new table according to the format
of external files imported. For example, if you import data from an Excel worksheet file,
Import Wizard changes the columns of an Excel file into the fields of a new table and
the rows of an Excel file into the records of a new table. In addition, Wizard
automatically changes the first row of an Excel file into the field names of a new table.
However, some external files, such as text files, are not compatible with Access files in
terms of formatting. In that case, you will have one more step to fix the format of
external files. Fixing the format of external files is very simple. Just follow the step
offered by Import Wizard.
Intermediate Microsoft Access 2000 - 18
8. Select the In a New Table option button if necessary, and click on the Next button. The
next Import Spreadsheet Wizard dialog box opens (see Figure 14.6).
9. You can edit field options, such as field names, field indexing, or skipping specific fields.
For example, if you want to change a field name, click on that field, and type a new field
name in the Field Name text box under Field Options, and click on the Next button. The
next Import Spreadsheet Wizard dialog box opens (see Figure 14.7).
10. Select the Let Access add primary key option button if necessary, and click on the Next
button. The next Wizard dialog box opens (see Figure 14.8).
11. Name the imported table and click on the Finish button. Figure 14.9 shows a new table
imported from an Excel spreadsheet file.
To export data:
1. In the Database window, select a table that you need to export by clicking on it.
2. On the File menu, click on the Export command. The Export Table dialog box opens
(see Figure 15.1).
3. Choose the file type from the Save as type drop-down list.
4. Click on the Save All button.
Note:
If you click the Save as type drop-down list, you will find the file types to which you can export
the Access objects. Access does not support all kinds of types or versions of external files to
which you can export. What can you do if you cannot find the formats or versions of the external
files to which you need to export? For example, suppose that you need to export a table in
Access to SPSS (Statistical Packages for Social Science) files type (*.sav) that Access does not
support. Here is a tip. Export a table to an Excel file, then, open the Excel file from SPSS
program. Excel files are the most flexible files, which means, you can open Excel files from
almost all types of software programs.
Intermediate Microsoft Access 2000 - 21
6. Enter a new name for the exported table or keep the same one if desired.
7. Select the desired option button under Export Tables.
8. Click on the OK button.
The database in the A:\drive will have the table you exported from the database in the C:\drive.