1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Access™ 2007 VBA Programmer’s Reference pdf

1,2K 677 8
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Access™ 2007 VBA Programmer’s Reference
Tác giả Teresa Hennig, Rob Cooper, Geoffrey Griffith, Armen Stein
Trường học Wiley Publishing, Inc.
Chuyên ngành Computer Programming
Thể loại Tài liệu hướng dẫn
Năm xuất bản 2007
Định dạng
Số trang 1.155
Dung lượng 14,99 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Access 2007 has some phenomenal new features that empower users and give Access a more universal appeal.. Duringthe Access 2007 release, he led the security efforts across the test team

Trang 2

Access ™ 2007 VBA Programmer’s Reference

Teresa Hennig Rob Cooper Geoffrey Griffith Armen Stein

Trang 4

Access ™ 2007 VBA Programmer’s Reference

Trang 6

Access ™ 2007 VBA Programmer’s Reference

Teresa Hennig Rob Cooper Geoffrey Griffith Armen Stein

Trang 7

Access™ 2007 VBA Programmer’s Reference

Copyright ©2007 by Wiley Publishing, Inc., Indianapolis, Indiana

Published simultaneously in Canada

ISBN: 978-0-470-04703-3

Manufactured in the United States of America

10 9 8 7 6 5 4 3 2 1

Library of Congress Cataloging-in-Publication Data: Available from Publisher.

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 ted 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 theCopyright 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

permit-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, INCLUDINGWITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE NO WARRANTYMAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS THE ADVICE ANDSTRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION THIS WORK ISSOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERINGLEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES IF PROFESSIONAL ASSISTANCE ISREQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT.NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HERE-FROM THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS ACITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THATTHE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION ORWEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE FURTHER, READERS SHOULD BEAWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAP-PEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ

For general information on our other products and services please contact our Customer Care Departmentwithin the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related tradedress are trademarks or registered trademarks of John Wiley & Sons, Inc and/or its affiliates, in the UnitedStates and other countries, and may not be used without written permission Microsoft and Access are trade-marks or registered trademarks of Microsoft Corporation in the United States and other countries All othertrademarks are the property of their respective owners Wiley Publishing, Inc., is not associated with anyproduct 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

Trang 8

I dedicate my work, passion, and energies to my brother Kirk is an inspiration, mentor, and good friend, and he leads by example in his unstinting support of the Spinal Cord Society’s research to cure paralysis And to my Mom and Papa and my Dad, who encourage me, laugh with me, and share in my joys, struggles, and jubilations as I take

on extraordinary challenges such as climbing Mt Rainier, riding 220 miles on a bike, and even writing this book And I dedicate this book to all the people who are just learning about Access and about VBA Access 2007 has some phenomenal new features that empower users and give Access a more universal appeal I am privileged to help you

on your journey.

— Teresa

To my Mom, for her love and encouragement over the years and for instilling in me the passion to find the things I enjoy To Karen and Chris, for reminding me where I come from And in loving memory of my dad Marvin, who continues to drive me in my search for meaning.

— Rob

To my wife Jamie, for all the love and support you have given me To my family: Mom, Dad, Cara, Sean, Ariana, and Army, for the encouragement, knowledge, and strength you have given me My deepest gratitude does not even begin to define my love and appreciation for each of you.

— Geoff

To my wife Lori Our work and interests are often so different, but I couldn’t ask for a better partner.

— Armen

Trang 10

About the Authors

Teresa Hennigloves challenges, solving problems, and making things happen Her company, DataDynamics NW, reflects her dynamic personality and her innate ability to quickly grasp a situation andformulate a solution

Teresa is president of both the Pacific Northwest Access Developer Group and the Seattle Access Group, and is host for INETA’s monthly webcasts She was the coordinating author for Access 2003 VBA Programmer’s reference, and continues to publish two monthly Access newsletters In recognition

of her expertise and dedication to the Access community, Teresa was awarded Microsoft Access MVP

Rob Cooperis a test lead on the Access team at Microsoft He started at Microsoft as a support engineer

in Charlotte, North Carolina, in 1998 and joined the Access 2003 test team in Redmond in 2001 Duringthe Access 2007 release, he led the security efforts across the test team and worked on several new fea-tures including disabled mode, database encryption, Office Trust Center, and sorting, grouping andtotals Rob also led efforts around the Access object model and continues to provide direction aroundprogrammability and security in Access

