Sie sind auf Seite 1von 150

N

FO

TR

IN

IN

Microsoft Access 2002


Advanced Level
Training Manual

C C T G L O B A L

.C O M

1995-2003 Cheltenham Courseware for Trainers


Crescent House
24 Lansdown Crescent Lane
Cheltenham
Gloucestershire
GL50 2LD, UK
Tel: +44 (0)1242 227200
Fax: +44 (0)1242 253200
Email: info@cctglobal.com
Internet: http://www.cctglobal.com

IN

All trademarks acknowledged. E&OE.

Cheltenham Courseware for Trainers 1995-2003 No part of this document may be copied without written permission
from Cheltenham Courseware for Trainers unless produced under the terms of a courseware site license agreement with
Cheltenham Courseware for Trainers.

IN

All reasonable precautions have been taken in the preparation of this document, including both technical and nontechnical proofing. Cheltenham Courseware for Trainers and all staff assume no responsibility for any errors or
omissions. No warranties are made, expressed or implied with regard to these notes. Cheltenham Courseware for
Trainers shall not be responsible for any direct, incidental or consequential damages arising from the use of any material
contained in this document. If you find any errors in these training modules, please inform Cheltenham Courseware for
Trainers. Whilst every effort is made to eradicate typing or technical mistakes, we apologize for any errors you may
detect. All courses are updated on a regular basis, so your feedback is both valued by us and will help us to maintain the
highest possible standards.

TR

Sample versions of courseware from Cheltenham Courseware for Trainers


(Normally supplied in Adobe Acrobat format)
If the version of courseware that you are viewing is marked as NOT FOR TRAINING, SAMPLE, or similar, then it cannot
be used as part of a training course, and is made available purely for content and style review. This is to give you the
opportunity to preview our courseware, prior to making a purchasing decision. Sample versions may not be re-sold to a
third party.

FO

For current license information


Cheltenham Courseware for Trainers reserves the right to alter the licensing conditions at any time, without prior notice.
No terms or conditions will affect your rights as defined under UK law. Please see the site license agreement available at:
www.cctglobal.com/agreement

Courseware Release Version 5.0

WORKING WITH THE NORTHWIND SAMPLE DATABASE........................................................... 1

INSTALLING THE NORTHWIND DATABASE .................................................................................................. 1


About Northwind.................................................................................................................................... 1
Checking for Northwind......................................................................................................................... 1
Installing Northwind .............................................................................................................................. 1
REVIEW QUESTIONS.................................................................................................................................... 2
INTRODUCING STRUCTURED QUERY LANGUAGE ....................................................................... 3

FO

TR

IN

IN

WRITING SQL COMMANDS ........................................................................................................................ 4


Structured Query Language (SQL) Bases.............................................................................................. 4
Understanding SQL Statements ............................................................................................................. 4
Understanding SQL Conventions .......................................................................................................... 4
Understanding SQL Syntax.................................................................................................................... 4
WRITING SQL QUERIES .............................................................................................................................. 4
Using SELECT Statement ...................................................................................................................... 4
Selecting All Data .................................................................................................................................. 5
Selecting Specific Data .......................................................................................................................... 6
Selecting Conditional Data.................................................................................................................... 7
Using ORDER BY Statement ................................................................................................................. 7
Sorting Data .......................................................................................................................................... 8
Using Aggregate Functions ................................................................................................................... 8
Calculating Data ................................................................................................................................... 9
Using GROUP BY Statement................................................................................................................. 9
Grouping Data....................................................................................................................................... 9
WRITING SQL SUBQUERIES ...................................................................................................................... 10
Creating a Subquery with Equality...................................................................................................... 10
Creating a Subquery with an Aggregate Function .............................................................................. 10
Using ANY and ALL Statements .......................................................................................................... 11
WRITING SQL JOINS ................................................................................................................................. 12
Understanding SQL Joins.................................................................................................................... 12
Creating a Simple Join ........................................................................................................................ 12
Sorting a Join....................................................................................................................................... 12
Creating Outer Joins ........................................................................................................................... 13
Creating Left Outer Joins .................................................................................................................... 13
Creating Right Outer Joins.................................................................................................................. 14
Creating Full Outer Joins.................................................................................................................... 14
INSERTING DATA ...................................................................................................................................... 14
Using INSERT Statement ..................................................................................................................... 14
Understanding INSERT Statement Rules............................................................................................. 15
Inserting Data using VALUES............................................................................................................. 15
Inserting Data using Defaults.............................................................................................................. 15
Inserting Data using SELECT ............................................................................................................. 15
UPDATING DATA ...................................................................................................................................... 16
Using UPDATE Statement................................................................................................................... 16
Updating All Rows............................................................................................................................... 16
Updating Specific Rows ....................................................................................................................... 16
Updating Multiple Columns................................................................................................................. 16
DELETING DATA ....................................................................................................................................... 17
Using DELETE FROM Statement ....................................................................................................... 17
Deleting Specific Rows ........................................................................................................................ 17
Deleting All Rows ................................................................................................................................ 17
WRITING SQL QUERIES IN ACCESS 2002 ................................................................................................. 17
Viewing SQL in Access 2002 ............................................................................................................... 17
Understanding SQL in Access 2002 .................................................................................................... 19
FOR USE AT THE LICENSED SITE(S) ONLY
Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Writing SQL Specific Queries.............................................................................................................. 20


Finding Help on SQL Queries ............................................................................................................. 21
REVIEW QUESTIONS.................................................................................................................................. 23
WORKING WITH MACROS .................................................................................................................. 25

TR

IN

IN

AUTOMATING TASKS ................................................................................................................................ 25


Understanding Macros ........................................................................................................................ 25
INTRODUCING THE MACRO WINDOW TOOLBAR ....................................................................................... 26
Using the Macro Window Toolbar ...................................................................................................... 26
CREATING MACROS .................................................................................................................................. 28
Creating New Macros.......................................................................................................................... 28
TESTING AND DEBUGGING MACROS ......................................................................................................... 32
Running a Macro ................................................................................................................................. 32
Stepping Through a Macro .................................................................................................................. 33
MODIFYING MACROS ................................................................................................................................ 34
Modifying a Macro .............................................................................................................................. 34
CONDITIONAL PROGRAMMING IN MACROS............................................................................................... 34
Adding Conditions to Macros .............................................................................................................. 34
Using the Expression Builder to create Conditions............................................................................. 36
Running Macros with Conditions ........................................................................................................ 37
ADDING MACROS TO FORMS .................................................................................................................... 38
Attaching Macros to a Form................................................................................................................ 38
ADDING MACROS TO REPORTS ................................................................................................................. 40
Attaching Macros to a Report.............................................................................................................. 40
FILTERING DATA ...................................................................................................................................... 42
Filtering Records ................................................................................................................................. 42
DOCUMENTING MACROS .......................................................................................................................... 46
Commenting Macros............................................................................................................................ 46
Printing Macro Definitions.................................................................................................................. 47
Viewing Macro Definitions.................................................................................................................. 47
REVIEW QUESTIONS.................................................................................................................................. 48
PROGRAMMING ACCESS USING VISUAL BASIC .......................................................................... 49

FO

USING MACROS VERSUS VISUAL BASIC .................................................................................................... 49


Using Visual Basic Modules ................................................................................................................ 49
Converting Macros to Visual Basic Code............................................................................................ 49
UNDERSTANDING VISUAL BASIC CONCEPTS ............................................................................................ 54
Understanding Modules....................................................................................................................... 54
Creating Modules ................................................................................................................................ 54
Understanding Module Declarations .................................................................................................. 56
Understanding Procedures .................................................................................................................. 56
Using Naming Rules ............................................................................................................................ 56
Declaring Variables............................................................................................................................. 57
Setting Variable Scope......................................................................................................................... 57
Declaring Constants ............................................................................................................................ 57
Using Methods ..................................................................................................................................... 58
Using Arguments ................................................................................................................................. 58
USING THE VISUAL BASIC EDITOR WINDOW ............................................................................................ 59
Customizing the Visual Basic Editor Window ..................................................................................... 59
Setting the Visual Basic Editor Options............................................................................................... 61
GETTING HELP WITH VISUAL BASIC ......................................................................................................... 63
Using Microsoft Visual Basic Help...................................................................................................... 63
Getting Visual Basic Syntax Help ........................................................................................................ 65
REVIEW QUESTIONS.................................................................................................................................. 66

USING DATA ACCESS PAGES .............................................................................................................. 67


FOR USE AT THE LICENSED SITE(S) ONLY
Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

TR

IN

IN

CREATING DATA ACCESS PAGES .............................................................................................................. 67


Using Data Access Pages .................................................................................................................... 67
Creating pages using the AutoPage..................................................................................................... 67
Creating pages using the Page Wizard................................................................................................ 71
Creating pages using an Existing HTML Document ........................................................................... 78
Creating pages using the Design View ................................................................................................ 80
MODIFYING DATA ACCESS PAGES ............................................................................................................ 81
Choosing a Theme ............................................................................................................................... 81
Adding Text.......................................................................................................................................... 84
Adding Controls................................................................................................................................... 84
Formatting Text and Labels................................................................................................................. 86
Aligning Content.................................................................................................................................. 86
Sizing Content...................................................................................................................................... 87
Adding Images ..................................................................................................................................... 87
Adding Backgrounds............................................................................................................................ 88
SORTING DATA IN DATA ACCESS PAGES .................................................................................................. 89
Sorting Data ........................................................................................................................................ 89
SUMMARIZING DATA IN DATA ACCESS PAGES ......................................................................................... 90
Summarizing Data ............................................................................................................................... 90
EDITING DATA IN DATA ACCESS PAGES ................................................................................................... 91
Adding a New Record .......................................................................................................................... 91
Deleting a Record ................................................................................................................................ 91
PROTECTING DATA IN DATA ACCESS PAGES ............................................................................................ 92
Customizing Navigation Bar................................................................................................................ 92
Protecting Fields ................................................................................................................................. 93
REVIEW QUESTIONS.................................................................................................................................. 93
CONVERTING ACCESS DATABASES ................................................................................................. 95

FO

CONVERTING DATABASES TO ACCESS 2002 ............................................................................................. 95


Converting Databases ......................................................................................................................... 95
Converting Database Objects.............................................................................................................. 96
Enabling Databases............................................................................................................................. 97
Sharing Databases across various Access versions............................................................................. 98
CONVERTING FROM ACCESS 2002 TO ACCESS 97 ................................................................................... 100
Converting an Access 2002 database to an Access 97 database ....................................................... 100
CONVERTING FROM ACCESS 2002 TO ACCESS 2000 ............................................................................... 101
Converting an Access 2002 database to an Access 2000 database ................................................... 101
REVIEW QUESTIONS................................................................................................................................ 102
CUSTOMIZING ACCESS 2002 ............................................................................................................. 103

CONFIGURING ACCESS 2002 OPTIONS .................................................................................................... 104


Setting Access 2002 Options.............................................................................................................. 104
Setting View Options.......................................................................................................................... 106
Setting General Options..................................................................................................................... 107
Setting Edit/Find Options .................................................................................................................. 108
Setting Keyboard Options.................................................................................................................. 109
Setting Datasheet Options ................................................................................................................. 110
Setting Forms/Reports Options.......................................................................................................... 111
Setting Pages Options........................................................................................................................ 112
Setting Advanced Options.................................................................................................................. 113
Setting International Options............................................................................................................. 114
Setting Spelling Options..................................................................................................................... 115
Setting Tables/Queries Options ......................................................................................................... 116
CONFIGURING AUTOCORRECT OPTIONS ................................................................................................. 117
Setting AutoCorrect Options.............................................................................................................. 117
Excluding AutoCorrect Rules ............................................................................................................ 118
FOR USE AT THE LICENSED SITE(S) ONLY
Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

IN

Removing AutoCorrect Rules............................................................................................................. 118


Adding Replace AutoCorrect Rules ................................................................................................... 119
Removing Replace AutoCorrect Rules............................................................................................... 119
CUSTOMIZING MENUS AND TOOLBARS ................................................................................................... 120
Opening Customize Dialog Box......................................................................................................... 120
Customizing Toolbars ........................................................................................................................ 120
Creating Custom Toolbars................................................................................................................. 121
Removing Toolbars............................................................................................................................ 124
Customizing Commands .................................................................................................................... 124
Adding Buttons to Toolbars ............................................................................................................... 125
Removing Buttons from Toolbars ...................................................................................................... 126
Customizing Options.......................................................................................................................... 127
REVIEW QUESTIONS................................................................................................................................ 128
ANALYZING ACCESS DATABASES .................................................................................................. 129

FO

TR

IN

OPTIMIZING DATABASES WITH TABLE ANALYZER ................................................................................. 129


Using the Table Analyzer................................................................................................................... 129
Renaming Tables ............................................................................................................................... 134
Adding Key Fields.............................................................................................................................. 135
OPTIMIZING DATABASES WITH PERFORMANCE ANALYZER .................................................................... 138
Using the Performance Analyzer ....................................................................................................... 138
DOCUMENTING DATABASES WITH DOCUMENTER ANALYZER ................................................................ 140
Using the Documenter Analyzer ........................................................................................................ 140
Printing Documentation .................................................................................................................... 142
Exporting Documentation.................................................................................................................. 143
REVIEW QUESTIONS................................................................................................................................ 144

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Working with the Northwind Sample Database


Access 2002 Advanced

1
2003 Cheltenham Courseware for Trainers

IN

When you have completed this learning module you will have seen how to:
Check for Northwind
Install Northwind

Working with the Northwind Sample


Database

Installing the Northwind Database

IN

About Northwind
Northwind is a sample database that is supplied with Access 2002. It contains product and
sales data for the fictitious company Northwind Traders.
It is recommended that Northwind be installed in order to follow the lessons in this
manual.

In the Search text box, type Northwind.


Click Search.
If Northwind.mdb appears in the Search Results, click on the file to open it and proceed to
the next chapter.
If Northwind is not found in the Search Results it will need to be installed.

TR

Checking for Northwind


Click the Search button on the database toolbar:

FO

Installing Northwind
Insert the Microsoft Office XP CD-ROM in the CD-ROM drive.
Double-click Setup.
Note: If your computer has autorun enabled, you will be presented directly with the Microsoft
Office XP setup screen.
Select Add or Remove Features.
Click Next.
Under Features to Install, select the Microsoft Access for Windows subtree.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

2
2003 Cheltenham Courseware for Trainers

Working with the Northwind Sample Database


Access 2002 Advanced

Under Sample Databases, select Run all from My Computer:

Click Update.
Once the installer completes, click OK to finish.

TR

IN

IN

FO

Review Questions

Note: Once the Northwind database is installed, search for it again and open it.

How would you:


