Access Cookbook - Ken Getz [1]
You won't, however, find that this book pushes you into using new technology just because it's new. Many of the techniques in this book are "old chestnuts" that Access developers have used for years to solve common problems. Most of the VBA code that performs data manipulation chiefly uses the older technology, DAO, rather than the newer ADO, because DAO is still the most efficient way to work with Access data. When ADO provides a better approach to solving a particular problem, you'll learn how to use it for that purpose. For example, you'll learn how you can use an ADO recordset to retrieve a list of all the users logged on to your application—something that was never possible with DAO.
Uses the Tools at Hand
This book focuses on using the right tool for each problem. Some solutions here require no programming, while others require a little (or a lot) of VBA coding. Sometimes even plain VBA code isn't sufficient, and you'll need to use the Windows API or other available code libraries. In each case, we've tried to make the implementation of the technique as simple, yet generic, as possible.
We did, however, decide to focus the data access features of this book squarely on using the Jet database engine (instead of SQL Server). There are several reasons why we made this choice, but first and foremost is that most Access developers still prefer the convenience and simplicity of using Jet. The Jet database engine remains a cost-effective and capable solution for database applications used by small workgroups, which make up the vast majority of the Access user base. Most of the techniques described in this book, however, will work just as effectively with data from SQL Server or from other ODBC data sources, even if the example uses a Jet database. And if you are working with non-Access data sources, you'll find plenty of tips focused on helping you do so more efficiently.
Follows a Problem-Solution Format
The structure of this book is simple. The chapters are arranged by categories: queries, forms, reports, application design, printing, data manipulation, VBA, optimization, user interface, multiuser, Windows API, Automation, DAPs, and SQL Server applications. Each section consists of a single problem and its solution, followed by a discussion. Each solution contains a sample database (e.g., 01-01.MDB) with complete construction details, indicating which modules you'll need to import, what controls you'll need to create, and what events you'll need to handle. In one case, Recipe 4-10, any MDB file used elsewhere in the chapter will do. To use certain Chapter 14 examples, you will need to be connected to either the Northwind or Pubs databases that ship with SQL Server. All the code, bitmaps, sample data, and necessary tools are included with the CD-ROM that accompanies this book. (CD content is available online at http://examples.oreilly.com/accesscook.)
Who This Book Is For
You don't have to be a VBA whiz to use this book. It's designed for all levels of readers: end users, power users, and developers.
In every case, we've made the steps needed to implement our solution as simple as possible. When VBA is involved, we've recommended which modules to import from the sample database and discussed the important features of the code within the text. You shouldn't have to retype any of the code unless you care to—in fact, you shouldn't retype the code, since we rarely include every single line of code here in the book. We've pointed out the important code here but left much of the support code on the CD-ROM (see http://examples.oreilly.com/accesscook). What's more, you don't actually have to understand the solutions to most