A long-time fan of Access, Rob is a frequent speaker at the Seattle Access Group and PNWADG meetingsand has written for the Microsoft Knowledge Base and Access Advisor Aside from writing code inAccess and C#, he also enjoys spending time with his family watching movies, going to the zoo andaquarium, and hanging out in and around Seattle

Geoffrey Griffithis an avid Access user who was raised in the Boulder, Colorado, area He holds aBachelor of Science degree in Computer Science from University of Colorado, where he studied softwareengineering Now living in the Seattle, Washington, area and employed by Microsoft, he contributed tothe Access 2007 product as a Software Design Engineer in Test for the Microsoft Office Access team Heenjoys participating in software community events by attending and speaking for local users groups andhelping all those who would seek it

Armen Steinis a Microsoft Access MVP and the president of J Street Technology, Inc., a team of databaseapplication developers in Redmond, Washington J Street also offers web design, web hosting, andCartGenie, a complete web storefront and shopping cart system Armen is President Emeritus of thePacific Northwest Access Developers Group, and has also spoken at Seattle Access and Portland AccessUsers Group meetings He has taught database classes at Bellevue Community College, and also devel-oped and taught one-day training classes on Access and Access/SQL Server development Armenearned a Business Administration/Computer Science degree from Western Washington University, andhas been developing computer applications since 1984 His other interests include activities with hisfamily, backgammon, Mariners baseball, and driving his 1969 Ford Bronco in the sun

Trang 14

We want to start with a huge thank you to everyone who was pulled into the research and review for theuniquely challenging adventure of writing about Access 2007 while working with the beta versions andusing Vista beta And a very heartfelt hug of appreciation to the families and friends of the authors andtech editors for putting up with our all-nighters as we strove to make this the most technically accurateand comprehensive book in its class Speaking of tech editors, words alone cannot adequately acknowl-edge the valuable contributions of our two tech editors, Michael Brotherton and Michael Tucker We alsowant to thank the Microsoft Access team for their passion and devotion and for making such revolution-ary changes to Access And, it wouldn’t be as good as it is without the people who shared ideas and con-tributed to this book, including David Antonsen, Tim Getsch, Michael Kaplan, Michael Tucker, andRandy Weers

We also want to thank Wiley and Wrox for providing the opportunity and infrastructure to reach ouraudience We especially want to thank Bob Elliott for guiding us through the process and understandingthe challenges of working with two beta systems And we have a very special vote of appreciation forour development editor, Maryann Steinhart, who did a great job of managing the formatting and edit-ing Despite numerous delays, Maryann worked with us to incorporate final revisions when 2007 wasreleased And of course, we want to thank the authors of the 2003 edition, Patricia Cardoza, TeresaHennig, Graham Seach, Armen Stein, and contributors Randy, Sam, Steve, and Brian

Writing this book has been a challenging and incredibly rewarding experience It was only possiblebecause of teamwork and the contributions of others So, thank you all!

— The Authors

I have to start by saying that is has been an honor and privilege to lead such an amazing team of authorsand tech editors Their combined expertise, experience, and passion for Access is unprecedented Thismay have been the most challenging version to write about, and thanks to your devotion and team spiritour book will set a new standard for technical accuracy As shocking as this may be, I’m at a loss forwords to adequately express my heartfelt appreciation

Of course, I have to thank the Access team for going all out for Access 2007 and for their seemingly less dedication to supporting the Access community It’s only through their efforts that we have so manynew features I can hardly wait to feel the excitement as people start to use Access 2007 That being said,

tire-I want to thank the members of my Access groups and all of the people who are using our book to getmore out of Access You are my motivation, and our team wrote this book for you

I want to thank my family and special friends for their understanding and support through the rollercoaster ride of writing this book You were always available to listen to my stories and graciouslyaccepted the many times that I was “unavailable.” And, I am so fortunate to have the most amazingclients Thank you for hanging in there when my time was consumed by the book and I had to deferyour projects You’ll recognize Randy from our last book; although he was unable to officially join our

Trang 15

yes, there it is again, the M word So yes, my world is still filled with Mikes and Michaels I wouldn’twant it any other way <g>.