Check for Northwind?
Install Northwind?

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Introducing Structured Query Language


Access 2002 Advanced

3
2003 Cheltenham Courseware for Trainers

FO

TR

IN

IN

When you have completed this learning module you will have seen how to:
Understand SQL Statements
Understand SQL Conventions
Understand SQL Syntax
Use SELECT Statement
Select All Data
Select Specific Data
Select Conditional Data
Use ORDER BY Statement
Sort Data
Use Aggregate Functions
Calculate Data
Use GROUP BY Statement
Group Data
Create a Subquery with Equality
Create a Subquery with an Aggregate Function
Use ANY and ALL Statements
Understand SQL Joins
Create a Simple Join
Sort a Join
Create Outer Join
Create Left Outer Join
Create Right Outer Join
Create Full Outer Join
Use INSERT Statement
Understand INSERT Statement Rules
Insert Data using VALUES
Insert Data using Defaults
Insert Data using SELECT
Use UPDATE Statement
Update All Rows
Update Specific Rows
Update Multiple Columns
Use DELETE FROM Statement
Delete Specific Rows
Delete All Rows
View SQL in Access 2002
Understand SQL in Access 2002
Write SQL Specific Queries
Find Help on SQL Queries

Introducing Structured Query Language

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

4
2003 Cheltenham Courseware for Trainers

Introducing Structured Query Language


Access 2002 Advanced

Writing SQL Commands

Structured Query Language (SQL) Bases


Structured Query Language is called SQL for short.
SQL consists of standard English words.
Like all programming languages, SQL has specific conventions and grammatical syntax.
SQL can be used by a range of users including Database Administrators, management
personnel, application programmers and other types of end users.

IN

IN

Understanding SQL Statements


SQL statement consists of reserved words and user-defined words:
Reserved words are a fixed part of SQL and must be spelt exactly as required and cannot
be split across lines.
User-defined words are created by the user and represent names of various database
objects such as relations, columns, views, etc.

TR

Understanding SQL Conventions


SQL is more readable if indentation and lineation are used:
Each clause in a statement should begin on a new line.
Start of a clause should line up with start of other clauses.
If clause has several parts, they should each appear on a separate line and be indented
under the start of clause.
Upper case letters represent SQL reserved words.
Lower case letters represent user-defined words.
A vertical bar ( | ) indicates a choice among alternatives.
Curly braces ( { } ) indicate a required element.
Square brackets ( [ ] ) indicate an optional element.
An ellipsis ( ) indicates optional repetition (0 or more times).

FO

Understanding SQL Syntax


The main elements in SQL are the statements and clauses that makeup statements.
SELECT command indicates which fields are included in the query result.
FROM clause indicated what table(s) the fields are retrieved from.
The following is the syntax of the SELECT statement:
{ * | [column_name] [, ] }
table_name

SELECT
FROM

Writing SQL Queries

Using SELECT Statement


Data is selected using the SELECT statement.
Order of the clauses cannot be changed.
SELECT
FROM
[WHERE
[GROUP BY
[HAVING
[ORDER BY

[predicate] { * | [column_name] [, ] }
table_name
condition]
column_name]
group_condition]
column_name] ;

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Introducing Structured Query Language


Access 2002 Advanced

5
2003 Cheltenham Courseware for Trainers

SELECT command specifies which columns are to appear in the output.


FROM clause specifies table or tables to be used.
WHERE clause filters rows subject to some conditions.
GROUP BY clause forms groups of rows with same column value.
HAVING clause specifies conditions the grouped records must meet to be displayed.
ORDER BY clause specifies the order of the output.
Semicolon ; ends the SQL statement.

Predicate is optional, and it restricts the number of results returned.


There are four predicates:
ALL
includes all records.
DISTINCT
omits duplicate data in selected fields.
DISTINCTROW
omits data based on entire duplicate records.
TOPn [PERCENT] limits the records to a number or percentage of records.

Only SELECT and FROM are mandatory.


Use * as an abbreviation for all columns.

SELECT
FROM

Example 2: Retrieve All data


(list full details of all staff)
SELECT
FROM

sno, fname, lname, position, salary


staff;

*
staff;

TR

Selecting All Data


Example 1: Retrieve All Columns, All Rows
(list full details of all staff)

IN

IN

position
Manager
Snr Asst
Deputy
Assistant
Manager
Assistant

bno
B5
B3
B3
B7
B3
B5

FO

The result table in either case is:


sno
fname
lname
SL21
John
White
SG37
Ann
Beech
SG14
David
Ford
SA9
Mary
Howe
SG5
Susan
Brand
SL41
Julie
Lee

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

salary
30000.00
12000.00
18000.00
9000.00
24000.00
9000.00

6
2003 Cheltenham Courseware for Trainers

Introducing Structured Query Language


Access 2002 Advanced

Selecting Specific Data


Example 3: Retrieve Specific Columns, All Rows
(produce a list of salaries for all staff, showing only the staff number, sno, the first and last
names, and the salary details).

salary
30000.00
12000.00
18000.00
9000.00
24000.00
9000.00

SELECT
FROM

sno, fname, lname, salary/12


staff;

lname
White
Beech
Ford
Howe
Brand
Lee

Example 5: Named Calculated Fields


th
In the example above, the 4 column is labeled col4. To name this column use AS clause:
SELECT
FROM

sno, fname, lname, salary/12 AS monthly_salary


staff;

The result table is:


sno
fname
SL21
John
SG37
Ann
SG14
David
SA9
Mary
SG5
Susan
SL41
Julie

O
N

col4
2500.00
1000.00
1500.00
750.00
2000.00
750.00

FO

The result table is:


sno
fname
SL21
John
SG37
Ann
SG14
David
SA9
Mary
SG5
Susan
SL41
Julie

Example 4: Calculated Fields


(produce a list of monthly salaries for all staff, showing the staff number, the first and last
names, and the salary details).

TR

lname
White
Beech
Ford
Howe
Brand
Lee

IN

The result table is:


sno
fname
SL21
John
SG37
Ann
SG14
David
SA9
Mary
SG5
Susan
SL41
Julie

sno, fname, lname, salary


staff;

IN

SELECT
FROM

lname
White
Beech
Ford
Howe
Brand
Lee

monthly_salary
2500.00
1000.00
1500.00
750.00
2000.00
750.00

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Introducing Structured Query Language


Access 2002 Advanced

7
2003 Cheltenham Courseware for Trainers

Selecting Conditional Data


Example 6: Comparison Search Condition
(list all staff with a salary greater than 10000.00)

The result table is:


sno
fname
SL21
John
SG37
Ann
SG14
David
SG5
Susan

IN

sno, fname, lname, position


staff
position = Manager OR position = Assistant;

The result table is:


sno
fname
SL21
John
SA9
Mary
SG5
Susan
SL41
Julie

lname
White
Howe
Brand
Lee

position
Manager
Assistant
Manager
Assistant

Example 8: Pattern Match Search Condition (LIKE / NOT LIKE)


(list all staff with any assistant position, looking for string Ass in their position)
sno, fname, lname, position, salary
staff
position LIKE %Ass%;

FO

SELECT
FROM
WHERE

The result table is:


sno
fname
SG37
Ann
SA9
Mary
SL41
Julie

lname
Beech
Howe
Lee

position
Snr Asst
Assistant
Assistant

Note: SQL has two special pattern matching symbols:


% percent represents any sequence of zero or more characters.
_ underscore character represents any single character.

salary
30000.00
12000.00
18000.00
24000.00

Example 7: Compound Comparison Search Condition (AND / OR)


(list all staff with the position of Manager or Assistant)
SELECT
FROM
WHERE

position
Manager
Snr Asst
Deputy
Manager

TR

lname
White
Beech
Ford
Brand

sno, fname, lname, position, salary


staff
salary > 10000;

IN

SELECT
FROM
WHERE

Using ORDER BY Statement


Data is sorted using the ORDER BY statement.
Data is sorted in Ascending order by default.
To sort data in Descending order, use DESC clause.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

salary
12000.00
9000.00
9000.00

8
2003 Cheltenham Courseware for Trainers

Introducing Structured Query Language


Access 2002 Advanced

Sorting Data
Example 9: Single Column Ordering
(list salaries for all staff, arranged in descending order of salary).

salary
30000.00
24000.00
18000.00
12000.00
9000.00
9000.00

SELECT
FROM
ORDER BY

sno, fname, lname, position


staff
lname, position;
lname
Beech
Brand
Ford
Howe
Lee
White

position
Snr Asst
Manager
Deputy
Assistant
Assistant
Manager

FO

The result table is:


sno
fname
SG37
Ann
SG5
Susan
SG14
David
SA9
Mary
SL41
Julie
SL21
John

Example 10: Multiple Column Ordering


(list of all staff, arranged in ascending order of last name and position).

TR

lname
White
Brand
Ford
Beech
Howe
Lee

IN

The result table is:


sno
fname
SL21
John
SG5
Susan
SG14
David
SG37
Ann
SA9
Mary
SL41
Julie

Using Aggregate Functions


There are five aggregate functions:
COUNT returns the number of values in a specified column.
SUM returns the sum of the values in a specified column.
AVG returns the average of the values in a specified column.
MIN returns the smallest value in a specified column.
MAX returns the largest value in a specified column.
Each function operates on a single column of a table and return single value.
COUNT, MIN and MAX apply to numeric and non-numeric fields.
SUM and AVG apply to numeric fields only.
COUNT(*) is a special use of COUNT that counts all rows of a table.

sno, fname, lname, salary


staff
salary DESC;

IN

SELECT
FROM
ORDER BY

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Introducing Structured Query Language


Access 2002 Advanced

9
2003 Cheltenham Courseware for Trainers

Calculating Data
Example 11: Use of COUNT(*)
(find the total number of staff that have salary of 9000).

COUNT(*) AS count
staff
salary = 9000;

The result table is:


count
2
Example 12: Use of COUNT and SUM
(find the total number of Managers and the sum of their salaries).
SELECT
FROM
WHERE

IN

COUNT(sno) AS count, SUM(salary) AS sum


staff
position = Manager;

TR

The result table is:


count
sum
2
54000.00

IN

SELECT
FROM
WHERE

Example 13: Use of MIN, MAX, AVG


(find the minimum, maximum and average staff salary).
SELECT
FROM

MIN(salary) AS min, MAX(salary) AS max, AVG(salary) AS avg


staff;

The result table is:


min
max
9000.00
30000.00

FO

avg
17000.00

Using GROUP BY Statement


Data is grouped using the GROUP BY statement.
Each item in SELECT list must be single-valued per group.
All column names in SELECT list must appear in GROUP BY clause, unless the name is
used only in an aggregate function.

Grouping Data
Example 14: Use of GROUP BY
(find number of staff in each branch and their total salaries).
SELECT
FROM
GROUP BY
ORDER BY

bno, COUNT(sno), AS count, SUM(salary) AS sum


staff
bno
bno;

The result table is:


bno
count
B3
3
B5
2
B7
1

sum
54000.00
39000.00
9000.00

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

10
2003 Cheltenham Courseware for Trainers

Introducing Structured Query Language


Access 2002 Advanced

Writing SQL Subqueries

Some SQL statements can have a SELECT embedded within them.


A subselect can be used in the WHERE clause of an outer SELECT, where it is called a
Subquery or Nested query.

SELECT
FROM
WHERE

sno, fname, lname, position


staff
bno = B3;

lname
Beech
Ford
White

The result table is:


sno
fname
SG37
Ann
SG14
David
SL21
John

IN
A

Note: Inner SELECT finds branch number corresponding to branch at 163 Main St which is
(B3). Outer SELECT then retrieves details of all staff who work at this branch. The outer
SELECT then becomes:

TR

sno, fname, lname, position


staff
bno =
(SELECT bno
FROM branch
WHERE street = 163 Main St);

IN

SELECT
FROM
WHERE

Creating a Subquery with Equality


Example 15: Use of Subquery with Equality
(list the staff who work in the branch at 163 Main St).

position
Snr Asst
Deputy
Manager

FO

Creating a Subquery with an Aggregate Function


Example 16: Use of Subquery with Aggregate Function
(list all staff whose salary is greater than the average salary).
sno, fname, lname, position, salary
staff
salary >
(SELECT AVG(salary)
FROM staff);

SELECT
FROM
WHERE

Note: You cannot write WHERE salary > AVG(salary). Instead, you can use Subquery to
find the average salary (17000), and then use outer SELECT to find those staff members with
a salary greater than this:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Introducing Structured Query Language


Access 2002 Advanced

sno, fname, lname, position, salary


staff
salary > 17000;

The result table is:


sno
fname
SL21
John
SG14
David
SG5
Susan

lname
White
Ford
Brand

position
Manager
Deputy
Manager

salary
30000.00
18000.00
24000.00

SELECT
FROM
WHERE

11
2003 Cheltenham Courseware for Trainers

SELECT
FROM
WHERE

Note: Inner SELECT produces the set {12000, 18000, 24000} and outer SELECT lists those
staff whose salaries are greater than any of the values in this set.

sno, fname, lname, position, salary


staff
salary > ANY
(SELECT salary
FROM staff
WHERE bno = B3);

FO

The result table is:


sno
fname
SL21
John
SG14
David
SG5
Susan

lname
White
Ford
Brand

position
Manager
Deputy
Manager

salary
30000.00
18000.00
24000.00

Example 18: Use of ALL


(find staff whose salary is larger than the salary of every member of the staff at branch B3).

Example 17: Use of ANY


(find staff whose salary is larger than the salary of at least 1 member of the staff at branch
B3).

TR

IN

IN

Using ANY and ALL Statements


ANY and ALL may be used with subqueries that produce a single column of numbers.
If Subquery is preceded by ALL, the condition will only be true if it is satisfied by all values
produced by the Subquery.
If Subquery is preceded by ANY, the condition will be true if it is satisfied by any values
produced by the Subquery.

SELECT
FROM
WHERE

sno, fname, lname, position, salary


staff
salary > ALL
(SELECT salary
FROM staff
WHERE bno = B3);

The result table is:


sno
fname
SL21
John

lname
White

position
Manager

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

salary
30000.00

12
2003 Cheltenham Courseware for Trainers

Introducing Structured Query Language


Access 2002 Advanced

Writing SQL Joins

IN

Understanding SQL Joins


In the previous examples, subqueries have provided results from the same table.
If result columns come from more than one table, we must use a join.
To perform a join, you must include more than one table in the FROM clause, using a comma
as a separator and typically including a WHERE clause to specify join column(s).
It is also possible to use an alias for a table, named in the FROM clause. An alias is
separated from the table name with a space.

SELECT
FROM
WHERE

r.mo, fname, lname, pno


renter r, viewing v
r.mo = v.mo;

