37965
37965
https://ebookultra.com
https://ebookultra.com/download/access-2007-vba-
bible-for-data-centric-microsoft-office-
applications-1st-edition-helen-feddema/
https://ebookultra.com/download/microsoft-office-sharepoint-
designer-2007-bible-1st-edition-vikram-kartik/
ebookultra.com
https://ebookultra.com/download/mastering-vba-for-microsoft-
office-2010-2nd-ed-edition-mansfield/
ebookultra.com
https://ebookultra.com/download/access-2007-vba-programming-for-
dummies-1st-edition-joseph-c-stockman/
ebookultra.com
https://ebookultra.com/download/microsoft-sharepoint-2007-for-
office-2007-users-1st-edition-martin-reid/
ebookultra.com
Office 2007 Bible 1st Edition John Walkenbach
https://ebookultra.com/download/office-2007-bible-1st-edition-john-
walkenbach/
ebookultra.com
https://ebookultra.com/download/microsoft-office-2007-timothy-j-
oleary/
ebookultra.com
https://ebookultra.com/download/access-2007-vba-programmer-s-
reference-1st-edition-teresa-hennig/
ebookultra.com
https://ebookultra.com/download/microsoft-access-data-analysis-
michael-alexander/
ebookultra.com
https://ebookultra.com/download/microsoft-office-2007-vista-edition-
timothy-j-oleary/
ebookultra.com
Access 2007 VBA bible for data centric Microsoft Office
applications 1st Edition Helen Feddema Digital Instant
Download
Author(s): Helen Feddema
ISBN(s): 9780470047026, 047004702X
Edition: 1
File Details: PDF, 23.35 MB
Year: 2007
Language: english
Access 2007 ™
VBA Bible
®
For Data-Centric Microsoft Office Applications
Helen Feddema
Access 2007 VBA Bible
™
Access 2007 ™
VBA Bible
®
For Data-Centric Microsoft Office Applications
Helen Feddema
Access™ 2007 VBA Bible: For Data-Centric Microsoft® Office Applications
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2007 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-04702-6
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of
the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through
payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923,
(978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal
Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355,
or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or
promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold
with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If
professional assistance is required, the services of a competent professional person should be sought. Neither the publisher
nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is referred to in this
work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses
the information the organization or Website may provide or recommendations it may make. Further, readers should be
aware that Internet Websites listed in this work may have changed or disappeared between when this work was written
and when it is read.
For general information on our other products and services or to obtain technical support, please contact our Customer
Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002.
Library of Congress Cataloging-in-Publication Data:
Feddema, Helen Bell.
Access 2007 VBA Bible: For Data-Centric Microsoft Office Applications / Helen Feddema.
p. cm.
Includes index.
ISBN 978-0-470-04702-6 (paper/website)
1. Microsoft Access. 2. Database management. 3. Microsoft Visual Basic for applications. I. Title.
QA76.9.D3F435 2007
005.75’65--dc22
2007007061
Trademarks: Wiley, the Wiley logo, and related trade dress are trademarks or registered trademarks of John Wiley & Sons,
Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission.
Microsoft and Access are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other
countries. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with
any product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in
electronic books.
About the Author
Helen Feddema is an independent developer specializing in Microsoft Office applications, concen-
trating on Access, Word, and (since 1996) Outlook. She has written or co-authored many books
on Access and other Office applications, including Inside Microsoft Access (New Riders, 1992),
Power Forms for Microsoft Access and Power Reports for Microsoft Access (Pinnacle, 1994), Access How-
Tos (Waite Group Press, 1995), MCSD: Access 95 Study Guide (Sybex, 1998), DAO Object Model: The
Definitive Guide (O’Reilly, January 2000), and Access 2002 Inside-Out (Microsoft Press, 2001), which
was judged #1 in the Desktop and Office Applications book category at the Waterside 2004 confer-
ence. Her most recent book is Expert One-on-One Microsoft Access Application Development
(Wiley/Wrox, 2003).
She has also contributed chapters to a number of multi-author Office books, including Special
Edition: Using Microsoft Outlook 97 (Que, 1997), Office Annoyances (O’Reilly, 1997), Outlook
Annoyances (O’Reilly, 1998), Special Edition: Using Microsoft Project 98 (Que, 1997), Teach Yourself
Project (Sams, 1998), and Special Edition: Outlook 2000 (Que, 2000). Helen has been a regular con-
tributor to Pinnacle’s Smart Access and Office Developer journals, Informant’s Microsoft Office and
VBA Programming (now Office Solutions), and Woody’s Underground Office newsletter, and she is cur-
rently the editor of the Access Watch ezine (formerly Woody’s Access Watch), for which she writes the
Access Archon column.
To Kerry and Jean King, good neighbors and good friends
Credits
Executive Editor Project Coordinator
Bob Elliott Adrienne Martinez
vii
Contents
viii
Contents
ix
Contents
x
Contents
xi
Contents
Chapter 17: Creating Standalone Scripts with Windows Script Host . . . . 591
Tools for Working with Windows Script Host Scripts ........................................................591
The Microsoft Script Editor ....................................................................................592
The VBScript Help File ............................................................................................597
Differences between VBA and VBScript Code ....................................................................599
Useful Scripts ....................................................................................................................603
Setup Scripts ..........................................................................................................603
Office Scripts ..........................................................................................................611
Miscellaneous Scripts ..............................................................................................616
Scheduling a Backup Script with the Windows Vista Task Scheduler ................................619
Summary ..........................................................................................................................626
Chapter 18: Working with SQL Server Data . . . . . . . . . . . . . . . . . 627
Getting SQL Server 2005 ..................................................................................................628
Preparing an Access Database for Upsizing to SQL Server ................................................629
Configuring SQL Server 2005 for Data Access ..................................................................631
Getting through the Firewall....................................................................................640
Windows XP..................................................................................................640
Windows Vista ..............................................................................................643
Other Security Roadblocks ......................................................................................647
Using the Upsizing Wizard................................................................................................648
Converting Access Tables to SQL Server Tables ......................................................649
Creating a Client/Server Application........................................................................657
Linking to Data in SQL Server Tables ................................................................................662
The SQL Server Migration Assistant for Access..................................................................671
Summary ..........................................................................................................................672
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673
xii
M
any thanks to my technical editor, Mary Hardy, for catching errors and making many
valuable suggestions that improved the quality of the book (and sample databases), and
to editors Kelly Talbot and Brian Hermann for their suggestions and support.
xiii
W
elcome to the Access 2007 VBA Bible. Like all books in the Bible series, you can expect
to find both hands-on tutorials and real-world practical application information, as
well as reference and background information that provides a context for what you are
learning. This book is a fairly comprehensive resource on writing VBA code to exchange data
among the main Office applications (Access, Word, Excel, and Outlook), using Access as the cen-
tral application for storing data, and using the other applications for producing attractively format-
ted documents of various types. By the time you have completed the Access 2007 VBA Bible, you
will be well-prepared to write VBA Automation code that uses your Access data to produce Word
letters, mailing labels and other documents (without the overhead of mail merge), to create Excel
worksheets and PivotCharts, and to create Outlook appointments, mail messages, contacts, and
journal items, with or without attachments. Additionally, you will be able to synchronize contact
data (both ways) between Access and Outlook.
In Part II, more specific coverage is provided for each Office component, with sample databases
that illustrate working with Access data, Word documents and templates, Excel worksheets, and
Outlook items. This part also includes a chapter on working with files and folders using the
FileSystemObject, and another on synchronizing Access contacts with Outlook contacts. This
allows you to maintain your contacts in a set of properly normalized linked tables in Access, while
also having the ability to reference and use Outlook contacts, without having to do dual entry or
manually update contact information. Finally, the last chapter in the part deals with several
advanced topics, working with Word and Excel objects.
xv
Introduction
Part III covers topics that add more functionality to Office, including the creation of COM add-ins
with VB 6, Access add-ins, and Visual Studio 2005 Shared add-ins. It also covers customizing the
Office 2007 Ribbon with XML in Access databases and with add-ins of various types. Additionally,
there is a chapter on creating standalone scripts with Windows Script Host, and another chapter
on using Access as a front end for working with SQL Server data.
Whenever the authors want to bring something important to your attention, the information will
appear in a Tip, Note, or Caution.
This information is important and is set off in a separate paragraph with a special icon.
CAUTION Cautions provide information about things to watch out for, whether simply inconve-
nient or potentially hazardous to your data or systems.
Tips generally are used to provide information that can make your work easier—special
TIP shortcuts or methods for doing something easier than the norm.
Notes provide additional, ancillary information that is helpful, but somewhat outside of
NOTE the current presentation of information.
New features introduce components or functionality that are new or improved in the
NEW FEATURE software compared to earlier versions.
Minimum Requirements
To run the sample code in this book, you need a computer capable of running at least Windows
XP, and of course you need Office 2007. Because Office 2007 runs fine on Windows XP, you don’t
need Windows Vista, but Office 2007 works even better on Vista. If you intend to run Vista, you
need a Vista-ready computer. If you buy a new computer, look for the “Windows Vista Capable”
sticker; however, an older computer may support Vista even if it doesn’t have the sticker (though
probably not the Aero Glass interface, which requires a high-powered video card).
xvi
Introduction
My web site (www.helenfeddema.com) has pages with code samples and Access Archon articles,
many of which deal with exchanging various types of data among Office applications. Check them
out—you may find that the solution you are looking for is already there, ready to download and use.
xvii
The Office
Components and
What They Do Best
IN THIS PART
Chapter 1
Storing and Displaying Data in
Access
Chapter 2
Creating Word Documents from
Access
Chapter 3
Analyzing Data with Excel
Chapter 4
Organizing and Communicating
with Outlook
Storing and Displaying
Data in Access
S
ince its earliest days — about 14 years ago — Access has been a rela-
tional database program, storing data in tables and using its own
IN THIS CHAPTER
queries, forms, and reports to sort, filter, display, and print data. With A brief history of Office data
successive Office versions, moving data among Office components (espe- exchange
cially Word, Excel, and Outlook) has become so much easier that it is now
often more efficient to use another Office component rather than an Access Storing data in Access
report for a task such as printing letters or analyzing numeric data.
Displaying Access data in forms
and reports
Additionally, using other Office components to display or print data from
Access makes the data stored in Access tables more widely accessible. Many Working with rich text in
Office users have an edition of Office that doesn’t include Access — but they Memo fields
all have Word and Excel, and many also have Outlook, so they can easily
work with Word documents, Outlook messages or appointments, and Excel New report interactivity
worksheets, filled with data from Access tables.
Using Access as a control
Whether you plan to present your data as an Access report, PivotChart, or center for working with
PivotTable; or a Word document or Excel worksheet, the data is stored in Office documents
Access tables, and entered and edited in Access forms.
3
Part I The Office Components and What They Do Best
called Object Linking and Embedding [OLE], then OLE Automation) and Extensible Markup
Language (XML).
In early Windows and Office versions, DDE and ODBC were difficult to use, cranky and unreliable
in operation, and ODBC in particular often required elaborate setup. I know — I used both DDE
and ODBC, when they were the only connectivity tools available. But I gladly dropped them when
OLE became available in Windows 95/Office 95, because it offered a much simpler way to connect
Office applications, though at first only in a limited manner.
Before Office 97, there was a distinction between Office components that were OLE servers, which
could be manipulated by code running from other applications, and OLE clients, which could
work with objects in OLE server applications’ object models. Back in the days of Access 1.0 or
even 2.0, Access developers had few tools available for connecting to other Office applications
such as Word or Excel. Access, for example, was only a client, whereas Word was only a server.
In Office 95 AccessBasic was upgraded to standard Office VBA, and Access became an OLE server
(previously it was only an OLE client). By Office 2000, all the major Office applications (Access,
Word, Excel, Outlook, and PowerPoint) had been upgraded to support Automation both as clients
and servers, so the OLE server/client distinction is no longer significant.
You can write Automation code in any major Office application to connect to any other Office
application’s data and functionality (and some third-party applications as well).
One valid exception is storing data in SQL Server back-end databases, using Access as
CROSS-REF the front end. SQL Server is usually the choice for huge corporate databases, not small-
to medium-sized databases used by individuals or small companies, where Access can easily handle
the number of records. See Chapter 18 for more information on this option.
Data entry and editing, too, should be done in Access, for the most part, because you can create
Access forms that offer an attractive interface for entering and editing data. You can write VBA code
that runs from form and control events for purposes of error handling, and create functions that
automate repetitive data-processing operations.
4
Storing and Displaying Data in Access 1
Over the years, Access forms and reports have been significantly upgraded. In Access
NEW FEATURE 2007, one long-requested feature has finally arrived in a workable form (I recall an
early and unreliable implementation that made a brief appearance in Access 95). Memo fields can
now store and display rich text, using the Text Align property, which takes a value of either Plain Text
or Rich Text. When you select Rich Text for this property, you can apply various fonts, colors, and
other attributes to selected portions of text in a table field or a control bound to that field.
In earlier versions of Office, if you wanted to generate a letter or other document including a block
of text with color, bolding, or other attributes applied to selected words or phrases within the
block, you had to create a Word letter and use Word’s formatting features. In Access 2007, you
can produce Access reports with varied formatting within text blocks, displaying text entered into
Access memo fields in a textbox on a form.
FIGURE 1.1
Creating a Memo field to hold Rich Text data.
5
Part I The Office Components and What They Do Best
If you select a block of text in a Rich Text–enabled Memo field, you will see a floating
WARNING toolbar that lets you apply some formatting, including indenting or outdenting, similar
to Word (this works fine; see Figure 1.2). However, if you apply bullets or numbering from this tool-
bar, you will get the bullets or numbers, but the text that runs over one line won’t be indented prop-
erly, as shown in Figure 1.3. For this reason, I recommend against using these features, unless all the
items on your lists are no more than one line in length.
FIGURE 1.2
Indenting text from the floating toolbar in a Rich Text field.
FIGURE 1.3
Incorrect indentation of an item in a numbered list in a Rich Text field.
Create a form bound to the table with the Memo field; you can now enter data into this textbox
control and format it with different fonts, color, bolding, and other attributes, as you would while
working in a Word document. When you place the cursor into a control with Rich Text enabled, a
formatting group on the Form Ribbon is enabled, with a variety of formatting selections, as shown
in Figure 1.4.
Figure 1.5 shows the form with a variety of formatting attributes applied to the text in the textbox.
6
Storing and Displaying Data in Access 1
FIGURE 1.4
Selecting formatting for a portion of text in a Rich Text–enabled textbox on a form.
FIGURE 1.5
A Rich Text–enabled textbox with a variety of formatting applied to portions of its text.
7
Part I The Office Components and What They Do Best
Once you have applied formatting to the text on a form, you can create a report based on the table,
and the formatting will display on the report as well (see Figure 1.6).
FIGURE 1.6
A report showing Rich Text formatting applied in a textbox on a form.
You can copy and paste formatted text from a Word document into a Memo field with
TIP Rich Text enabled (or a textbox bound to such a field), and the formatting will be pre-
served. However, bullets and numbered lists won’t be aligned correctly, so it is best to turn off those
features before copying text to Access.
I also created a one-row table to hold information to use in the database; in this case, it has
two Rich Text–enabled Memo fields for the letter header and signature information. The form
fdlgSelectLetter (bound to the information table, zstblInfo) lets you edit the header and signature
(Figure 1.8) and select a letter type and a contact.
8
Storing and Displaying Data in Access 1
FIGURE 1.7
A table with formatted letter body text.
FIGURE 1.8
A dialog form for editing header and signature block information and selecting a letter and contact.
9
Part I The Office Components and What They Do Best
Clicking the Create Letter button opens a filtered Access report displaying name and address data
from the selected Contact record, and the letter body from the selected letter type, as depicted in
Figure 1.9.
With Rich Text formatting now supported in Access forms and reports, you may not need to pro-
duce a Word letter to get the look you want in printed documents. However, compared with Word,
Access reports using Rich Text–enabled Memo fields have one significant limitation. In Word, you
can place merge fields or DocProperty fields within a block of text, so that merged data or data
stored in document properties will print at a certain point in the text, with the surrounding text
wrapping as needed, depending on the length of the text in the fields. This is not possible with a
Memo field on an Access report, so if you need to embed merge fields or DocProperty fields within
the letter body text, you still need to create Word documents.
See Chapter 2 for information on creating Word documents of various types filled with
CROSS-REF Access data.
FIGURE 1.9
A report with formatted text.
10
Storing and Displaying Data in Access 1
I first realized what a problem it is to work in a database with no naming convention when I took
over a database created by another programmer. The database had a table, a query, a form, a
report, a function, and five or six variables (of different data types) all called Sales (this was only one
of a number of sets of objects with the same name). This meant that when I encountered the word
“Sales” in VBA code, I had no idea whether it was a reference to a table, form, query, function, or
variable, unless the context made it clear. There were numerous errors because of the use of the
same name for different types of objects, because (among other possible sources of errors) you can
set the value of a field with a variable, or with a function — and if several variables and a function
are all called Sales, the code may use the wrong one.
You can also get circular reference errors when a control has the same name as the field to which it
is bound — which is still the case in Access 2007, when you create a form bound to a table using the
Form Wizard. To prevent these reference errors, it is an excellent idea to use a naming convention for
database objects, controls, and variables. Using a naming convention also makes your database self-
documenting (to some extent, at least), and prevents confusion when selecting an object from a
drop-down list.
About 10 years ago, I wrote an Access 97 add-in (LNC Rename.mda) to automate the process of giv-
ing the appropriate tags to database objects and controls on forms and reports, using the Leszynski
Naming Convention (LNC). This add-in was updated for Access 2000, and that version still works in
Access 2007; it is available as Code Sample #10 (for Access 2000 or higher databases) from the
Code Samples page of my web site, www.helenfeddema.com.
11
Part I The Office Components and What They Do Best
FIGURE 1.10
Selecting the Report Wizard to create a report.
Select the fields to include on the report (see Figure 1.11) and click Next.
FIGURE 1.11
Selecting fields for a report.
12
Storing and Displaying Data in Access 1
On the next screen of the wizard (see Figure 1.12), select the top-level grouping you want for the
report (in this case, I accepted the default selection of OrderQuarter, Customer, OrderDate).
FIGURE 1.12
Selecting a major grouping level for a report.
The next screen lets you select sub-groups, if desired; I accepted the default (no further sub-
grouping, as shown in Figure 1.13).
FIGURE 1.13
Select sub-grouping levels for a report.
13
Part I The Office Components and What They Do Best
Next, select sorting and summarizing options; I selected ProductName for sorting, as shown in
Figure 1.14.
FIGURE 1.14
Selecting sorting and summarizing options for a report.
On the report layout screen, depicted in Figure 1.15, I selected the Block option.
FIGURE 1.15
Selecting the Block report layout option.
14
Storing and Displaying Data in Access 1
Select a style on the next screen, shown in Figure 1.16 (bear in mind that some of the more artistic
styles won’t look good when printed on a black-and-white printer). I selected None for a plain report.
FIGURE 1.16
Selecting a report style.
Give the report a name on the Finish screen (Figure 1.17) — I called it rptNorthwindSales. Select
the “Modify the report’s design” option to open the report in design view, and click Finish.
FIGURE 1.17
The Finish screen of the Report Wizard.
15
Part I The Office Components and What They Do Best
You will need to make some adjustments to the report’s design in the property sheet; if
TIP it is not open, click the Property Sheet button in the Tools group on the Design tab of
the Ribbon, as shown in Figure 1.18.
FIGURE 1.18
Opening the property sheet.
By default, in the Block report layout only the cells with values have visible borders, so to create an
overall worksheet-type layout, select all the controls in the Detail section of the report, and turn off
display of duplicate data values by setting the Hide Duplicates property to No on the Format tab of
the properties sheet, as shown in Figure 1.19.
FIGURE 1.19
Setting the Hide Duplicates property to No to eliminate duplicate data on a report.
Although it is generally not a problem for report controls to have the same names as their bound
fields (because they are rarely, if ever, referenced in code), I like to give the appropriate tags to the
bound controls at least. To do this manually, give the textboxes the prefix txt. (On a report created
by the Report Wizard, labels are named with the non-standard suffix _Label.)
16
Storing and Displaying Data in Access 1
The Report Wizard generally applies the default alignment to each column label, which
NEW FEATURE may result in inconsistent alignment. That doesn’t look good, so (if necessary) adjust the
alignment of the column headings labels as desired (generally they should be either all left-aligned or
all centered); on the sample report I made them all centered.
If you need to adjust an individual column width, it may be necessary to turn off control grouping
(a new feature in Access 2007). To accomplish this, first select the controls in the Detail section
and click the yellow group anchor that should now be visible (though not very visible — Microsoft
should have selected a color with more contrast than dull mustard yellow) at the upper-left corner
of the group, then right-click any control in the group and select Remove from the Layout submenu
(see Figure 1.20).
FIGURE 1.20
Turning off control grouping.
You can interactively sort and filter a report in report view — for example, when you want to view
records from only one customer, as shown in Figure 1.22.
17
Part I The Office Components and What They Do Best
FIGURE 1.21
A worksheet-type Access report.
FIGURE 1.22
Filtering a report by a selected value in the Customer field.
18
Storing and Displaying Data in Access 1
After making the selection, the report shows only Gourmet Lanchonetes records (Figure 1.23).
FIGURE 1.23
A report filtered by a Customer value.
PivotTables
If you need more advanced interactivity, you can make a PivotTable based on the same
qryNorthwindAll query. In Access 2007, the process of creating a PivotTable has been simpli-
fied; just select the data source query or table, then, as depicted in Figure 1.24, select PivotTable
from the More Forms menu of the Forms group in the Create tab of the Ribbon.
19
Part I The Office Components and What They Do Best
FIGURE 1.24
Creating a PivotTable.
A new form based on the data source opens in PivotTable view (see Figure 1.25), with the Field
List open so you can drag fields to the drop zones of the PivotTable, one field each to the Row
Fields, Column Fields, and (optionally) Filter Fields drop zones, which are indicated in gray text at
the upper-left corner of the form. The data field to be displayed in the body of the table is dragged
to the drop zone in the center of the form; Access will automatically create a Count or Sum field
when appropriate.
Figure 1.26 shows the PivotTable with Salesperson selected as the Row field and CategoryName as
the Column field, with Price as the Totals field.
20
Storing and Displaying Data in Access 1
FIGURE 1.25
A newly created PivotTable, ready to select fields.
FIGURE 1.26
A completed PivotTable.
21
Part I The Office Components and What They Do Best
PivotCharts
Making a PivotChart is even easier: select the data source query or table and click the PivotChart
button in the Forms group in the Create tab of the Ribbon. Figure 1.27 shows the new, blank
PivotChart with drop zones at the top and right sides of the form.
FIGURE 1.27
A new, blank PivotChart.
As with a PivotTable, you simply drag fields from the field list to the appropriate drop zones.
I dragged the OrderQuarter field to the Category field drop zone, the Supplier field to the Series
drop zone, the CategoryName to the Filter drop zone, and the Price field to the Data drop zone,
and I selected the Dairy Products category for filtering the data. Figure 1.28 shows the PivotChart
at this point.
22
Storing and Displaying Data in Access 1
FIGURE 1.28
The PivotChart with fields assigned to its drop zones.
The next step is to give names to the chart’s vertical and horizontal axes. To name the axes, select an
Axis Title label, open the property sheet, and select its Format tab; enter the name you want to dis-
play for that axis in the Caption property, as shown in Figure 1.29. Repeat for the other axis label.
FIGURE 1.29
Naming the vertical axis of a PivotChart.
23
Part I The Office Components and What They Do Best
To make the chart’s Legend visible (generally a good idea), click the Legend button in the
Show/Hide group of the Design tab of the Ribbon, as shown in Figure 1.30.
FIGURE 1.30
Making the PivotChart’s Legend visible.
FIGURE 1.31
A completed PivotChart.
Access 2007 reports have some interactivity, and PivotTables and PivotCharts have almost unlim-
ited interactivity, but both have a serious limitation: the interactivity is available only when you are
working in the Access database; when you send an Access report, PivotTable, or PivotChart to
someone else who doesn’t have Access, say as a PDF file, the recipient gets a read-only image of the
report, PivotTable, or PivotChart, with no interactivity. This may be what you want in some cases;
but if you need to deliver data in a worksheet or chart format that users can interact with, you
need to create an Excel worksheet or chart from your Access data, rather than a report, PivotTable,
or PivotChart.
24
Exploring the Variety of Random
Documents with Different Content
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.