To friends, challenges, and opportunities May we learn to celebrate them all

— Teresa

First, I’d like to thank my wife Sandi for her support during all of the late nights and weekends To mychildren Isabel and Gillian for being so understanding at such a young age while Daddy was workingand not playing soccer or hanging out on the weekends And to my oldest Taryn for being there onmany occasions while I was not The sushi is still better on the left-coast!

Huge thanks to Teresa Hennig for the opportunity to work on this book and for the project coordinationefforts This is something I have always wanted to do and I am truly grateful for the opportunity Thanks

to everyone on the Access team at Microsoft for their amazing work during this release and for ing questions that I came across while writing I’d also like to thank the following people in particular:Sherri Duran for her encouragement and support while I started on this project, Kumar Srinivasamurthyfor the encouragement and for being both a great lead and teacher this release, Adam Kenney for teach-ing me about the Ribbon, Michael Tucker and Michael Brotherton for agreeing to work on this projectand for providing outstanding technical feedback, and Tim Getsch for writing the Foreword and greatAccess conversation

answer-— Rob

I’d like to acknowledge my wife Jamie and her family — Ken, Mary and Tammy — for the numeroussacrifices you have made for me; they are far too many to count To my own family — Mom, Dad, Cara,Sean, Ariana, Army, and all my grandparents, aunts, uncles and cousins — your love and support hasbeen monumental and the foundation of my entire life To my best friends throughout the years — Mikeand Megan, Joe, Rudi, Dylan, the Tom’s, Sean, Cody, Ryan, Sammy, Marc, John, Paul, Matt, Elgin, Daveand Lori, Joe, Shinya, Andrew, Scott, and Dee Dee — thanks for all the encouragement and great times

To Sherri, Shawn, and everyone on the Access Team, for answering all of my questions and providing

me with tremendous, life-changing experiences Andrei, Valdimir, Tianru, Richard and Stephanie, thanksfor taking a chance on a young kid, teaching me Access, and breaking me into the software industry Thewriters and contributors to this book — Teresa, Rob, Armen, Michael, Michael, Maryann, Bob, andDavid — thanks for the great team and providing me with the magnificent opportunity of working onthis book To the previous authors of this book: Patricia, Teresa, Graham and Armen, as well as the con-tributing authors Steve, Brian, Randy, and Sam, for laying a powerful foundation for this book and shar-ing your extensive knowledge and experience in the previous book To Clayton, Doug, Ed (“Dr A”), Dr.Tom Lookabaugh, Dr Michael Main, Jan, Mrs Best, Jeannie, Yvonne, and all of my other teachers andprofessors, thanks for helping me learn and grow Finally, all the hundreds of people who have made adifference in my life, even though you have not been called out by name, I still acknowledge your sup-port and appreciate your contributions Every last one of you is a Rock Star!

— Geoff

Thanks to my team at J Street Technology for their dedication to quality database applications: Steve,Sandra, Tyler, Matt, Stacey and Jessica And thanks to my wife Lori and kids Lauren and Jonathan, whoalways support me in everything I do

— Armen

Trang 16

When I saw the list of authors Teresa brought together for this second edition of the Access VBA

Programmer’s Reference, I was very impressed I have known each of the authors for several years, and

they each have valuable insight Teresa Hennig and Armen Stein are both Microsoft MVPs who haveserved the Access community in the Seattle area for many years Rob Cooper is one of the top testers onthe Access team and has a long history with the Access product as a support engineer Geoffrey Griffith

is an up-and-coming tester on the Access team who carries a lot of passion for the product I haveworked closely with him since his first day at Microsoft Even the technical editors for this book haveextremely strong resumes Both Michael Brotherton and Michael Tucker have worked at Microsoft formore than 10 years and were testers on the Access 2007 team

Not only was this book written and reviewed by a strong cast of authors, it nicely covers a wide trum of topics that you will encounter as you build your solutions in Access It has topics for people new to Access or new to programming as well as topics that will improve the skills of seasoned veterans.This book teaches about many of the latest innovations as well as illustrating several commonly usedtechniques

spec-You will not just learn how to properly use VBA, but you will also see several new features in Access