Note: To obtain correct rows, include only those rows from both tables that have identical
values in the rno columns: r.mo = v.mo. These two columns are the matching columns for
two tables.
lname
Stewart
Stewart
Stewart
Tregear
Kay

The result table is:


mo
fname
CR56
Aline
CR56
Aline
CR56
Aline
CR62
Mary
CR76
John

TR

IN

Creating a Simple Join


Example 19: Use of Simple Join
(list names of all renters who have viewed a property).

pno
PG36
PA14
PG4
PA14
PG4

FO

Sorting a Join
Example 20: Sort a Join
(for each branch, list names of staff who manage properties).

SELECT
FROM
WHERE
ORDER BY

The result table is:


bno
sno
B3
SG14
B3
SG14
B3
SG37
B3
SG37
B5
SL41
B7
SA9

O
N

s.bno, s.sno, fname, lname, pno


staff s, property_for_rent p
s.sno = p.sno
s.bno, s.sno, pno;
fname
David
David
Ann
Ann
Julie
Mary

lname
Ford
Ford
Beech
Beech
Lee
Howe

pno
PG4
PG16
PG21
PG36
PL94
PA14

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Introducing Structured Query Language


Access 2002 Advanced

13
2003 Cheltenham Courseware for Trainers

Creating Outer Joins


With an inner join, if one row of a table is unmatched, the row is omitted from the result table.
Outer join retains rows that do not satisfy the join condition.
Consider the following two simplified tables:

bcity
Glasgow
Bristol
London

IN

BRANCH1
bno
B3
B4
B2

SELECT
FROM
WHERE

b.*, p.*
branch1 b, property_for_rent1 p
b.bcity = p.pcity;

OR
SELECT
FROM
ON

b.*, p.*
branch1 b INNER JOIN property_for_rent1 p
b.bcity = p.pcity;

The result table is:


bno
bcity
B3
Glasgow
B2
London

pno
PG4
PL94

FO

Example 21: The INNER JOIN of these two tables

TR

IN

PROPERTY_FOR_RENT1
pno
pcity
PA14
Aberdeen
PL94
London
PG4
Glasgow

pcity
Glasgow
London

Note: The result table has two rows where the cities are the same. There are no rows
corresponding to the branches in Bristol and Aberdeen.

Creating Left Outer Joins


Example 22: Left Outer Join
(list branches and properties that are in the same city along with any unmatched branches).

SELECT
FROM
ON

b.*, p.*
branch1 b LEFT JOIN property_for_rent1 p
b.bcity = p.pcity;

The result table is:


bno
bcity
B3
Glasgow
B4
Bristol
B2
London

pno
PG4
NULL
PL94

pcity
Glasgow
NULL
London

Note: Left outer join includes those rows of first (left) table that are unmatched with rows
from second (right) table. Columns from second table are filled with NULLs.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

14
2003 Cheltenham Courseware for Trainers

Introducing Structured Query Language


Access 2002 Advanced

Creating Right Outer Joins


Example 23: Right Outer Join
(list branches and properties in the same city and any unmatched properties).

The result table is:


bno
bcity
NULL
NULL
B3
Glasgow
B2
London

pcity
Aberdeen
Glasgow
London

Note: Right outer join includes those rows of second (right) table that are unmatched with
rows from first (left) table. Columns from first table are filled with NULLs.

IN

pno
PA14
PG4
PL94

b.*, p.*
branch1 b RIGHT JOIN property_for_rent1 p
b.bcity = p.pcity;

IN

SELECT
FROM
ON

b.*, p.*
branch1 b FULL JOIN property_for_rent1 p
b.bcity = p.pcity;

pcity
Aberdeen
Glasgow
NULL
London

Note: Full outer join includes those rows that are unmatched in both tables. Unmatched
columns are filled with NULLs.

FO

pno
PA14
PG4
NULL
PL94

The result table is:


bno
bcity
NULL
NULL
B3
Glasgow
B4
Bristol
B2
London

TR

SELECT
FROM
ON

Creating Full Outer Joins


Example 24: Full Outer Join
(list branches and properties in the same city and any unmatched branches and properties).

Inserting Data

Using INSERT Statement


Data is inserted in the table using the INSERT statement.

INSERT INTO
VALUES

table_name [ (column_list) ]
(data_value_list);

Column_list is optional.
If omitted, SQL assumes a list of all columns in their original order.
Any columns omitted must be declared as NULL when the table is created, unless DEFAULT
is specified when creating the column.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Introducing Structured Query Language


Access 2002 Advanced

15
2003 Cheltenham Courseware for Trainers

Understanding INSERT Statement Rules


Data_value_list must match column_list as follows:
Number of items in each list must be the same.
Order of items must correspond directly to the position of items in two lists.
Data type of each item in data_value_list must be compatible with data type of the
corresponding column.

staff
(SG16, Alan, Brown, Assistant, B3, 8300);

IN

INSERT INTO
VALUES

Inserting Data using VALUES


Example 25: INSERT VALUES
(insert a new record into staff table supplying data for all columns).

staff (sno, fname, lname, position, bno


(SG16, Alan, Brown, Assistant, B3);

INSERT INTO
VALUES

IN

Inserting Data using Defaults


Example 26: INSERT using Defaults
(insert a new record into staff table supplying data for all mandatory columns).

INSERT INTO
VALUES

TR

OR

staff
(SG16, Alan, Brown, Assistant, B3, NULL);

table_name [ (column_list) ]
;

FO

INSERT INTO
SELECT

Inserting Data using SELECT


Second form of INSERT allows multiple rows to be copied from one or more tables to
another.

Example 27: INSERT SELECT


Assume there is a table staff_prop_count that contains names of staff and the number of
properties they manage:
staff_prop_count(sno, fname, lname, prop_cnt).
(populate staff_prop_count using staff and property_for_rent).

INSERT INTO
staff_prop_count
(SELECT s.sno, fname, lname, COUNT(*)
FROM staff s, property_for_rent p
WHERE s.sno = p.sno
GROUP BY s.sno, fname, lname);

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

16
2003 Cheltenham Courseware for Trainers

Introducing Structured Query Language


Access 2002 Advanced

Updating Data
Using UPDATE Statement
Data is updated in the table using the UPDATE statement.

SET clause specifies names of one or more columns that are to be updated.
WHERE clause is optional. If omitted, named columns are updated for all rows in table. If
specified, only those rows that satisfy search_condition are updated.
New data_value(s) must be compatible with the data type for the corresponding column.

IN

IN

[WHERE

table_name
column_name1 = data_value1
[, column_name2 = data_value2 ]
search_condition];

UPDATE
SET

staff
salary = salary*1.03;

TR

UPDATE
SET

Updating All Rows


Example 28: UPDATE All Rows
(give all staff a 3% pay increase).

Updating Specific Rows


Example 29: UPDATE Specific Rows
(give all Managers a 5% pay increase).

Note: WHERE clause finds rows that contain data for Managers. Update is applied only to
these particular rows.

FO

staff
salary = salary*1.05
position = Manager;

UPDATE
SET
WHERE

Updating Multiple Columns


Example 30: UPDATE Multiple Columns
(promote David Ford (sno = SG14) to Manager and change his salary to 18000).
staff
position = Manager, salary = 18000
sno = SG14;

UPDATE
SET
WHERE

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Introducing Structured Query Language


Access 2002 Advanced

17
2003 Cheltenham Courseware for Trainers

Deleting Data
Using DELETE FROM Statement
Data is removed from the table using the DELETE FROM statement.

DELETE FROM
WHERE

staff
position = Manager;

DELETE FROM

staff;

TR

Deleting All Rows


Example 32: DELETE All Rows
(delete all records from the staff table).

IN

Deleting Specific Rows


Example 31: DELETE Specific Rows
(delete all staff that hold a Manager position).

IN

Search_condition is optional. If omitted, all rows are deleted from the table.
This does not delete the table.
If search_condition is specified, only those rows that satisfy the condition are deleted.

table_name
search_condition];

