Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 590 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
590
Dung lượng
22,69 MB
Nội dung
Collins
ISBN 978-1-4302-3578-1
9 781430 235781
54499
US $44.99
Shelve in
Databases / MS Access
User level:
Intermediate–Advanced
www.apress.com
SOURCE CODE ONLINE
RELATED
BOOKS FOR PROFESSIONALS BY PROFESSIONALS
®
Pro Access2010 Development
Pro Access2010Development shows you how to develop business applications
that take full advantage of all Access2010 has to offer. Practical and hands-on,
author Mark Collins explains all the facets of developing Access-based solutions,
including data modeling, complex form development, and UI customizations. You’ll
even find out all you need to know to deploy your solution to the web and integrate
it with other external data sources.
With ProAccess2010 Development, you will learn how to:
• Build business applications that integrate local data, web-generated data,
and data available from SQL Server and other sources
• Develop VBA routines and macros to enhance the automation of your database
• Deploy databases to your users and “web-ify” your application for access
from anywhere
• Securely allow access to your data and maintain its integrity
• Integrate Access with SharePoint, Outlook, SQL Server databases, and
other business applications
Pro Access2010Development offers many handy tricks to help you get the most
out of Access, including its comprehensive set of features and tools for collecting,
using, and acting on business data, no matter where your data is stored.
www.it-ebooks.info
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
www.it-ebooks.info
iv
Contents at a Glance
About the Author xix
About the Technical Reviewer xx
Acknowledgments xxi
Preface xxii
PART 1 Introduction 1
Chapter 1: Introduction 3
PART 2 Defining the Database Schema 15
Chapter 2: Defining and Relating Tables 17
Chapter 3: Using Data Macros 53
Chapter 4: Designing Queries 77
Chapter 5: Creating PivotTables 103
PART 3 Creating Forms and Reports 125
Chapter 6: Standard Forms 127
Chapter 7: Creating a CheckOut Form 153
Chapter 8: Creating a Customer Admin Form 191
Chapter 9: Enhancing Product Administration 221
Chapter 10: Enhancing the User Experience 255
Chapter 11: Branding with Themes and Styles 291
Chapter 12: Reports 309
www.it-ebooks.info
CONTENTS AT A GLANCE
v
PART 4 Multiuser Considerations 359
Chapter 13: Upsizing 361
Chapter 14: Distributing the Application 393
Chapter 15: Publishing to the Web 415
PART 5 Advanced Topics 455
Chapter 16: Integrating Outlook 457
Chapter 17: Using External Data 489
Chapter 18: Miscellaneous Features 511
Chapter 19: Security 531
Appendix A: Northwind Web Database 551
Index 563
www.it-ebooks.info
1
P A R T I
Introduction
www.it-ebooks.info
C H A P T E R 1
3
Introduction
Microsoft Access is a unique platform that enables rapid development of database applications. It has
been a long-time favorite of both developers and end users for creating single-user and small-scale office
automation solutions. Recent improvements have made it a viable choice for enterprise-class
applications as well. In this book, I’ll show you how to take advantage of all the great features that Access
2010 has to offer. I think you’ll find it surprisingly easy to build full-featured applications.
What Is Access?
For those that may be new to Access, a brief overview will be helpful before I get into the details. At its
core, Access is a relational database engine that allows you to define tables to store data. You can define
primary keys, indices, and table relationships much like you would with SQL Server or Oracle. You can
also write queries to insert, update, retrieve, or delete data from your tables.
Defining the User Interface
However, this is where the similarities with other database engines end. Access is also an application
development platform that you can use to define forms, menus, and reports.
With Access, you can design forms to display and update data. Because the form definition is
integrally tied to the data schema, the form can easily enforce data integrity. For example, if you define a
foreign key relationship between two tables, the form can automatically provide a dropdown list
showing the permitted values.
Access provides a facility for designing reports that use tables or queries. Again, because the report
writer is integrated into the database design, you can simplify the report definition. Access also allows
you to create forms for navigating through the various forms and reports, so you can control the entire
user experience. Finally, by using macros and Visual Basic for Applications (VBA), you can automate
tasks and provide advanced features.
Choosing the Application Architecture
Because Access is both a database engine and an application development platform, there are several
ways that these components can be configured. In this book, I will show you how to implement these
configurations. The simplest scenario is to include both tables and forms in a single “database.” The end
user will open this file using the Access application. This is ideal for single user applications.
To support multiple users, you can split the UI elements (forms, reports, and macros) into a
separate file. The tables are then referenced as linked tables in their own database. Each user can open
their own copy of the UI file but reference a common database file.
www.it-ebooks.info
CHAPTER 1 ■ INTRODUCTION
4
With Access, you can reference data from various sources such as Excel files, other Access databases,
text and XML files, SharePoint lists, and Open Database Connectivity (ODBC) sources. It is possible to
use Access solely as an application development platform using data from another source such as SQL
Server.
With Access 2010, you can also publish your database to a SharePoint server. This gives end users
access to your data and forms without needing a copy of the Access runtime. This also takes advantage
of all the enterprise features of SharePoint such as security, concurrency and offline data caching.
Using This Book
This book is designed to show you how to use Access2010 to build a complete application. You will
create an Access database in Chapter 2 and each subsequent chapter will build upon the previous
chapters adding features to your database. I recommend that you work through each chapter in order
and, when you’re done, you will have full-featured Access database application. You can download the
final result from www.apress.com if you prefer. I will also create a copy of the interim application at the
end of each chapter. So if you wanted to skip to Chapter 8, for example, you can download the database
from Chapter 7 and start from there.
The Sample Application
The sample project that you will create throughout this book will support a lending library. It keeps track
of all the inventory items including which items have been checked out and when they are due back. It
also computes any overdue fees. It will send reminder e-mails when items are due and allow users to
request an item to be held for them.
To give you a preview of where we’re heading in this book, I’ll briefly describe the end product. This
is what you will create yourself as you work through the exercises in each chapter. When you first load
the Access database, the initial view will look like Figure 1-1.
www.it-ebooks.info
CHAPTER 1 ■ INTRODUCTION
5
Figure 1-1. The main Navigation form
This is the Navigation form that is loaded automatically when the application starts. Notice that all
of the standard Access menus and navigation are removed. In their place, a custom ribbon is used to
reveal all of the forms, reports, and macros that are available to the users. Most of these features are also
available through the tabbed dialog form. The application has been branded to mimic the
www.apress.com website.
Figure 1-2 shows the first tab of the Customer Admin form, which is used to add or update a
customer’s profile.
www.it-ebooks.info
CHAPTER 1 ■ INTRODUCTION
6
Figure 1-2. The Profile tab of the Customer Admin form
The next two tabs of this form show the items currently checked out and a complete history of all
items that have been loaned to this customer. The “Items On Loan” tab is shown in Figure 1-3.
www.it-ebooks.info
CHAPTER 1 ■ INTRODUCTION
7
Figure 1-3. The Items On Loan tab
The top grid lists the items still checked out. The lower form shows the details of the selected item. If
the item is overdue, the due date will blink to highlight that fact. Notice that an image of the item is
included on this form.
The application provides a search feature for finding items based on author, title, or description.
The Item Search form is shown in Figure 1-4.
www.it-ebooks.info
[...]... tables could end up having three or more primary key fields For the project in this book, I will use the former approach and give each table a single primary key field I believe this to be the more prevalent approach, especially in Microsoft platforms such as Access and SQL Server This will also simplify the implementation of this project 17 www.it-ebooks.info CHAPTER 2 DEFINING AND RELATING TABLES... the Loan and Request tables Creating the Customer Table Start the Access 2010 application and create a blank database named Library Use the Microsoft Access 2007 database format, which should be your default option This will create a Library.accdb file The template automatically creates a single table named Table1 with an ID column Access provides two views that you can use to define the table The default... defined The lower left pane displays all the properties of the selected column The subset of properties that are displayed will vary depending on the data type of the column The lower right pane provides information about the selected property In the Field Name column, replace ID with CustomerID This column was set up as an AutoNumber field Notice that the New Values property is set to Increment and there... Validation Text property and enter The loan period must be between 7 and 21 days Set the Required property to Yes The Decimal Places property defaults to Auto Because you are expecting only whole numbers, change this to 0 Notice that when you change the Decimal Places 29 www.it-ebooks.info CHAPTER 2 DEFINING AND RELATING TABLES property a lightning bolt appears next to it This is known as the Property Update... will guide you through the process of creating a base set of tables for your application I’ll show you step-by-step how to design the tables and use the many data modeling features in Access 2010 By the end of the chapter, you’ll have a solid structure on which to build the rest of the application Considering Design Practices Before starting the specific design for this project, I want to cover some... integrate with Outlook • Understanding the Access security features In the next chapter, you’ll create the Library database and define the tables that will be used for the rest of the book This is how most good Access solutions begin, by providing a good data model at the start 14 www.it-ebooks.info PART 2 Defining the Database Schema In Part 2, you’ll create an Access database and define schema elements,... will add the following fields: • Address • City • StateProvince • ZIPPostal • CountryRegion These fields as well as LastName and FirstName were added as not required and the “Allow Zero Length” property is set to No Depending on how your library will be used, you probably want to make some of these required I suggest that you set the Required property to Yes on at least LastName and FirstName fields... field required, select the Required property and choose Yes from the dropdown list Do this for the CategoryCode field For Text fields there is also an “Allow Zero Length” property Access makes a distinction between a null value and an empty string, as do most database engines In practice, however, we seldom care about that distinction If the “Allow Zero Length” property is set to Yes, the end user... these properties are set to Yes Adding a Unique Constraint There are times when we need to ensure certain values are unique For example, if two categories were created that used the same code, the code would be ambiguous In Access you can ensure unique values by adding an index and selecting the No Duplicates option Go to the CategoryCode field and select this option for the Indexed property The properties... constraints allows you define rules for what data is considered valid By providing these rules at the database level, you guarantee that these rules are followed, regardless of the source of the data The database engine will not allow data to be added or modified if it violates any of these constraints Fortunately, Access 2010 provides all the necessary features to allow you to do this Foreign key constraints . / MS Access
User level:
Intermediate–Advanced
www.apress.com
SOURCE CODE ONLINE
RELATED
BOOKS FOR PROFESSIONALS BY PROFESSIONALS
®
Pro Access 2010 Development
Pro. Access 2010 Development
Pro Access 2010 Development shows you how to develop business applications
that take full advantage of all Access 2010 has to offer.