2007 that eliminate or reduce the need for VBA code Ultimately, you have a job to get done, and thisbook shows you the tools that are at your disposal It is full of sample code that can help you get started,and it teaches you solid techniques that will help your code become easier to maintain in the long run.This is a great book for anyone wanting to learn the depth and breadth of Access 2007 It is also an excel-lent reference and something that you will surely want to keep close at hand

Tim Getsch Program Manager, Microsoft Access

Trang 18

Introduction xxxi

Trang 19

The Power User 34

Trang 20

Access Data Engine 52

Trang 22

DAO Object Properties 127

Trang 23

Creating ADO Recordsets 204

Trang 24

Looping Through Recordsets 250

Trang 25

Issues in Error Handling 289

Trang 26

Important Report Events and Properties 352

Trang 27

Building the Settings Tab 415

Trang 28

Chapter 14: Extending VBA with APIs 485

Trang 29

Chapter 16: Working with Office Applications 537

Trang 30

Using the User-Level Security Wizard 621

Chapter 19: Understanding Client-Server Development with VBA 649

Trang 31

Using the Win32 Registry APIs 709

Chapter 22: Protecting Yourself with Access 2007 Security 755

Trang 32

Digital Signatures and Certificates 769

Appendix D: DAO Object Method and Property Descriptions 839

Appendix F: ADO Object Argument Enumeration Information 889

Trang 34

Welcome to Access 2007 VBA Programmer’s Reference This release of Access probably has the most

dra-matic changes for developers and users since Access 97 and arguably since Access 2.0 With changes ofthis magnitude, you will want to leverage community resources to get up to speed quickly so that youare working smarter and more efficiently That’s where this book comes in

Why this book? It has an unparalleled team of authors and tech editors who are as devoted to helpingfellow developers as they are passionate about the product Armen and Teresa have both earned AccessMVP status in recognition of their expertise and contributions to the Access community, and Rob andGeoff are members of the Microsoft Access test team They have the level of familiarity with Access 2007that can only be developed through time and use Both of the tech editors are testers on the MicrosoftAccess team, so they too have been working with Access 2007 for more than a year In addition to edit-ing, they also contributed resources, suggestions, and some of the tips in Appendix M Every member ofthe team has been working with Access since 97 or before Even with this remarkable level of expertise,

we took the opportunity to complement our own experiences with contributions from other developers

to bring you the best available information on using VBA (Microsoft Visual Basic for Applications) inAccess 2007

Many of the new features in Access 2007 can accomplish tasks that previously required VBA ming In addition to reducing development time, these features can create better and more professionallooking solutions For many of us, being able to take advantage of the new features, right out of the box,

program-is more than enough reason to upgrade So although the primary focus of thprogram-is book program-is to help you extendthe power of Access by adding VBA, we identify the new features of Access 2007 Because many of youare familiar with prior versions of Access, we also point out some of the major changes, particularly ifthey affect the way that you will be working

The goal is for Access 2007 VBA Programmer’s Reference to be your primary resource and tool to help you

leverage both Access’s built-in functionality and VBA in a manner that helps you to create the best cations that you can imagine Access 2007 makes it easy to start working as soon as it’s installed Withthe new UI (user interface), people will be building complex applications using the tools and resourcesthat ship with Access And, with a little outside guidance, they can work a lot smarter, with more confi-dence, and avoid several pitfalls So, this book is for the typical Access user as well as the seasoned pro-grammer It will help you utilize the power of Microsoft Access more effectively and help you choosewhen to let the wizards do the work, as well as showing you how to modify and enhance the code thatthe wizards create Access builds great forms and reports that can be customized on-the-fly by usingVBA code to respond to a multitude of events Interactive reports, or report browse, may be the ultimateexample of the power and potential of Access And Access now offers invaluable opportunities to inte-grate with external applications and multiple data sources It’s almost as easy as “a click of a button” toretrieve data from e-mail or to work with SharePoint and other online services You can even useSharePoint for deployment and version control

appli-With all the new templates, macros, wizards, and help files, it is easier than ever to open the programand quickly start creating tables, forms, and reports When you consider how easy it is to get started,

Trang 35