DELETE FROM
[WHERE

Writing SQL Queries in Access 2002

FO

Viewing SQL in Access 2002


SQL is the language that Access 2002 uses to program query operations.
To view and/or edit SQL statements while creating a Query, switch from Design View to
SQL View:

To open the SQL View:


Open a Query in Design View.
From the main menu, choose View > SQL View:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

18
2003 Cheltenham Courseware for Trainers

Introducing Structured Query Language


Access 2002 Advanced

Click on the Design button:

FO

TR

IN

IN

To view sample SQL statement:


For example, open the sample Northwind.mdb database.
Click on the Queries button under the Objects pane of the Database window.
Select a query named Employee Sales by Country:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Introducing Structured Query Language


Access 2002 Advanced

19
2003 Cheltenham Courseware for Trainers

This will open the Design View for the selected query:

While in Design View, from the main menu, choose View > SQL View.
This will open the SQL View:

You can edit the SQL statement directly in this window.

FO

TR

IN

IN

Understanding SQL in Access 2002


SQL statements are little different in Access that in the standard SQL.
Lets look at the example:

SELECT
FROM
WHERE

[First Name], [Last Name], Position


[Staff Data]
Position = Assistant;

The column names that contain spaces must be enclosed in square brackets [ ].
If the column name does not contain spaces, square brackets are not needed.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

20
2003 Cheltenham Courseware for Trainers

Introducing Structured Query Language


Access 2002 Advanced

Writing SQL Specific Queries


SQL Specific queries are queries that can be created only using SQL statements.

TR

In the New Query dialog box, select Design View and click OK:

FO

IN

IN

To write SQL Specific query:


Click on the New button while in the Queries page of the Database window:

There are three SQL Specific queries:


Union queries that combine corresponding fields from two or more tables into one field in the
query results.
Pass-Through queries that send commands directly to ODBC databases.
Data Definition queries that create or edit Access tables.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Introducing Structured Query Language


Access 2002 Advanced

21
2003 Cheltenham Courseware for Trainers

In the Show Table dialog box, click Close without adding any table:

From the main menu, choose Query > SQL Specific > then select the type of query you
want to create, Union, Pass-Through or Data Definition:

FO

TR

IN

IN

Finding Help on SQL Queries


As always, if you need more help, Access 2002 has more information on SQL queries.
From the main menu, choose Help > Microsoft Access Help:

OR press the F1 key


OR click on the Help [?] toolbar button.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

22
2003 Cheltenham Courseware for Trainers

In the Contents page, navigate to Queries > SQL Queries to list all subjects on this issue:

FO

TR

IN

IN

Introducing Structured Query Language


Access 2002 Advanced

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Introducing Structured Query Language


Access 2002 Advanced

23
2003 Cheltenham Courseware for Trainers

IN
IN
A

FO

TR

How would you:


Understand SQL Statements?
Understand SQL Conventions?
Understand SQL Syntax?
Use SELECT Statement?
Select All Data?
Select Specific Data?
Select Conditional Data?
Use ORDER BY Statement?
Sort Data?
Use Aggregate Functions?
Calculate Data?
Use GROUP BY Statement?
Group Data?
Create a Subquery with Equality?
Create a Subquery with an Aggregate Function?
Use ANY and ALL Statements?
Understand SQL Joins?
Create a Simple Join?
Sort a Join?
Create an Outer Join?
Create a Left Outer Join?
Create a Right Outer Join?
Create a Full Outer Join?
Use INSERT Statement?
Understand INSERT Statement Rules?
Insert Data using VALUES?
Insert Data using Defaults?
Insert Data using SELECT?
Use UPDATE Statement?
Update All Rows?
Update Specific Rows?
Update Multiple Columns?
Use DELETE FROM Statement?
Delete Specific Rows?
Delete All Rows?
View SQL in Access 2002?
Understand SQL in Access 2002?
Write SQL Specific Queries?
Find Help on SQL Queries?

Review Questions

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

N
T
R

FO
IN

TR

IN

Working with Macros


Access 2002 Advanced

25
2003 Cheltenham Courseware for Trainers

Automating Tasks

TR

IN

IN

When you have completed this learning module you will have seen how to:
Understand Macros
Use the Macro Window Toolbar
Create New Macros
Run a Macro
Step Through a Macro
Modify a Macro
Add Conditions to Macros
Use the Expression Builder to Create Conditions
Run Macros with Conditions
Attach Macros to a Form
Attach Macros to a Report
Filter Records
Comment Macros
Print Macro Definitions
View Macro Definitions

Working with Macros

FO

Understanding Macros
Macros present a way of programming Access 2002 to perform a variety of tasks and actions.
Macros are easy to create - you simply select from the list of predefined actions and their
arguments.
Each action performs a specific operation.
Each action can have arguments, which specify additional information for that action.
Macros are best for performing simple tasks, like opening and closing forms, running reports,
and displaying custom toolbars.
Macros are individual Access objects listed in the Macros page in the Database window:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

26
2003 Cheltenham Courseware for Trainers

Working with Macros


Access 2002 Advanced

Once macros are created, you can attach them to an Event property of any object in your
database.
Note: Access macros differ from other macros in Office XP and other applications, because
it does not record the keystrokes.

IN

There are two cases when you must use macros:


When assigning specific actions to a key combination to be used globally, in the entire
database.
When assigning startup actions to the database, such as opening a switchboard form at
startup.

TR

IN

Introducing the Macro Window Toolbar

FO

Using the Macro Window Toolbar


Macro Names button adds the Macro Name column to the macro sheet:

OR from the main menu, choose View > Macro Names:

Macro Name column is added to the macro sheet:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Working with Macros


Access 2002 Advanced

27
2003 Cheltenham Courseware for Trainers

Conditions button adds the Condition column to the macro sheet:

OR from the main menu, choose View > Conditions.

Insert Rows button inserts one or more blank rows in the grid above the selected row:

TR

IN

IN

Condition column is added to the macro sheet:

OR from the main menu, choose Insert > Rows.

Delete Rows button deletes the selected row or rows:

FO

OR from the main menu, choose Edit > Delete Rows.


Run button runs the macro:

OR from the main menu, choose Run > Run.

Single Step button runs the macro one action at a time, displaying intermediate information:

OR from the main menu, choose Run > Single Step.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

28
2003 Cheltenham Courseware for Trainers

Working with Macros


Access 2002 Advanced

Creating Macros

The Macro window opens, displaying the blank macro sheet.


Under the Action column, you will see the drop-down list which contains a list of predefined
actions for you to choose from:

FO

TR

IN

IN

Creating New Macros


While in the Macros page of the Database window, click on the New button:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Working with Macros


Access 2002 Advanced

29
2003 Cheltenham Courseware for Trainers

The Comment column contains optional comments used for documenting macros.
Once you select an Action, the pane on the bottom area displays the associated Action
Arguments:

Depending on the selected action, some arguments are required and some are optional.
For example, for the Close action, you can select an Object Type, such as Form:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

30
2003 Cheltenham Courseware for Trainers

Working with Macros


Access 2002 Advanced

Once the Object Type is selected, you can select an Object Name. Access will list all
available Forms in the current database:

The last argument is the Save option (required). Here, you can select what type of actions
Access should perform at the end:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Working with Macros


Access 2002 Advanced

31
2003 Cheltenham Courseware for Trainers

Note: The information pane at the bottom-right area of the Macro window displays
information about the part of the macro sheet that is currently active. If you need more
information, press the F1 key for help.

Close the Macro window and click Yes to save changes for your new macro:

In the Save As dialog box, enter the name in the Macro Name field, then click OK:

The new macro is now available in the Macros tab of the Database window:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

32
2003 Cheltenham Courseware for Trainers

Working with Macros


Access 2002 Advanced

Testing and Debugging Macros

TR

IN

IN

To run a macro:
Select the macro name from the Macros page of the Database window.
Click Run button:

Running a Macro
Once you have created a macro, you will have to run it and see if it works.
You can run the whole macro at once, or you can run step-by-step through the macro.
If you get an error while running a macro, make sure you run through the macro step-by-step
to find where the error occurs, and fix it.

FO

OR double-click the macro name

OR right-click the macro name and choose Run from the popup menu:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Working with Macros


Access 2002 Advanced

33
2003 Cheltenham Courseware for Trainers

Stepping Through a Macro


If you have received an error while running a macro, you will have to step through the macro
in order to find the error and fix it.

TR

IN

IN

To use the Single Step method to run a macro:


Select the macro name from the Macros page of the Database window.
Click Design button to open the Macro window:

While in the Macro window, click on the Single Step button:

This will open the Macro Single Step dialog box:

FO

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

34
2003 Cheltenham Courseware for Trainers

The Step button moves to the next action, if there are more actions in the macro. This is the
default option.
The Halt button stops macro execution.
The Continue button stops the Single Step mode and runs the rest of the macro without
stopping.

Working with Macros


Access 2002 Advanced

Modifying Macros

TR

IN

IN

Modifying a Macro
Select the name of the macro you want to modify from the Macros page of the Database
window.
Click Design button to open the Macro window.
Use the Insert Rows toolbar button or the Insert menu command to add actions.
Use the Delete Rows toolbar button or the Edit menu command to delete actions.
Use the Cut, Copy, and Paste operations to edit a macro.
Use the Undo button to reverse the recent changes.
When you have finished editing the macro, Save it again.
Run and test your newly saved macro to make sure it works properly.

Conditional Programming in Macros

FO

Adding Conditions to Macros


By adding conditions to macros, you can specify if and when actions will happen.
Conditions mean that if the condition is true, then the action(s) will be performed. If the
condition is not true, the macro will skip to the next action but only if there is one.
Macro conditions are added in the Condition column on the macro sheet:

By default, the condition only applies to the action on the same row in the macro sheet.
If the condition is not met, the next action (i.e. the next row) will be executed.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Working with Macros


Access 2002 Advanced

35
2003 Cheltenham Courseware for Trainers

To extend the condition to the next action, you must enter the ellipsis () in the Condition
column of the next row:

When debugging a macro, you can temporarily disable an action by entering False in the
Condition column:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

36
2003 Cheltenham Courseware for Trainers

Working with Macros


Access 2002 Advanced

In the Expression Builder dialog box, create the logical expression (for example if the Total
Pages number is greater than 0) and click OK:

FO

TR

IN

IN

Using the Expression Builder to create Conditions


Right-click inside the Condition field where you want to create a condition, and select Build
from the popup menu:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Working with Macros


Access 2002 Advanced

The new expression will be displayed in the Condition field:

IN

IN

37
2003 Cheltenham Courseware for Trainers

FO

TR

Running Macros with Conditions


When running macros with conditions, Access evaluates each condition and does each of the
following.
If condition is TRUE, Access runs the action on that row first, then runs all following actions
that have an ellipsis () in the Condition column. Access then runs any additional actions
that have blank conditions until it encounters another condition, comes across a macro name
in the Macro Name column, or reaches the end of the macro.
If a condition is FALSE, Access ignores the action on that row and any subsequent actions
that have an ellipsis () in the Condition column. Access then moves to the next condition, if
there is one:

Note: The MsgBox action has a condition [CurrentRecord]=0, meaning if no records are
returned for the selected letter, display a message. Then Access goes to the next action with
an ellipsis () ShowAllRecords that will show all records. Then Access continues to the
next action with an ellipsis () SetValue that will press in the All button.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

38
2003 Cheltenham Courseware for Trainers

Working with Macros


Access 2002 Advanced

Adding Macros to Forms

TR

IN

IN

Attaching Macros to a Form


First select the form in the Forms page of the Database window and click on the Design
button:

FO

To attach the macro to a form event:


From the main menu, choose Edit > Select Form
OR press the Ctrl + R key combination.
The Form is selected:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Working with Macros


Access 2002 Advanced

39
2003 Cheltenham Courseware for Trainers

TR

IN

IN

To attach the macro to a section of the form:


Click the section selector (for example, Detail section):

FO

To attach the macro to a control in the form:


Select the control (for example, Exit Microsoft Access button):

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

40
2003 Cheltenham Courseware for Trainers

Working with Macros


Access 2002 Advanced

Save and close the form design.

TR

IN

IN

To attach the macro to the selected form property:


From the main menu, choose View > Properties
OR press the F4 key
OR right-click on the selection and select Properties from the popup menu (available for
section or control objects only).
Click the Event tab to view a list of events that can occur for the selected object.
Select the event you want to run the macro (for example, On Exit).
Choose the Macro name from the drop-down list of available macros (for example, Close):

Adding Macros to Reports

FO

Attaching Macros to a Report


Select the form in the Reports tab of the Database window and click on the Design button:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Working with Macros


Access 2002 Advanced

41
2003 Cheltenham Courseware for Trainers

TR

IN

IN

To attach the macro to a report event:


From the main menu, choose Edit > Select Report
OR press the Ctrl + R key combination.
The Report is selected:

FO

To attach the macro to a section of the report:


Click the section selector (for example, Page Header section):

To attach the macro to the selected form property:


From the main menu, choose View > Properties
OR press the F4 key
OR right-click on the selection and select Properties from the popup menu (available for the
section or control objects only).
Click the Event tab to view a list of events that can occur for the selected object.
Select the event you want to run the macro (for example, On Format).

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

42
2003 Cheltenham Courseware for Trainers

Working with Macros


Access 2002 Advanced

Choose the Macro name from the drop-down list of available macros (for example, Sales
Totals by Amount):

Save and close the report design.

TR

Filtering Data

IN

IN

FO

Filtering Records
The Northwind sample database contains a macro that alphabetically filters the records in the
Customer Phone List form.
Open the Northwind database by selecting Help > Sample Databases > Northwind Sample
Database from the main menu.
In the Main Switchboard window, click on the Display Database Window button:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Working with Macros


Access 2002 Advanced

43
2003 Cheltenham Courseware for Trainers

In the Database window, click on the Macros tab, then select the Customer Phone List
macro and click on the Design button:

This will open the macro sheet:

FO

TR

IN

IN

In the Comment column, you can see that this macro is attached to the Customer Phone List
form. In order to see how the macro works, we should run it first.
In order to run the macro, we have to open the form attached to the macro.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

44
2003 Cheltenham Courseware for Trainers

Working with Macros


Access 2002 Advanced

Go back to the Database window, click on the Forms tab, and select Customer Phone List:

Double-click on the form name to open it:

FO

TR

IN

IN

As you can see, the form has Alphabet buttons that will filter data when pressed. Only the
company names that start with a specified letter of the alphabet will be displayed.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Working with Macros


Access 2002 Advanced

45
2003 Cheltenham Courseware for Trainers

Click on the Design button to see the underlined programming for this form:

The row of Alphabetic buttons are actually an Option Group control named
CompanyNameFilters, which returns a value depending which button is selected.
If you open the Properties for this control, you will see that the macro Customer Phone
List.Alpha Button is attached to the After Update event. This means that the macro will run
when the user clicks one of the buttons in the option group.

Go back to the Customer Phone List macro sheet to see how this is done:

The Alpha Buttons macro applies a filter to the list, based on which button is pressed.
For example, if the A button is pressed, the macro will filter for company names that start with

Pressing on the A button will result in this company list:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

46
2003 Cheltenham Courseware for Trainers

Working with Macros


Access 2002 Advanced

Now go back to the Customer Phone List macro sheet and scroll down to the last rows. In
the GoToControl action row, the stated condition is that if the current record count is greater
than 0, the records are displayed and the macro stops. The ellipsis () in the StopMacro
action row carries over the condition from the row above it:

However, if no records are returned by the filter (based on the condition if the current record
count equal to 0), the message will be displayed in the MsgBox action. When the user clicks
OK to close the message window, all records are displayed on the screen, as the ellipsis ()
in the ShowAllRecord action row carries over the condition from the row above it.
Furthermore, the next action row containing ellipsis () SetValue, will press in the All button
in the form:

TR

IN

IN

FO

Documenting Macros

Commenting Macros
To make programming and future updates easier, make sure you comment macros using the
Comment column in the macro sheet:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Working with Macros


Access 2002 Advanced

47
2003 Cheltenham Courseware for Trainers

Properties include the container, date created, date of last update, owner, and user.
Actions and Arguments include all the actions with their conditions, as well as values for all
arguments.
Permissions by User and Group include user permissions and group permissions.

IN

IN

Printing Macro Definitions


In the Macros page of the Database window, select the macro name.
From the main menu, choose File > Print
OR press the Ctrl + P key combination.
In the Print Macro Definition dialog box, select what info you want to print and click OK:

FO

TR

Viewing Macro Definitions


In the Macros page of the Database window, select the macro name.
From the main menu, choose File > Print Preview and make the same selections as for the
Print:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

48
2003 Cheltenham Courseware for Trainers

Working with Macros


Access 2002 Advanced

IN
IN

FO

TR

How would you:


Understand Macros?
Use the Macro Window Toolbar?
Create New Macros?
Run a Macro?
Step Through a Macro?
Modify a Macro?
Add Conditions to Macros?
Use the Expression Builder to Create Conditions?
Run Macros with Conditions?
Attach Macros to a Form?
Attach Macros to a Report?
Filter Records?
Comment Macros?
Print Macro Definitions?
View Macro Definitions?

Review Questions

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Programming Access Using Visual Basic


Access 2002 Advanced

49
2003 Cheltenham Courseware for Trainers

TR

IN

IN

When you have completed this learning module you will have seen how to:
Use Visual Basic Modules
Convert Macros to Visual Basic Code
Understand Modules
Create Modules
Understand Module Declarations
Understand Procedures
Use Naming Rules
Declare Variables
Set Variable Scope
Declare Constants
Use Methods
Use Arguments
Customize the Visual Basic Editor Window
Set the Visual Basic Editor Options
Use Microsoft Visual Basic Help
Get Visual Basic Syntax Help

Programming Access Using Visual Basic

Using Macros versus Visual Basic

In this manual, we will cover only the basics of Visual Basic programming regarding its use in
Access 2002.
If you want to learn more about Visual Basic, refer to one of the numerous manuals and
books on this subject.

FO

Using Visual Basic Modules


In the previous chapter, we have covered the use of Macros. Another way to program
Access is writing Visual Basic modules.
Certain procedures cannot be created in Macros, you must use Visual Basic to write them.
Examples of Visual Basic usages:
- Error handling
- Repetitive looping
- Custom functions
- Optimized performance, etc

Converting Macros to Visual Basic Code


There are two methods for converting Macros to Visual Basic (VB) code:
Converting from the Macros page of the Database window this is used when you want to
make VB code available to the whole database.
Converting from the Form or Report Design view this is used when you want to store VB
code with a form or report.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

50
2003 Cheltenham Courseware for Trainers

Programming Access Using Visual Basic


Access 2002 Advanced

To convert a Macro from the Database Window:


Click on the Macros tab in the Database window.
Select a macro you want to convert to VB.
From the main menu, choose Tools > Macro > Convert Macros to Visual Basic

IN

IN

OR from the main menu, choose File > Save As and in the Save As dialog box, select
Module under the As filed. Click OK to continue:

This will open up the Convert macro: macro_name dialog box:

Check the Add error handling to generated functions and Include macro comments
options and click Convert.
The Convert macros to Visual Basic message box shows the conversion is finished.

FO

TR

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Programming Access Using Visual Basic


Access 2002 Advanced

51
2003 Cheltenham Courseware for Trainers

This will create Converted Macro macro_name module, listed under the Modules folder
in the Visual Basic Editor window. Click on the module to see the code:

Scroll to the end of the code window to view the whole Visual Basic code:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

52
2003 Cheltenham Courseware for Trainers

Programming Access Using Visual Basic


Access 2002 Advanced

Newly created module is also listed in the Modules tab of the Database window:

TR

IN

IN

The Function statement represents the global module that is available to the entire
database.
The DoCmd statement performs macro action in a Visual Basic procedure.
Apostrophe () marks the comment line.

FO

To convert Forms Macro from the Design View:


Click on the Forms tab in the Database window.
Select a form whose macro you want to convert to VB.
Click on the Design view button.
From the main menu, choose Tools > Macro > Convert Forms Macros to Visual Basic.
This will open up the Convert form macros: macro_name dialog box:

Uncheck Add error handling to generated functions and check Include macro comments
options and click Convert.
The Convert macros to Visual Basic message box shows the conversion is finished.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Programming Access Using Visual Basic


Access 2002 Advanced

53
2003 Cheltenham Courseware for Trainers

Click on the Code toolbar button to open the Visual Basic Editor window with the converted
macros code:

Scroll to the end of the code window to view the whole Visual Basic code:

FO

TR

IN

IN

The Sub statement represents the local code, stored with a form.
The DoCmd statement performs macro action in a Visual Basic procedure.
The Apostrophe () marks the comment line.
FOR USE AT THE LICENSED SITE(S) ONLY
Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

54
2003 Cheltenham Courseware for Trainers

Programming Access Using Visual Basic


Access 2002 Advanced

IN

Uncheck Add error handling to generated functions and check the Include macro
comments option and click Convert.
The Convert macros to Visual Basic message box shows the conversion is finished.

TR

Understanding Visual Basic Concepts

IN

To convert Reports Macro from the Design View:


Click on the Reports tab in the Database window.
Select a report whose macro you want to convert to VB.
Click on the Design view button.
From the main menu, choose Tools > Macro > Convert Reports Macros to Visual Basic.
This will open up the Convert report macros: macro_name dialog box:

Understanding Modules
The Visual Basic module consists of declarations and procedures.
Modules are used to create event procedures that execute when an event occurs.
There are two types of modules:
1. Module objects listed in the Modules page of the Database window.
2. Form and Report modules stored together with a form or report containing procedures
and functions associated with a single form or report.

FO

Creating Modules
Click on the Modules tab in the Database window.
Click on the New button:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Programming Access Using Visual Basic


Access 2002 Advanced

55
2003 Cheltenham Courseware for Trainers

The new module, named Module1, opens up in the Visual Basic Editor window:

A newly created module has two or more sections:


Declarations section
Procedure section(s)

If you do not see the Option Explicit declaration, choose Tools > Options from the Visual
Basic Editor window main menu.
In the Options dialog box, click on the Editor tab and check the Require Variable
Declaration option. Click OK to continue:

TR

FO

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

56
2003 Cheltenham Courseware for Trainers

Programming Access Using Visual Basic


Access 2002 Advanced

Understanding Module Declarations


Declarations are listed in the first section of a module.
They set requirements and defaults on the module-level.

There are two default module-level declarations:


The Option Compare declaration specifies the default comparison method for string data.
This declaration requires an argument:
- Binary sorts string data based on the internal binary representation of characters.
- Text sorts in a case-insensitive text sort order.
- Database sorts in the same order as the database.
The Option Explicit declaration forces the declaration of variables used in the module.

IN

IN

Understanding Procedures
Procedures consist of statements and methods.
A statement is a complete instruction to Visual basic and consists of keywords, operations,
variables, constants, and expressions.

There are three types of statements:


Declaration statements used to name variables, constants or procedures.
Assignment statements used to give a value or an expression to a variable or a constant.
Executable statements used to trigger actions or jump to another location in the procedure.

There are two types of procedures:


A sub procedure is program code that does not return a value. It usually runs as a separate
program called by an event in a form or report.
Example of a sub procedure:

TR

A function procedure is program code that returns a value as a result of a calculation or


comparison.
Example of a function procedure:

FO

Sub sub_name (parameters)


DoCmd.command_name
End Sub

Function function_name (parameters) As type


calculation
End Function

Using Naming Rules


In any programming, writing clear code is one of the most important practices. This helps
you and others understand and maintain your code.

In Visual Basic, there are several naming rules and practices:


The first character must be a letter.
The name has a maximum of 255 characters.
Avoid the use of special characters and spaces, periods, exclamation marks, etc.
Avoid the use of Visual Basic keywords.
Avoid the use of same names for multiple variables in same procedures.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Programming Access Using Visual Basic


Access 2002 Advanced

Add prefixes to names that can indicate what type of item or variable they are:
- con used to indicate a constant
- int used to indicate an integer variable
- dte used to indicate a date variable
- str used to indicate a string variable
- rst used to indicate a recordset
- frm used to indicate a form

57
2003 Cheltenham Courseware for Trainers

Dim strName As String


Dim intAge As Integer, dteBirthday As Date, undeclared

You can declare several variables in the same statement, separated by commas.
In the above example, we have used prefixes to descriptively name the variables in order to
include their data type.
The last variable has no data type declaration, so the type is Variant.

TR

IN

IN

Declaring Variables
Variables are items with unique names that contain data that can be changed during
procedure execution.
You can specify the data type for each variable, or let Access assign the default Variant type.
A Variant type variable can contain string, date, time, Boolean, or numeric values.
The Dim statement is used to declare variables:

Setting Variable Scope


Scope of a variable indicates the variable availability to procedures.

FO

There are three levels of variable scope:


Procedure level is set when the variable is declared with a Dim statement in the procedure.
Private module level is set when the variable is declared with a Private statement in the
declarations module section. The variable is available only to procedures in that module.
Public module level is set when the variable is declared with a Public statement in the
declarations module section. The variable is available to all procedures in the application.

Declaring Constants
Constants are items with unique names within which data cannot be changed during
procedure execution.
A constant data type can be a string or number value, another constant, or an expression.
The Const statement is used to declare constants and give them a value:

Const conYear As Integer = 1990


Const conTitle As String = President

You can declare several constants in the same statement separated by commas.
In the above example, we have used prefix con to descriptively name the constants instead
of their data types.
You must assign a constant a value at the time of declaration.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

58
2003 Cheltenham Courseware for Trainers

Programming Access Using Visual Basic


Access 2002 Advanced

Methods have specific synax that indicates the object and the action:

IN

SetFocus Forms![Customer Phone List]![Company Name].SetFocus

IN

Using Methods
Methods are actions that database objects can perform, or procedures that apply to
database objects.
Access 2002 modules can use nearly 160 methods that apply to different database objects.
Some examples of methods are:
- Opening or closing a form.
- Sounding a beep when specific event occurs.
- Going to a specific field in a form.
- Filtering records for a report.
- Printing multiple copies of a report, etc.

In the example above, the method moves the cursor to the Company Name field in the
Customer Phone List form.

TR

Using Arguments
Arguments are used in the sub or function procedure calls.
They are optional, depending on the procedure.
There are two ways you can list arguments: in a procedure order, or by name.
For example, this is the sub procedure with argument list:

Sub GetArguments (strName As String, dteBirthday As Date, intAge As Integer)

When you run the procedure, you can list the arguments in the same order as the procedure:

GetArguments John, #11/12/1967#, 36

Or, you can list the arguments using their names in any order:

FO

GetArguments dteBirthday:=#11/12/1967#, intAge:=36, strName:=John

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Programming Access Using Visual Basic


Access 2002 Advanced

59
2003 Cheltenham Courseware for Trainers

FO

TR

IN

IN

Using the Visual Basic Editor Window

Customizing the Visual Basic Editor Window


Once you open the Visual Basic Editor window, you can change its look.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

60
2003 Cheltenham Courseware for Trainers

Programming Access Using Visual Basic


Access 2002 Advanced

From the main menu, choose View > then select the elements you want to see in the editor
window:

In the Code view, the Object list box displays a list of all controls in the form or report:

FO

TR

IN

IN

In the Code view, the Procedure list box displays a list of all procedures in the module
object:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Programming Access Using Visual Basic


Access 2002 Advanced

61
2003 Cheltenham Courseware for Trainers

TR

IN

IN

Setting the Visual Basic Editor Options


Once you open the Visual Basic Editor window, you can change its features.
From the main menu, choose Tools > Options.
This opens up the Options dialog box:

The Code Settings group controls the code editing.


Auto Syntax Check option checks for syntax errors as you type the code.
Require Variable Declaration option includes the Option Explicit declaration in new
modules.
Auto List Members option displays a list of keywords as you type the code.
Auto Quick Info option displays syntax when you type a method or procedure name.
Auto Data Tips option displays the current value of a variable when you rest your mouse
pointer on the name.
Auto Indent option indents a line of code to match the previous line.
Tab Width option sets the number of characters for TAB key.

FO

The Window Settings group controls the editor window behaviors.


Drag-and-Drop Text Editing option allows drag-and-drop editing in a module.
Default to Full Module view option shows all procedures in the module by default.
Procedure Separator option displays a horizontal line between procedures.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

62
2003 Cheltenham Courseware for Trainers

Programming Access Using Visual Basic


Access 2002 Advanced

Click the Editor Format tab to specify the appearance of the different types of text in the
editor window:

Click the General tab to set Form Grid Settings, Error Trapping and Compile options:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Programming Access Using Visual Basic


Access 2002 Advanced

Click the Docking tab to allow docking for editor windows:

TR

IN

IN

63
2003 Cheltenham Courseware for Trainers

Getting Help with Visual Basic

If you get the following message, you must install the Microsoft Visual Basic Help first. Click
on the Yes button, and follow the installation instructions:

FO

Using Microsoft Visual Basic Help


Open the Visual Basic Editor window.
From the main menu, choose Help > Microsoft Visual Basic Help
OR press the F1 key
OR click on the Microsoft Visual Basic Help [?] button on the toolbar:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

64
2003 Cheltenham Courseware for Trainers

The Microsoft Visual Basic Help window opens up. Here you can find extensive reference
for various Visual Basic topics:

FO

TR

IN

IN

Programming Access Using Visual Basic


Access 2002 Advanced

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Programming Access Using Visual Basic


Access 2002 Advanced

65
2003 Cheltenham Courseware for Trainers

FO

TR

IN

IN

Getting Visual Basic Syntax Help


While you are editing statements in the Visual Basic Editor window, you can get syntax help
from the Edit menu:

OR right-click inside the statement and choose desired help from the popup menu:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

66
2003 Cheltenham Courseware for Trainers

Programming Access Using Visual Basic


Access 2002 Advanced

List Properties/Methods lists all properties and methods available for selected statement:

List Constants lists all intrinsic constants that are valid for a specific item in the argument
list.

Quick Info displays the complete syntax with the current item highlighted in bold:

Parameter Info displays the complete syntax with the current parameter highlighted in bold:

Complete Word automatically completes the word when you begin typing.

Review Questions

TR

IN

IN

FO

How would you:


Use Visual Basic Modules?
Convert Macros to Visual Basic Code?
Understand Modules?
Create Modules?
Understand Module Declarations?
Understand Procedures?
Use Naming Rules?
Declare Variables?
Set Variable Scope?
Declare Constants?
Use Methods?
Use Arguments?
Customize the Visual Basic Editor Window?
Set the Visual Basic Editor Options?
Use Microsoft Visual Basic Help?
Get Visual Basic Syntax Help?

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

67
2003 Cheltenham Courseware for Trainers

Creating Data Access Pages

TR

IN

IN

When you have completed this learning module you will have seen how to:
Use Data Access Pages
Create pages using the AutoPage
Create pages using the Page Wizard
Create pages using an Existing HTML Document
Create pages using the Design View
Choose a Theme
Add Text
Add Controls
Format Text and Labels
Align Content
Size Content
Add Images
Add Backgrounds
Sort Data
Summarize Data
Add a New Record
Delete a Record
Customize Navigation Bar
Protect Fields

Using Data Access Pages

FO

Using Data Access Pages


Data access pages allow you to connect Access database to the Internet.
With data access pages you can share database data and allow viewing and/or editing of
dynamic data at your website.
To display data access pages, the user must use Internet Explorer 5.5 or later and have a
Microsoft Office XP license.
There are several ways to create data access pages using:
AutoPage
Page Wizard
Existing HTML Document
Design View

Creating pages using the AutoPage


The quickest way to create data access pages is to use the AutoPage feature.
AutoPage automatically adds all the fields from selected table or query.
Data is displayed in a form-like style.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

68
2003 Cheltenham Courseware for Trainers

Using Data Access Pages


Access 2002 Advanced

In the New Data Access Page select AutoPage: Columnar:

FO

TR

IN

IN

To create a data access page using AutoPage:


In the Database window, click on the Pages tab, then click on the New button:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

69
2003 Cheltenham Courseware for Trainers

Choose the table or query where the objects data comes from by selecting it from the
drop-down list:

Click OK to create a data access page:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

70
2003 Cheltenham Courseware for Trainers

Using Data Access Pages


Access 2002 Advanced

At the bottom of the data access page, you will notice the Record Navigation Bar.
From the main menu, choose File > Save to open the Save As Data Access Page dialog
box:

Select the location and name the data access page and click Save.
The new data access page is listed in the Pages section of Database window:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

71
2003 Cheltenham Courseware for Trainers

FO

TR

IN

IN

To view a data access page in the browser:


Select the data access page in the Pages page of the Database window.
From the main menu, choose File > Web Page Preview.
The data access page opens in the browser window:

Creating pages using the Page Wizard


Another way to create data access pages is using the Page Wizard.
The Page Wizard allows additional options for creating a data access page. For example,
you can choose fields from more than one table or query, grouping, selecting multiple fields
for sorting, etc.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

72
2003 Cheltenham Courseware for Trainers

Using Data Access Pages


Access 2002 Advanced

IN

IN

To create a data access page using the Page Wizard:


In the Database window, click on the Pages tab, and then click on the New button.
In the New Data Access Page select Page Wizard and click OK to continue:

FO

TR

OR from the Pages page of Database window, double-click on Create data access page by
using wizard:

This will open the Page Wizard dialog box.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

73
2003 Cheltenham Courseware for Trainers

Select the table or query from the Tables/Queries drop-down list:

Under the Available Fields list, select one field and click [>] button to transfer it to the
Selected Fields:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

74
2003 Cheltenham Courseware for Trainers

Using Data Access Pages


Access 2002 Advanced

If you want to select all the fields, click on the [>>] button:

If you want to remove a field from the Selected Fields list, select the field and click on the [<]
button.
Repeat the same steps for other tables and/or queries from which you want to add fields to
the data access page. Once you have finished selecting fields, click Next button to continue.

IN

IN

FO

TR

To group data in the data access pages:


This page of the wizard allows you to add grouping levels.
Select the field you want to group by, and click on the [>] button:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

75
2003 Cheltenham Courseware for Trainers

A new grouping level will be added to the data access page. If you want to choose the
grouping interval, click on the Grouping Options button:

The Grouping Intervals dialog box allows you to choose how you want to group the grouplevel field(s). Click OK to accept change or Cancel to close the dialog box:

FO

TR

IN

IN

Back in the Page Wizard, click Next to continue.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

76
2003 Cheltenham Courseware for Trainers

Using Data Access Pages


Access 2002 Advanced

The default sorting order is ascending. If you want to change the sorting order, click the
Ascending button to change it into Descending:

FO

TR

IN

IN

To sort data in the data access pages:


This page of the wizard allows you to sort records.
Select the sorting field(s) from the drop-down lists:

Once you select all of the sorting fields, click on the Next button to continue.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

77
2003 Cheltenham Courseware for Trainers

The last page of the wizard allows you to add a title to the page and set other options:

Open the page option takes you directly to the Page view.
Modify the pages design option takes you directly to the Design view.
Do you want to apply a theme to your page option allows you to add predefined styles to
the data access page.
Display Help on working with the page option gives you help while working on the page
design.

Click Finish. Depending on what you have selected, the page will be opened in either the
Page view or the Design view. This is a sample of the page in the Design view:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

78
2003 Cheltenham Courseware for Trainers

Using Data Access Pages


Access 2002 Advanced

Creating pages using an Existing HTML Document


If you already have an HTML document that contains layout, graphics, and text that you want
to use in your data access pages, you can use the following procedure to create a data
access page.

TR

IN

IN

To create a data access page using an Existing Web page:


In the Database window, click on the Pages tab, and then click on the New button.
In the New Data Access Page select Existing Web page and click OK to continue:

FO

OR from the Pages page of the Database window, double-click on Edit Web page that
already exists:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

79
2003 Cheltenham Courseware for Trainers

This will open the Locate Web Page dialog box where you can select the already existing
web page. Click Open to continue:

This will open the web page in the Design view:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

80
2003 Cheltenham Courseware for Trainers

Using Data Access Pages


Access 2002 Advanced

Creating pages using the Design View


If you already have an HTML document that contains layout, graphics and text you want to
use in your data access pages, you can use the following procedure to create a data access
page.

TR

IN

IN

To create a data access page using an Existing Web page:


In the Database window, click on the Pages tab, and then click on the New button.
In the New Data Access Page select Design View and click OK to continue:

FO

OR from the Pages page of the Database window, double-click on Create data access page
in Design view:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

This will open the blank page in Design view. Simply drag and drop fields from the Field
List window to the page grid and use the Toolbox to add controls to the data access page:

TR

Modifying Data Access Pages

IN

IN

81
2003 Cheltenham Courseware for Trainers

FO

Choosing a Theme
In the Database window, click on the Pages tab.
Select the data access page you want to modify and click the Design button:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

82
2003 Cheltenham Courseware for Trainers

Once the page is opened in Design view, from the main menu, choose Format > Theme.
This will open the Theme dialog box:

FO

TR

IN

IN

Using Data Access Pages


Access 2002 Advanced

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

Under the Choose a Theme list, select the theme you want, and you will see an example in
the right pane:

FO

TR

IN

IN

83
2003 Cheltenham Courseware for Trainers

Note: If the theme you selected is not installed, the Install button is displayed on the right
pane. Click on the Install button to install the selected theme from the Office XP CD.
Vivid Colors option displays the text links and button colors with a brighter color scheme.
Active Graphics option refers to Animated GIF files.
Background Image option activates or deactivates the background image.
Set Default button sets the current theme as the default theme for all new data access
pages.
Click OK to apply the theme.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

84
2003 Cheltenham Courseware for Trainers

Using Data Access Pages


Access 2002 Advanced

TR

IN

IN

Adding Text
You can add text to the page areas above or below the grid section header.
Simply position the insertion point on the page and type the text:

The Grid section is the area generally used for data-related text and controls, as the
absolute positioning of the grid allows you to place fields in a structured layout.

FO

Adding Controls
Controls are objects that can be placed on data access pages that display data, perform
actions, or can be used for visual display.
The Toolbox contains controls that you can add to the page design:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

85
2003 Cheltenham Courseware for Trainers

Click on a Button in the Toolbox and then click on the page to add this control to the page:
BUTTON

CONTROL

DESCRIPTION

Label

Used to display text on a page. Labels are useful for


descriptive or instructional text. Labels are not
associated with a data source.
Used to display data from a field in the database or
result of an expression.
Used to input data on a page. Text boxes are
unbound to accept input or display a calculation.
Used to add a marquee for displaying scrolling text.

Bound Span

IN

Text Box
Scrolling Text

Option Button

Check Box

Command Button
Expand

TR

Drop-down List
List Box

Used to select a limited list of choices. Sometimes


interchangeable with List Boxes when selecting from
only a few pre-defined options.
Used to set Yes/No values from an underlying query
or table.
Used to set Yes/No values from an underlying query
or table.
Used to display a pre-determined list of values. Dropdown Lists are useful when limiting selection choices
or when enforcing data integrity.
Used to display a pre-determined list of values. List
boxes are useful when limiting selection choices or
when enforcing data integrity.
Used to execute a pre-defined set of actions in a
macro or event procedure written in visual basic.
Used to add a button for expanding and collapsing
grouped records.
Used to add a Record Navigation bar that contains
buttons for display, edit, delete, sort, and filter.
Used to add a PivotTable. PivotTables can be
associated with a data source.
Used to add a Chart. Used for analyzing data.

IN

Option Group

Record Navigation

FO

Office PivotTable
Office Chart

Office Spreadsheet
Hyperlink

Movie

Used to insert an image with a link to a file or a web


page.
Used to insert a movie on a page.

Image

Used to insert an image on a page.

Line

Used when displaying horizontal lines. Useful when


displaying breaks between fields within a page.
Used when displaying rectangle shapes. Useful when
displaying sections within a page.

Hyperlink Image

Used to add Excel Spreadsheets for adding data or


importing a spreadsheet from Excel.
Used to insert a link to a file or a web page.

Rectangle

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

86
2003 Cheltenham Courseware for Trainers

Using Data Access Pages


Access 2002 Advanced

TR

IN

Aligning Content
In the page Design view, select the content you want to align.
From the main menu, choose Format > Align > alignment option:

IN

Formatting Text and Labels


In the page Design view, select the text or label(s) you want to format.
From the Formatting (Page) toolbar, select any formatting tool and apply appropriate
formatting: Style, Font, Font Size, Bold, Italic, Underline, Align Left, Center, Align Right,
Decrease Indent, Increase Indent, Numbering, Bullets, Fill/Back Color, Font/Fore Color,
Line/Border Color, Line/Border Width, and Special Effect:

FO

OR right-click on the selection and select Align > alignment option from the popup menu:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

87
2003 Cheltenham Courseware for Trainers

IN

IN

Sizing Content
In the page Design view, select the content you want to resize.
From the main menu, choose Format > Size > sizing option:

TR

OR right-click on the selection and select Size > sizing option from the popup menu:

FO

Adding Images
From the Toolbox, click on the Image button.
Place the Image control on the page:

This will open the Insert Picture dialog box. Select the image file you want to place and click
Insert.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

88
2003 Cheltenham Courseware for Trainers

To change various image properties, right-click on the image and select Element Properties
from the popup menu. Under the Format tab, you can modify image border properties,
height, width, margins, etc:

IN

IN

Using Data Access Pages


Access 2002 Advanced

TR

Adding Backgrounds
Data access page background can be displayed with flat color or a tiled image.

FO

To add a Background Color:


From the main menu, choose Format > Background > Color > Transparent (default) or any
other color:

To add a Background Picture:


From the main menu, choose Format > Background > Picture.
This will open the Insert Picture dialog box. Locate your background image and click Insert.
The picture will automatically fill in the background in a tiled style.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

89
2003 Cheltenham Courseware for Trainers

Sorting Data in Data Access Pages

If you cannot see the whole text in the property box, right-click on the box and choose Zoom
from the popup menu to zoom it up:

FO

TR

IN

IN

Sorting Data
In the page Design view, select the group section bar.
Right-click the selection and choose Group Level Properties from the popup menu.
In the properties dialog box, enter the name of the field you want the records to be sorted by
in the DefaultSort property box:

As usual, if the field name includes a space, make sure to enclose the name with square
brackets [ ].
By default, the records are sorted in the ascending order. If you want to switch to descending
order, enter a space after the field name and then type DESC:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

90
2003 Cheltenham Courseware for Trainers

Using Data Access Pages


Access 2002 Advanced

Summarizing Data in Data Access Pages

IN

Summarizing Data
The AutoSum feature in the data access page Design view allows you to quickly add
calculated summaries to a page.
In the page Design view, select the bound span control you want to summarize:

Click on the AutoSum tool from the toolbar and choose from the list:

Save the page.


From the main menu, choose File > Web Page Preview to see the summary result:

FO

TR

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

91
2003 Cheltenham Courseware for Trainers

Editing Data in Data Access Pages

In data access pages, much the same as in the forms, you can use the Record Navigation
Bar to add, edit and delete records.

IN

IN

To add a new record:


From the Record Navigation Bar, click the New record button:

Adding a New Record


From the main menu, choose File > Web Page Preview.
Notice the Record Navigation Bar at the bottom of the page:

Type the data in the first field.


Press the TAB key to move to the next field.
Click on the Save button to save the record:

Or click on the Undo button to undo the changes:

FO

TR

Deleting a Record
From the main menu, choose File > Web Page Preview.
Use the Next and Previous buttons on the Record Navigation Bar, to locate the record you
want to remove.
Click on the Delete button to remove the record:

If the data access page does not display the changes, refresh the browser window by
pressing the F5 key.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

92
2003 Cheltenham Courseware for Trainers

Using Data Access Pages


Access 2002 Advanced

Protecting Data in Data Access Pages

IN

Customizing Navigation Bar


The easiest way to protect the data in data access pages is to limit the Record Navigation
Bar functionality.
In the page Design view, select the Navigation control:

Right-click on selection and choose Navigation Buttons from the popup menu:

Uncheck any button you want to remove from the Record Navigation Bar. For example,
uncheck the New button to disable adding new records:

FO

TR

IN

If you want to add the control back to the Navigation bar, check the button again.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Using Data Access Pages


Access 2002 Advanced

93
2003 Cheltenham Courseware for Trainers

In the properties dialog box, click on the Other tab.


Under the ReadOnly property box, select True to protect the field from editing.
Save the page.

Review Questions

TR

IN

IN

Protecting Fields
If you want to protect only certain fields from editing, you can change their properties.
In the page Design view, select the field you want to protect and open its properties:

FO

How would you:


Use Data Access Pages?
Create pages using the AutoPage?
Create pages using the Page Wizard?
Create pages using an Existing HTML Document?
Create a page using the Design View?
Choose a Theme?
Add Text?
Add Controls?
Format Text and Labels?
Align Content?
Size Content?
Add Images?
Add Backgrounds?
Sort Data?
Summarize Data?
Add a New Record?
Delete a Record?
Customize Navigation Bar?
Protect Fields?

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

N
T
R

FO
IN

TR

IN

Converting Access Databases


Access 2002 Advanced

95
2003 Cheltenham Courseware for Trainers

IN

When you have completed this learning module you will have seen how to:
Convert Databases
Convert Database Objects
Enable Databases
Share Databases across various Access versions
Convert an Access 2002 database to an Access 97 database
Convert an Access 2002 database to an Access 2000 database

In Microsoft Access, incompatibility exists between different versions of Access. Therefore,


you will need to convert your database(s) to Access 2002 in order to work on them.
You can convert databases created with Access 2.0 or later to Access 2002.

IN

Converting Databases to Access 2002

Converting Access Databases

FO

TR

Converting Databases
Before any conversion, first you should create a backup copy of your Access database.
If opened, close the database you want to convert.
If the database is used in a multiple-user environment, make sure that all users have closed
the database.
In an empty Access 2002 window, choose Tools > Database Utilities > Convert Database
> To Access 2002 File Format from the main menu.
In the Database to Convert From dialog box, select the database to be converted to Access
2002, then click on the Convert button:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

96
2003 Cheltenham Courseware for Trainers

Converting Access Databases


Access 2002 Advanced

In the Convert Database Into dialog box, enter the database name in the File name field,
and then click on the Save button:

You will see the warning dialog box. Click on the OK button to proceed:

Note: If your Access database has linked tables, make sure these tables remain in the
original folder, so that the converted database can find them. If Access cannot find linked
databases, the converted database will not work properly. Linked tables are not converted
automatically; so you must convert them manually.

FO

TR

IN

IN

Converting Database Objects


If you do not want all of the objects in the older-version database to be converted in the
Access 2002, you can convert only specific objects: Tables, Queries, Forms, Reports, Pages,
Macros, and Modules.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Converting Access Databases


Access 2002 Advanced

97
2003 Cheltenham Courseware for Trainers

In the Import Objects dialog box, select the object(s) and click on the OK button:

FO

TR

IN

IN

To convert Database Objects to Access 2002:


Create a new Access 2002 database, or open an already existing one.
From the main menu, choose File > Get External Data > Import.
In the Import dialog box, select the older-version database and click on the Import button:

Enabling Databases
In some cases, you might want to open an older-version Access database in Access 2002
without converting it first. This may be necessary if some of the database users do not have
Access 2002.
By enabling a database, you can still add, modify and delete records, but you cannot modify
any existing objects or add new objects using Access 2002.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

98
2003 Cheltenham Courseware for Trainers

Converting Access Databases


Access 2002 Advanced

TR

IN

IN

To enable a Database:
From the main menu, choose File > Open.
Select an older-version Access database and click Open.
In the Convert/Open Database dialog box, select the Open Database option and click OK:

Note: You cannot import or link an Access 2002 table into an enabled database.

FO

Sharing Databases across various Access versions


You can also use a one-file database with several versions of Access by creating a front-end
/ back-end database out of a one-file database.
The oldest-version database file is the back-end containing all data.
The Access 2002 database is the front-end containing all converted objects.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Converting Access Databases


Access 2002 Advanced

99
2003 Cheltenham Courseware for Trainers

In the Create Back-end Database dialog box, the File name will be automatically named
with suffix _be. Keep that name and click on the Split button:

FO

TR

IN

IN

To create one-file Access database:


Convert the oldest-version database to Access 2002.
Open the converted database and choose Tools > Database Utilities > Database Splitter
from the main menu,.
In the Database Splitter dialog box, click on the Split Database button:

Once you have split the database into front-end and back-end, delete the back-end database.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

100
2003 Cheltenham Courseware for Trainers

From the main menu, choose Tools > Database Utilities > Linked Table Manager.
Link the new Access 2002 front-end to the tables in the older-version (back-end) database.
Click the Select All button, and then OK to link all tables:

IN

IN

Converting Access Databases


Access 2002 Advanced

TR

Converting from Access 2002 to Access 97

Converting an Access 2002 database to an Access 97 database


When converting an Access 2002 database to an Access 97 database, you will lose any
features and functionalities specific to the Access 2002 version.

FO

To convert an Access 2002 to an Access 97 database:


Before any conversion, first you should create a backup copy of your Access database.
If the database is used in a multiple-user environment, make sure that all users have closed
the database.
Open the Access 2002 database.
If the database has password protection for the code, open the Visual Basic Editor first.
From the main menu, choose Tools > Macro > Visual Basic Editor
OR press the Alt + F11 key combination.
In the Visual Basic Editor, choose Tools > Database_name Properties from the main
menu:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Converting Access Databases


Access 2002 Advanced

101
2003 Cheltenham Courseware for Trainers

In the Project Properties dialog box, select the Protection tab and enter the password in
the Password field, then click OK:

Close the Visual Basic Editor to return to the Access window.


From the main menu, choose Tools > Database Utilities > Convert Database > To Access
97 File Format.
In the Convert Database Into dialog box, enter the database name in the File name field,
and then click on the Save button.

FO

TR

IN

IN

Converting from Access 2002 to Access 2000

Converting an Access 2002 database to an Access 2000 database


When converting an Access 2002 database to an Access 2000 database, you will lose any
features and functionalities specific to the Access 2002 version.

To convert an Access 2002 to an Access 2000 database:


Before any conversion, the first step is to create a backup copy of your Access database.
If the database is used in a multiple-user environment, make sure that all users have closed
the database.
Open the Access 2002 database.
If the database has password protection for the code, enter the password following the same
steps used in the Access 2002 to Access 97 conversion, as explained in the previous section.
From the main menu, choose Tools > Database Utilities > Convert Database > To Access
2000 File Format.
In the Convert Database Into dialog box, enter the database name in the File name field,
and then click the Save button.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

102
2003 Cheltenham Courseware for Trainers

Converting Access Databases


Access 2002 Advanced

Review Questions

FO

TR

IN

IN

How would you:


Convert Databases?
Convert Database Objects?
Enable Databases?
Share Databases across various Access versions?
Convert an Access 2002 database to an Access 97 database?
Convert an Access 2002 database to an Access 2000 database?

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Customizing Access 2002


Access 2002 Advanced

103
2003 Cheltenham Courseware for Trainers

FO

TR

IN

IN

When you have completed this learning module you will have seen how to:
Set Access 2002 Options
Set View Options
Set General Options
Set Edit/Find Options
Set Keyboard Options
Set Datasheet Options
Set Forms/Reports Options
Set Pages Options
Set Advanced Options
Set International Options
Set Spelling Options
Set Tables/Queries Options
Set AutoCorrect Options
Exclude AutoCorrect Rules
Remove AutoCorrect Rules
Add Replace AutoCorrect Rules
Remove Replace AutoCorrect Rules
Open Customize Dialog Box
Customize Toolbars
Create Custom Toolbars
Remove Toolbars
Customize Commands
Add Buttons to Toolbars
Remove Buttons from Toolbars
Customize Options

Customizing Access 2002

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

104
2003 Cheltenham Courseware for Trainers

Customizing Access 2002


Access 2002 Advanced

Configuring Access 2002 Options

FO

TR

IN

IN

Setting Access 2002 Options


Access 2002 allows you to customize the workplace by configuring many available options.
To access the options, choose Tools > Options from the main menu.
In the Options dialog box, you can find more information on each option by clicking on the
Help [?] button first:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Customizing Access 2002


Access 2002 Advanced

105
2003 Cheltenham Courseware for Trainers

The cursor will change to include the question mark, ?. Simply click on the option name or
option selection item (checkbox, radio button, drop-down list, etc):

Now you can read the information for the selected option:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

106
2003 Cheltenham Courseware for Trainers

Customizing Access 2002


Access 2002 Advanced

If you have made any changes to the current tab options, you can apply those changes by
clicking on the Apply button. Then you can click on another tab to view/change more
options.
Otherwise, you can click on the OK button to apply changes and close the Options dialog
box.

The Show group allows you to specify what features you will see when you startup Access
2002:
Status bar option shows or hides the status bar at the bottom of the screen.
Startup Task Pane option shows or hides the opening Access side pane.
New object shortcuts option shows or hides shortcuts in the Database window that you can
use to start a new database object. For example, in the Tables page, the shortcut named
Create table in Design view will create a table in the Design view.
Hidden objects option shows or hides objects in the Database window that have the Hidden
property. If shown, objects will appear as dimmed icons.
System objects option shows or hides system tables as dimmed icons.
Windows in Taskbar option shows a button on the Windows taskbar for every open
database object or window. You must have Internet Explorer Active Desktop feature installed
for this option to work.

FO

TR

IN

IN

Setting View Options


From the main menu, choose Tools > Options.
From the Options dialog box, click on the View tab:

The Show in Macro Design group allows you to change what you see while working with
macros:
Names column option displays the Macro Name column in a macro sheet.
Conditions column option displays the Condition column in a macro sheet.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Customizing Access 2002


Access 2002 Advanced

107
2003 Cheltenham Courseware for Trainers

The Click options in database window group controls how you work in the Database
window:
Single-click open option opens an object with single mouse click.
Double-click open option opens an object with a double mouse click. This is the default
setting.

The Print margins group allows you to change the margins compatible with your printer and
paper size: Left margin, Right margin, Top margin, and Bottom margin.
Recently used file list option specifies how many files are displayed when you choose File
from the main menu, or when the opening Task pane appears.
Provide feedback with sound option activates sound alerts.
Compact on Close option automatically compacts and repairs the database upon closing.
Remove personal information from this file option removes your name, company name or
any other personal information.
Default database folder option specifies the default folder where you will save new
databases.

FO

TR

IN

IN

Setting General Options


From the main menu, choose Tools > Options.
From the Options dialog box, click on the General tab:

The Use four-digit year formatting group allows you to apply the default format to This
database or All databases.

The Name AutoCorrect group allows you to correct any problems that occur when you make
changes in an object:
- Track name AutoCorrect info option stores the information it needs to correct naming
errors.
- Perform name AutoCorrect option repairs naming errors as they occur.
- Log name AutoCorrect changes option generates a log named AutoCorrect Log that
contains the changes.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

108
2003 Cheltenham Courseware for Trainers

Customizing Access 2002


Access 2002 Advanced

New database sort order option allows you to choose from a list of 15 languages that
change the default alphabetic sort order for new databases.

Web Options opens the dialog box where you can change the default Appearance for both
the Hyperlink color and the Followed hyperlink color. You can also specify if you want to
Underline hyperlinks:

TR

IN

IN

FO

Setting Edit/Find Options


From the main menu, choose Tools > Options.
From the Options dialog box, click on the Edit/Find tab:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Customizing Access 2002


Access 2002 Advanced

109
2003 Cheltenham Courseware for Trainers

The Default find/replace behavior group specifies the extent of the search:
Fast search option searches the current field only and matches the entire field.
General search option searches all the fields and matches any part of the field.
Start of field search option searches the current field and matches only the beginning
characters in the field.

The Confirm group displays the message requiring confirmation from the user:
Record changes option requires confirmation when a record changes.
Document deletions option requires confirmation when you delete a database object.
Action queries option requires confirmation when you run an action query.

The Filter by form defaults for [current database] Show list of values in group allows you
to limit or expand the size of the value list displayed in the Filter By Form window:
Local indexed fields option limits the value list to the indexed fields in the current database.
Local nonindexed fields option includes the non-indexed fields in the current database.
ODBC fields option includes fields in a linked table in an external source.
Dont display lists where more than this number of records read option sets the
maximum number of records to be used to generate the list of unique values for the field.

IN

IN

FO

TR

Setting Keyboard Options


From the main menu, choose Tools > Options.
From the Options dialog box, click on the Keyboard tab:

The Move after enter group controls what happens when you press the ENTER key:
Dont move option keeps the insertion point in the current field.
Next field option moves the insertion point to the next field.
Next record option moves the insertion point to the next record in the table or form.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

110
2003 Cheltenham Courseware for Trainers

The Behavior entering field group controls what happens when the insertion point enters
the field:
Select entire field option selects all of the characters in the field.
Go to start of field option moves the insertion point in front of the first character in the field
without selecting any characters.
Go to end of field option moves the insertion point to the end of the field after the last
character without selecting any characters.

IN

The Arrow key behavior group controls what happens when you press RIGHT ARROW and
LEFT ARROW keys:
Next field option moves the insertion point to the next field when you press the RIGHT
ARROW key or previous field when you press the LEFT ARROW key.
Next character option moves the insertion point to the next character when you press the
RIGHT ARROW key or to the previous character when you press the LEFT ARROW key.

IN

Customizing Access 2002


Access 2002 Advanced

Cursor stops at first/last field option locks the inserting point within the current record and
stops the RIGHT ARROW and LEFT ARROW keys from moving the insertion point.

FO

TR

Setting Datasheet Options


From the main menu, choose Tools > Options.
From the Options dialog box, click on the Datasheet tab:

The Default colors group allows you to change the colors of the following:
Font option specifies the font color. Default setting is Black.
Background option specifies the background color. Default setting is White.
Gridlines option specifies the gridlines color. Default setting is Silver.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Customizing Access 2002


Access 2002 Advanced

111
2003 Cheltenham Courseware for Trainers

The Default font group allows you to change the following:


Font option specifies font name. Default setting is Arial.
Weight option specifies font weight from Thin to Heavy. Default setting is Normal.
Size option specifies the font size from 8 to 72 points. Default setting is 10.
Underline option sets font style to underline.
Italic option sets font style to italic.

The Default gridlines showing group allows you to show or hide the following:
Horizontal option shows or hides the horizontal gridlines in the datasheet.
Vertical option shows or hides the vertical gridlines in the datasheet.
Default column width option specifies the width of the columns in a new datasheet.

The Default cell effect group specifies the cell effect from Flat, Raised or Sunken.

Show animations option shows movement in the datasheet.

IN

IN

FO

TR

Setting Forms/Reports Options


From the main menu, choose Tools > Options.
From the Options dialog box, click on the Forms/Reports tab:

Form template option specifies an existing form template for new designs.
Report template option specifies an existing report template for new designs.

Always use event procedures option takes you directly to the VB Editor window when you
click the Build button in the property sheet.

The Selection behavior group relates to the results of dragging a rectangle in the design
view to select controls.
Partially enclosed option selects all controls with any part within the drawn rectangle.
Fully enclosed option selects only controls fully within the drawn rectangle.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

112
2003 Cheltenham Courseware for Trainers

Customizing Access 2002


Access 2002 Advanced

The Default Database/Project Properties group controls the properties:


Use Default Page Folder option specifies the default page folder. If checked, enter the
folder to use as a default page folder.
Use Default Connection File option specifies the default connection file. If checked, enter
the ODC or Microsoft Data link to use as a default connection file.

The Default Designer Properties group controls the sections design:


Section Indent option specifies the default indent for each section.
Alternate Row Color option specifies the color to display in alternate rows of the group
header and footer sections.
Caption Section Style option specifies the default style for the caption section.
Footer Section Style option specifies the default style for the footer section.

FO

TR

IN

IN

Setting Pages Options


From the main menu, choose Tools > Options.
From the Options dialog box, click on the Pages tab:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Customizing Access 2002


Access 2002 Advanced

113
2003 Cheltenham Courseware for Trainers

Command-line arguments option specifies values you want the Command function to
return.
OLE/DDE timeout (sec) option specifies the time-period after which Access will re-attempt to
perform OLE or DDE operations.
Refresh interval (sec) option specifies the time-period for updating DDE links if Enable
DDE refresh option is checked. Enter a value between 1 and 32,766.
Number of update retries option specifies the number of times Access tries to save a
changed record locked by another user. Enter a value between 0 and 10.
ODBC refresh interval (sec) option specifies the time-period after which Access refreshes
records you are accessing through ODBC connection. Enter a value between 1 and 32,766.
Update retry interval (msec) option specifies the time-period after which Access tries to
save a changed record locked by another user. Enter a value between 0 and 1000.

The DDE operations group controls how the database interacts with other applications:
Ignore DDE requests option ignores Dynamic Data Exchange (DDE) requests from external
sources.
Enable DDE refresh option allows DDE links.

FO

TR

IN

IN

Setting Advanced Options


From the main menu, choose Tools > Options.
From the Options dialog box, click on the Advanced tab:

Default File Format option allows you to choose between Access 2000 and Access 2002 as
a default file format for new databases.

The Default open mode group allows you to choose how you work with the database on the
network:
Shared option allows others to open the database at the same time you have it opened.
Exclusive option gives you sole access to the database.
The Default record locking group allows you to choose how the database behaves while
shared on the network:
FOR USE AT THE LICENSED SITE(S) ONLY
Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

114
2003 Cheltenham Courseware for Trainers

Open databases using record-level locking option locks only one row or record instead of
locking an entire page that may have several records.

The Default direction group allows you to choose from two directions of the text:
Left-to-right option starts entering data in the left most column and places the next data in
the column to the right, etc.
Right-to-left direction option starts entering data in the right most column and places the
next data in the column to the left, etc.

FO

TR

IN

Setting International Options


From the main menu, choose Tools > Options.
From the Options dialog box, click on the International tab:

No locks option does not lock records while they are being edited.
All records option locks records in a form or datasheet as long as the form or datasheet is
open.
Edited record option locks only the record currently being edited.

IN

Customizing Access 2002


Access 2002 Advanced

The General alignment group gives you a choice between two modes:
Interface mode option sets General alignment consistent with the user interface language.
For example, if the direction is left-to-right, the text is left-aligned.
Text mode option sets General alignment according to the direction of the first languagespecific characters it encounters.

The Cursor movement group controls the cursor moves within bidirectional text that has
various languages in the same sentence:
Logical option moves cursor within bidirectional text according to the direction of the
language it is encountering. For example, for English words the insertion point moves left-toright, for Arabic words the insertion point moves right-to-left.
Visual option moves cursor within bidirectional text by moving to the next adjacent character.

Use Hijri Calendar option to change the setting to the Middle Eastern calendar.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Customizing Access 2002


Access 2002 Advanced

115
2003 Cheltenham Courseware for Trainers

The Language-specific group options are specific and apply to different languages.
AutoCorrect Options will be discussed later in this manual.

Dictionary Language option specifies the language. English (U.S.) is default.


Add words to option specifies the dictionary file to add words to.
Suggest from main dictionary only option tries to suggest corrections only from the main
dictionary. If you want the spell check to use the custom dictionary as well, uncheck this
option.
Ignore words in UPPERCASE option ignores uppercase words while spellchecking.
Ignore words with numbers option ignores words with numbers while spellchecking.
Ignore Internet and file addresses option ignores internet or file addresses while
spellchecking.

FO

TR

IN

IN

Setting Spelling Options


From the main menu, choose Tools > Options.
From the Options dialog box, click on the Spelling tab:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

116
2003 Cheltenham Courseware for Trainers

Customizing Access 2002


Access 2002 Advanced

The Query design area includes:


Show table names option displays the table names in the Table row of the query grid.
Output all fields option displays all the fields in a querys underlying tables and queries
when you run the query.
Enable AutoJoin option automatically creates an INNER JOIN between two tables in the
query grid if they have fields with the same name and same data type, and one of these
fields is the primary key field for its table.

The Table design area includes:


The Default field sizes group specifies the size for the Text data type fields, and the size for
the Number data type fields.
Default field type option sets the default data type.
AutoIndex on Import/Create option sets automatic indexing for all fields that start or end
with the characters typed in this option box.

FO

TR

IN

IN

Setting Tables/Queries Options


From the main menu, choose Tools > Options.
From the Options dialog box, click on the Tables/Queries tab:

The Run permissions group specifies if others are permitted to view data retrieved by
queries or to run action queries:
Owners option allows all users to view or run the query, but only the owner can edit query.
Users option applies the permissions defined for that classification of user.

The SQL Server Compatible Syntax (ANSI 92) group formats queries exclusively in ANSI
92 standard syntax:
This Database option applies formatting for the current database.
Default for new databases option applies formatting for all new databases.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Customizing Access 2002


Access 2002 Advanced

117
2003 Cheltenham Courseware for Trainers

Configuring AutoCorrect Options


Setting AutoCorrect Options
AutoCorrect options will automatically correct misspelled words as you type.
From the main menu, choose Tools > AutoCorrect Options.

This will open the AutoCorrect dialog box:

The AutoCorrect options are self-explanatory.


Exceptions are covered later in this section.
Replace With options are covered later in this section.

IN

From the main menu, choose Tools > Options.


From the Options dialog box, click on the Spelling tab.
Click on the AutoCorrect Options button.

FO

TR

IN

OR

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

118
2003 Cheltenham Courseware for Trainers

Customizing Access 2002


Access 2002 Advanced

IN

IN

Excluding AutoCorrect Rules


The Exceptions button opens the AutoCorrect Exceptions dialog box.
Click on the First Letter tab:

In the Dont capitalize after field, type the abbreviation with the period at the end.
Click on the Add button to add this rule.

Click on the INitial CAps tab:

FO

TR

In the Dont correct field, type the word you want to add.
Click on the Add button to add this rule.

Removing AutoCorrect Rules


The Exceptions button opens the AutoCorrect Exceptions dialog box.
In the First Letter tab, or the INitial CAps tab, select the rule you want to delete.
Click on the Delete button to remove the rule.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Customizing Access 2002


Access 2002 Advanced

119
2003 Cheltenham Courseware for Trainers

In the Replace field, type a commonly misspelled word, or a word you want to use as a
shortcut to generate another word or symbol.
In the With field, type the correctly spelled word, or the wanted word or symbol.
Click Add button.
Click OK to close the AutoCorrect dialog box.

TR

IN

IN

Adding Replace AutoCorrect Rules


When you check the Replace text as you type option, you can specify what words you can
replace with correct words:

FO

Removing Replace AutoCorrect Rules


Select the rule you want to remove.
Click on the Delete button:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

120
2003 Cheltenham Courseware for Trainers

Customizing Access 2002


Access 2002 Advanced

Customizing Menus and Toolbars

IN

IN

Opening Customize Dialog Box


From the main menu, choose View > Toolbars > Customize
OR from the main menu, choose Tools > Customize
OR right-click anywhere on the toolbar or menu bar and select Customize from the popup
menu:

FO

TR

Customizing Toolbars
Using any of the methods described above open the Customize dialog box.
Click on the Toolbars tab:

This will list all available Toolbars, both built-in and custom.
Check the check box for any toolbar you want displayed.
Uncheck the check box for any toolbar you want to hide.
Click Close when done.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Customizing Access 2002


Access 2002 Advanced

121
2003 Cheltenham Courseware for Trainers

IN

Creating Custom Toolbars


Using any of the methods described above open the Customize dialog box.
Click on the Toolbars tab.
Click on the New button:

This will open the New Toolbar dialog box:

Type the Toolbar name and click OK.


You will notice that a new, empty toolbar appears in addition to the Customize dialog box,
and that the new toolbar will appear in the Toolbars list:

FO

TR

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

122
2003 Cheltenham Courseware for Trainers

Customizing Access 2002


Access 2002 Advanced

Make sure that the new toolbar is selected, and click the Properties button:

This will open the Toolbar Properties dialog box:

FO

TR

IN

IN

Toolbar Name option displays the name of the toolbar. You can edit the name here.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Customizing Access 2002


Access 2002 Advanced

123
2003 Cheltenham Courseware for Trainers

Type option allows you to choose what type of custom bar you want to create:
Menu Bar
Toolbar
Popup

Docking option specifies what kind of docking is allowed for this custom bar:
Allow Any
Cant Change
No Vertical
No Horizontal

Show on Toolbars Menu option displays the toolbar name in the list or popup menu.
Allow Customizing option allows changes to the toolbars appearance or behavior.
Allow Resizing option allows resizing of the floating toolbar.
Allow Moving option allows moving the toolbar between the floating and docked position.
Allow Showing/Hiding option allows showing or hiding the toolbar using these methods:
- Right-click a toolbar and check or clear the toolbar name in the popup menu.
- From the main menu, choose View > Toolbars and check or clear the toolbar name in the
list.
- Check or clear the toolbar name in the Customize dialog box, under the Toolbars tab.

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

124
2003 Cheltenham Courseware for Trainers

Customizing Access 2002


Access 2002 Advanced

TR

IN

IN

Removing Toolbars
Using any of the methods described above open the Customize dialog box.
Click on the Toolbars tab.
Select the toolbar you want to remove and click on the Delete button:

FO

Customizing Commands
Once you created a new toolbar, you can add Commands and/or buttons to it.
Use any of the methods described above to open the Customize dialog box.
Click on the Commands tab:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Customizing Access 2002


Access 2002 Advanced

Choose the category you want under the Categories list.


Choose the command you want under the Commands list. To find more information about
the command, click on the Description button.

Drag the button toward the toolbar until the cursor changes to the plus sign +:

FO

TR

IN

IN

Adding Buttons to Toolbars


Under the Commands list, click on the button you want to add to the toolbar.
The cursor will change into an x:

125
2003 Cheltenham Courseware for Trainers

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

126
2003 Cheltenham Courseware for Trainers

You will see a new button on the toolbar:

TR

IN

IN

Customizing Access 2002


Access 2002 Advanced

FO

Removing Buttons from Toolbars


With the Customize dialog box open, drag the button of the toolbar:

OR right-click on the button and choose Delete from the popup menu:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Customizing Access 2002


Access 2002 Advanced

127
2003 Cheltenham Courseware for Trainers

TR

IN

IN

Customizing Options
Using any of the methods described above open the Customize dialog box.
Click on the Options tab:

The Personalized Menus and Toolbars group allows you to customize your work with
Menus and Toolbars:
Show Standard and Formatting toolbars on two rows option displays the two default
toolbars on two rows when available.
Always show full menus option displays all commands on menus.
Show full menus after a short delay option displays the most used commands first. If you
rest the mouse pointer over the menu, it expands to show all commands.
Reset my usage data clears all automatically saved menu and toolbar settings
The Other group allows you to customize how command bars look and behave:
Large icons option displays larger button images.
List font names in their font option displays the drop-down list of fonts in their own font.
Show ScreenTips on toolbars option displays the name of the button when the mouse
pointer rests over the button.
Show shortcut keys in ScreenTips option displays the shortcut key combination with the
button name in the ScreenTip.
Menu animations option specifies whether or not menus are animated when displayed.

FO

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

128
2003 Cheltenham Courseware for Trainers

Customizing Access 2002


Access 2002 Advanced

IN
IN
A

FO

TR

How would you:


Set Access 2002 Options?
Set View Options?
Set General Options?
Set Edit/Find Options?
Set Keyboard Options?
Set Datasheet Options?
Set Forms/Reports Options?
Set Pages Options?
Set Advanced Options?
Set International Options?
Set Spelling Options?
Set Tables/Queries Options?
Set AutoCorrect Options?
Exclude AutoCorrect Rules?
Remove AutoCorrect Rules?
Add Replace AutoCorrect Rules?
Remove Replace AutoCorrect Rules?
Open Customize Dialog Box?
Customize Toolbars?
Create Custom Toolbars?
Remove Toolbars?
Customize Commands?
Add Buttons to Toolbars?
Remove Buttons from Toolbars?
Customize Options?

Review Questions

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Managing and Maintaining Access Databases


Access 2002 Advanced

129
2003 Cheltenham Courseware for Trainers

The Table Analyzer helps you optimize a database by reducing data redundancy using a set
of related tables, suggesting additional optimization, adding more indexes, etc.

IN

Optimizing Databases with Table Analyzer

IN

When you have completed this learning module you will have seen how to:
Use the Table Analyzer
Rename Tables
Add Key Fields
Use the Performance Analyzer
Use the Documenter Analyzer
Print Documentation
Export Documentation

Analyzing Access Databases

FO

TR

Using the Table Analyzer


From the main menu, choose Tools > Analyze > Table.
This will open the Table Analyzer Wizard dialog box:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

130
2003 Cheltenham Courseware for Trainers

The first page of the wizard gives an introduction on how the Table Analyzer looks at the
problem. You can also click on the Show me an example buttons to view an example. Click
Next to continue.
The second page of the wizard gives an introduction on how the Table Analyzer solves the
problem. You can also click on the Show me an example buttons to view example. Click
Next to continue:

TR

IN

IN

Managing and Maintaining Access Databases


Access 2002 Advanced

The next page of the wizard allows you to select which Tables you want to analyze. To skip
the introductory pages of the wizard next time you run the Table Wizard, you should uncheck
the Show introductory pages option. Click Next to continue:

FO

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Managing and Maintaining Access Databases


Access 2002 Advanced

131
2003 Cheltenham Courseware for Trainers

The next page of the wizard allows you to decide how to split up the data. You can let wizard
decide, or you can decide. Click Next to continue:

If you select the wizard to make a decision you might see the message containing the
wizards recommendation:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

132
2003 Cheltenham Courseware for Trainers

Managing and Maintaining Access Databases


Access 2002 Advanced

The next page of the wizard represents a diagram of the suggested redistribution of
information:

You can see more instructions on how to handle the wizards suggestions by clicking the
Tips button:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Managing and Maintaining Access Databases


Access 2002 Advanced

133
2003 Cheltenham Courseware for Trainers

Read the Tips instructions to help you implement the wizards suggestions:

The wizard suggests that you create a Lookup Table for each field with a link from the
original Employees table (Table1) to Table2 and Table3:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

134
2003 Cheltenham Courseware for Trainers

Managing and Maintaining Access Databases


Access 2002 Advanced

TR

IN

IN

Renaming Tables
Once you approve the table structures, you have to Rename the proposed tables. Select
each table and click on the Rename Table button:

Enter the new Table Name and click OK:

When you finish renaming tables, click on Next to continue.

FO

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Managing and Maintaining Access Databases


Access 2002 Advanced

135
2003 Cheltenham Courseware for Trainers

TR

IN

IN

Adding Key Fields


The next page of the wizard allows you to verify the primary key fields. Wizard adds the
Generated Unique ID primary key fields for newly generated tables. The original table does
not have the primary key.
If there is a field that can be used as a primary key, select that field in the table and click on
the Set Unique Identifier button:

The field is now a primary key, marked with the key icon:

FO

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

136
2003 Cheltenham Courseware for Trainers

Managing and Maintaining Access Databases


Access 2002 Advanced

To undo the change, select the field and click on the Undo button:

If there is no field in the table that can be used as a primary key, you can assign a generated
key. Select the table without a primary key and click on the Add Generated Key button:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Managing and Maintaining Access Databases


Access 2002 Advanced

137
2003 Cheltenham Courseware for Trainers

The generated primary key field is added, marked with the key icon:

After adding primary key fields, click on Next to continue.


On the final page, the wizard offers to create a query for you that looks like your original table
and has the same name. Letting the wizard create a query ensures that you can continue to
work with all the forms and reports created using the original table. Click Finish to close the
wizard:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

138
2003 Cheltenham Courseware for Trainers

Managing and Maintaining Access Databases


Access 2002 Advanced

Optimizing Databases with Performance Analyzer

The Performance Analyzer helps you optimize a database by analyzing all objects in the
database and suggesting ways you can improve the database performance.

Select the appropriate tab, or click on the All Object Types tab to list all database objects.
Check the check box besides the object(s) you want to analyze and click the OK button:

FO

TR

IN

IN

Using the Performance Analyzer


From the main menu, choose Tools > Analyze > Performance.
The Performance Analyzer dialog box opens, containing tabs for each type of database
object:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Managing and Maintaining Access Databases


Access 2002 Advanced

139
2003 Cheltenham Courseware for Trainers

To analyze the entire database, click on the All Object Types tab and click on the Select All
button to check all objects. Click OK to start analyzer:

A Performance Analyzer message box displays the analyzing process:

At the end of the process, the Performance Analyzer displays the Analysis Results:

FO

TR

IN

IN

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

140
2003 Cheltenham Courseware for Trainers

Key icons specify what kind of information is contained in the finding list: Recommendation,
Suggestion, Idea or Fixed.
Analysis Notes pane describes the results for the selected list item.
If there are any Recommendations, you can click on the Optimize button to implement
analyzers recommendations.
Click Close to close the Performance Analyzer.

Managing and Maintaining Access Databases


Access 2002 Advanced

IN

Documenting Databases with Documenter Analyzer

The Documenter Analyzer helps you document databases, which is one of most important
tasks in a database management system.

Check the objects from each tab you want documented, or click the All Object Types tab
and click on the Select All button to document the whole database.
Click on the Options button.

FO

TR

IN

Using the Documenter Analyzer


From the main menu, choose Tools > Analyze > Documenter.
The Documenter dialog box opens, containing tabs for each type of database object:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Managing and Maintaining Access Databases


Access 2002 Advanced

141
2003 Cheltenham Courseware for Trainers

This will open the Print Table Definition dialog box:

The Include for Table group allows you to limit what table elements you want to print:
Properties
Relationships
Permissions by User and Group.

The Include for Fields Table group allows you to limit what field information you want to
print:
Nothing
Names, Data Types, and Sizes
Names, Data Types, Sizes, and Properties

The Include for Indexes group allows you to limit what index information you want to print:
Nothing
Names and Fields
Names, Fields, and Properties

FO

TR

IN

IN

Click OK twice to start the Documenter.


The Status Bar displays the analysis progress.

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

142
2003 Cheltenham Courseware for Trainers

Managing and Maintaining Access Databases


Access 2002 Advanced

FO

TR

IN

IN

Printing Documentation
The report is opened in Print Preview:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Managing and Maintaining Access Databases


Access 2002 Advanced

Right-click on the report to open the popup menu where you can configure Page Setup and
other print options:

IN

IN

143
2003 Cheltenham Courseware for Trainers

FO

TR

Exporting Documentation
Once you have generated the report you can export the documentation data.
Right-click on the report to open the popup menu and select the Export option
OR from the main menu, choose File > Export.
This will open the Export Report dialog box were you can select the location, file name and
file type for export:

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

144
2003 Cheltenham Courseware for Trainers

Managing and Maintaining Access Databases


Access 2002 Advanced

A Printer message box displays the exporting process:

IN

IN

You can save the report in various Excel, HTML Document, Text File, Rich Text Format,
Snapshot Format and XML Document formats.
Once you select the type under the Save as type field, click on the Export button:

FO

How would you:


Use the Table Analyzer?
Rename Tables?
Add Key Fields?
Use the Performance Analyzer?
Use the Documenter Analyzer?
Print Documentation?
Export Documentation?

TR

Review Questions

FOR USE AT THE LICENSED SITE(S) ONLY


Cheltenham Courseware for Trainers 1995-2003 - www.cctglobal.com

Das könnte Ihnen auch gefallen