an integration tool, or SDK (software development kit), it typically requires VB or VBA to work with it.VBA is actually a subset of the Visual Basic programming language and is a superset of VB Script(another in the Visual Basic family of development tools) VBA includes a robust suite of programmingtools based on the Visual Basic development, arguably the world’s most popular rapid applicationdevelopment system for desktop solutions Developers can add code to tailor any VBA-enabled applica-tion to their specific business processes Starting with a blank database or building on a template, youcan build complex solutions For example, a construction company can use VBA within Microsoft Access

to develop a sophisticated system covering estimating, ordering, scheduling, costing, and inventory trol The look and operation of the system can be tailored for each group and it can easily limit what data

con-a person ccon-an view or chcon-ange

The report browse feature in Access 2007 is going to revolutionize the way both developers and userswork with data Developers will create more powerful and informative reports and users will have moreoptions for analyzing and reporting data It will enable people to make smarter decisions faster Whateverthe industry, Access may be the cost-effective alternative to purchasing an off-the-shelf product Instead ofpaying the high cost of a proprietary program that offers limited capability for customization, developerscan use Access to build a robust, expandable application that easily integrates with other programs Oncethe Access application is in place, it can continue to be enhanced quickly and efficiently

You might wonder why you should develop in VBA rather than Visual Basic 6.0 or Visual Basic NET,both robust, popular, and capable programming languages Using VBA within Access gives you a couple

of key benefits First, you can profit from a built-in Access object library, taking full advantage of a widevariety of Access commands, including executing any command from the Ribbon or custom toolbar inAccess And second, it’s cost effective because VBA is included in all Microsoft Office System applica-tions To develop in Visual Basic, you need to purchase Visual Basic 6.0 or Visual Basic NET either alone

or as part of the Visual Studio or Visual Studio NET suite If they are required, they can be cost-effectivetools, but it may not be necessary to burden a project with that overhead And, since VBA is includedwith the Microsoft Office applications, your code and skills are transferable and it makes it much easier

to integrate with other applications

Despite the advantages of VBA, there are still circumstances where it would be beneficial to use VisualBasic For example, to deploy an application to a wide variety of computers, especially those without afull installation of Microsoft Access, Visual Basic is a valid option In fact, this book discusses using theAccess Developer Extensions that ship with Visual Studio Tools for Office for that very purpose

What Does This Book Cover?

Access 2007 VBA Programmer’s Reference covers a wide spectrum of programming topics relevant to

Access Although it assumes the reader has some familiarity with VBA programming language, it beginswith a brief introduction to VBA And to help you leverage the tools that Access provides, a chapter

Trang 36

highlights the new features in Microsoft Office Access 2007 — including new wizards and GUI cal user interface) elements that previously required VBA code, as well as new VBA features.

(graphi-The book also discusses how to create and name variables, how to use Data Access Object (DAO) andActiveX Data Object (ADO) to manipulate data both within Access and within other applications, propererror handling techniques, and advanced functions such as creating classes and using APIs Key newobjects such as using Macros and the Ribbon are explored, too, as are forms and reports, the two mostpowerful tools for working with and displaying data Working with other applications is covered exten-sively both in a general nature and for working specifically with Microsoft Office applications, WindowsSharePoint Services, and SQL Server Of course, this book wouldn’t be complete without discussingsecurity issues and the Developer Extensions

The ChaptersChapters 1–5 provide material that you need if you’re new to Access or VBA After a review of Access2007’s new features, you explore the building blocks of VBA, including objects, properties, methods, andevents And you’re introduced to the VBA Editor and its various debugging tools

Chapters 6 and 7 focus on using VBA to access data Both DAO and ADO provide methods for accessingdata in Microsoft Access and other external data sources such as Informix, SQL Server, and a variety ofaccounting programs

Chapters 8 and 9 provide detailed information on executing and debugging VBA code Every ment project needs some debugging, even if you’re an expert developer You’ll see some easy ways todebug your code, and get some tips and tricks to make the tedious process of debugging a bit easier.Error handling is for more than just trapping problems and preventing crashes It provides a powerfultool for interacting with users and adding functionality to programs

develop-Chapters 10 and 11 tackle forms and reports, two Access objects that can make particularly heavy use ofVBA In many applications, forms and reports control what the user can see and do With the advent ofreport browsers, nearly all of the events that were available on forms are now accessible on reports So,

in addition to using code to show or hide sections of reports and to provide special formatting, you cannow drill into the data underlying the report These two chapters are packed with information; you’ll seehow to use split screens on forms, create professional image controls, format reports based on cross tabqueries, enhance interactive reports, alternate row colors, and much more

Advanced VBA programming information begins in the next four chapters (12–15) — creating classes inVBA, using APIs, and using SQL and VBA Because the Office Ribbon is new, there is a chapter dedi-cated to explaining how to customize and work with the ribbon

Chapters 16–22 provide information about working with other programs, working with Windows, andcontrolling access to your applications and files They also discuss some techniques for deploying data-base solutions You’ll learn to create tasks and e-mail in Outlook, perform a mail merge in Word, exportdata to an Excel spreadsheet, and take information from Access, create a graph, and insert that graphinto PowerPoint Windows SharePoint services can help your applications share data across the Web.You’ll see how new file formats add to network and Access security In addition, you’ll work withclient/server development, learn to take advantage of Windows Registry and explore the AccessDeveloper Extensions, essentially a Microsoft add-in, before you tackle macro security

Trang 37

The Appendixes

As a developer, you can often spend hours going from source to source looking for reference material.The authors have applied the principles of relational databases (doing the work once so it can be usedmany times in multiple ways) to the appendixes, providing a compilation of data from a myriad ofsources

Appendix A addresses the issues and processes of upgrading, converting, and compatibility The other

12 appendixes provide lists and tables that complement specific chapters in the book You’ll finddetailed lists of objects for both DAO and ADO as well as the Access object model and WindowsRegistry The appendixes on naming conventions and reserved words provide invaluable informationthat not only can strengthen your programming style but can save you from using terms or charactersthat can cause hours of needless pain and frustration in debugging and correcting The last appendix isfilled with tips and tricks to make it easier and faster for you to develop professional applications, allsolicited from MVPs and developers around the world

How to Use This Book

The initial chapters are written in a tutorial format with detailed examples True to the Wrox

Programmer’s Reference standard format, the book includes numerous reference appendixes withdetails on the various object models you might use when writing VBA code in Access It also provides adetailed primer on the Windows Registry and a listing of common API functions you might want to use

in your code

Real-world examples are given for many, if not most, of the programming topics covered in this book.These are just of few of the topics and examples that are included:

❑ How to control access to data based on database login information

❑ How to create custom reports based on information entered on a form

❑ How to leverage report browse — the new interactive report feature that enables drilling intodata on reports

❑ How to summarize and graphically display data using cross-tab reports

❑ How to use VBA to transfer data between Access and other Office programs such as Outlook,Word, and Excel

❑ How to configure custom ribbons, toolbars, and menus for your Access database applications

❑ How to use the image controls for more intuitive and professional looking forms

Throughout the book, we’ve also included tips and tricks discovered during the authors’ programmingexperiences

We recommend that as you go through the book, you download the code and sample databases so thatyou can see how the code works and experiment with changes (See the “Source Code” section later inthis Introduction for details on downloading the code.) Working with the code is how you take owner-ship of the concept and start to incorporate it into your work and solutions

Trang 38

Other Access/VBA Sources

You’ve heard the saying that there are as many ways to build a solution as there are programmers Well,there is a lot of history underlying that statement So, although this book is an excellent reference for all

of your Access 2007 programming needs, there just isn’t enough time and ink to cover everything — tosay nothing about fixes, updates, and add-ons That’s where networking, newsgroups, and other infor-mation sites come in Here are some of the authors’ favorites for you to check out:

❑ Microsoft Newsgroups — Microsoft maintains a news server and has a wide variety of Accessand VBA newsgroups to choose from Currently there are more than 18 Access newsgroups for you to choose from They all begin with microsoft.public.access You can access newsgroups through a newsreader such as Outlook Express or through the Web at http://support.microsoft.com/newsgroups/default.aspx

❑ Microsoft Office Discussion Groups (http:// microsoft.com/office/community/

en-us/FlyoutOverview.mspx) — Microsoft is encouraging users to help each other, and

it hosts discussion groups on selected products There are currently 12 newsgroups listed for Microsoft Access

❑ MVPS.ORG (http:// mvps.org) — Your jumping-off point to a number of interesting ings provided by a few folks associated with the Microsoft Most Valuable Professional (MVP)program

offer-❑ Microsoft Access Developer Portal(http://msdn.microsoft.com/office/program/access) — Provides information aboutcurrent issues, downloads, updates, and ways to obtain product support There are links toexcellent tutorials and training as well as videos about Access 2007 and links to external sitessuch as user groups, newsgroups, and other valuable resources

❑ Microsoft TechNet (http:// microsoft.com/technet) — Offers quick access to MicrosoftKnowledge Base articles, security information, and many other technical articles and tips

❑ Microsoft Office Online - Access (http://office.microsoft.com/en-us/

FX010857911033.aspx) — Provides quick tips, and direct links to Access resources such

as downloads, templates, training, add-ins, and other pertinent information

❑ Utter Access (http:// utteraccess.com) — Currently the leading independent forum forMicrosoft Access questions and solutions

Conventions Used in This Book

Several different styles of text in this book will help you understand different types of information Some

of the styles we’ve used are listed here:

Mission-critical information or tips we’ve found particularly valuable in ment are included in a box such as this.

Trang 39

develop-As for styles in the text:

New terms and important words are highlighted when they’re introduced.

❑ Keyboard strokes appear like this: Ctrl+A

❑ Simple filenames, URLs, and code within the text look like so: persistence.properties

❑ Code is presented in two different ways:

In code examples, new and important code is highlighted with a gray background

The gray highlighting is not used for code that’s less important in the presentcontext, or that has been shown before

Source Code

As you work through the examples in this book, you may choose either to type in all the code manually

or to use the source code files that accompany the book All of the source code used in this book is able for download at http://www.wrox.com Once at the site, simply locate the book’s title (either byusing the Search box or by using one of the title lists) and click the Download Code link on the book’sdetail page to obtain all the source code for the book

avail-Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is 978-0-470-04703-3

Once you download the code, just decompress it with your favorite compression tool Alternatively, you can go to the main Wrox code download page at http://www.wrox.com/dynamic/books/download.aspxto see the code available for this book and all other Wrox books

Er rata

Every effort is made to ensure that there are no errors in the text or in the code However, no one is perfect, and mistakes do occur If you find an error like a spelling mistake or faulty piece of code in one of our books, we would be grateful for your feedback By sending in errata you may save anotherreader hours of frustration and at the same time you will be helping us provide even higher qualityinformation

To find the errata page for this book, go to http://www.wrox.comand locate the title using the Searchbox or one of the title lists Then, on the book details page, click the Book Errata link On this page you canview all errata that has been submitted for this book and posted by Wrox editors A complete book listincluding links to each book’s errata is also available at www.wrox.com/misc-pages/booklist.shtml

If you don’t spot “your” error on the Book Errata page, go to www.wrox.com/contact/techsupport.shtmland complete the form there to send us the error you have found We’ll check the informationand, if appropriate, post a message to the book’s errata page and fix the problem in subsequent editions

of the book

Trang 40

For author and peer discussion, join the P2P forums at p2p.wrox.com The forums are a Web-based tem for you to post messages relating to Wrox books and related technologies and interact with otherreaders and technology users The forums offer a subscription feature to e-mail you topics of interest ofyour choosing when new posts are made to the forums Wrox authors, editors, other industry experts,and your fellow readers are present on these forums

sys-At http://p2p.wrox.comyou will find a number of different forums that will help you not only asyou read this book, but also as you develop your own applications To join the forums, just follow thesesteps:

1. Go to p2p.wrox.comand click the Register link

2. Read the terms of use and click Agree

3. Complete the required information to join as well as any optional information you want to vide, and click Submit

pro-4. You will receive an e-mail with information describing how to verify your account and plete the joining process

com-You can read messages in the forums without joining P2P but to post your own messages, you must join.

Once you join, you can post new messages and respond to messages other users post You can read sages at any time on the Web If you would like to have new messages from a particular forum e-mailed

mes-to you, click the Subscribe mes-to this Forum icon by the forum name in the forum listing

For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to tions about how the forum software works as well as many common questions specific to P2P and Wroxbooks To read the FAQs, click the FAQ link on any P2P page

Ngày đăng: 10/12/2013, 03:15

TỪ KHÓA LIÊN QUAN

w