VBA Developer’s Handbook

Ken Getz

Mike Gilbert

San Francisco · Paris · Düsseldorf · Soest

Associate Publisher: Amy Romanoff

Acquisitions Manager: Kristine Plachy

Acquisitions & Developmental Editor: Melanie Spiller

Editor: Dusty Bernard

Project Editor: Shelby Zimmerman

Technical Editor: David Shank

Book Designer: Patrick Dintino, Catalin Dulfu

Graphic Illustrator: Inbar Berman

Electronic Publishing Specialist: Debi Bevilacqua

Production Coordinator: Amy Eoff

Indexer: Matthew Spence

Cover Designer: Design Site

Cover Photographer: Color Photograph: The Image Bank

SYBEX is a registered trademark of SYBEX Inc.

Developer’s Handbook is a trademark of SYBEX Inc.

TRADEMARKS: SYBEX has attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following the capitalization style used by the manufacturer.

The author and publisher have made their best efforts to prepare this book, and the content is based upon final release software whenever possible. Portions of the manuscript may be based upon pre-release versions supplied by software manufacturer(s). The author and the publisher make no representation or warranties of any kind with regard to the completeness or accuracy of the contents herein and accept no liability of any kind including but not limited to performance, merchantability, fitness for any particular purpose, or any losses or damages of any kind caused or alleged to be caused directly or indirectly from this book.

Appendix A copyright ã1995-1997 by Gregory Reddick. All rights reserved. Used by permission. Portions of Chapters 1 and 2 are derived from tips and tricks written by this book’s authors, originally published in Smart Access, a monthly publication owned and published by Pinnacle Publishing, Inc.

Copyright ã1997 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501. World rights reserved. No part of this publication may be stored in a retrieval system, transmitted, or reproduced in any way, including but not limited to photocopy, photograph, magnetic or other record, without the prior agreement and written permission of the publisher.

Library of Congress Card Number: 97-65126

ISBN: 0-7821-1951-4

Manufactured in the United States of America

10 9 8 7 6 5 4 3 2 1

To Drs. Paul Bamberg and Harry Leitner, of Harvard University’s Extension program, who started me off on this amusing chapter of my life. Also, to Joan Weinstein, one of my first students, who (if nothing else) made sure I really knew what I was talking about.

—K.N.G.

To my parents, Robert and Donna Johnson, who provided me with the most important development tools—those for life. Also, to Robert and Rick Sterrett, for being the role models every young man needs.

—M.T.G.

About the Authors

Ken Getz

Ken Getz is a senior consultant with MCW Technologies, focusing on the Microsoft suite of products. He has received Microsoft’s MVP award (for providing technical support on CompuServe) for the years 1993 through 1996 and has co-written several books on developing applications using Microsoft Access, including the best-selling Microsoft Access 2 Developer’s Handbook and the Access 95 and 97 editions of that book. Ken is also a contributing editor to Smart Access and a frequent contributor to other developer publications. Currently, Ken spends a great deal of time traveling around the country for Application Developer’s Training Company, presenting training classes for Access and Visual Basic developers. He also speaks at many conferences and shows throughout the world, including Tech*Ed, Advisor Publication’s DevCon, Windows Solutions, and Access and VB Teach. When taking a break from the computer, he turns the chair around and handles another keyboard: the grand piano that fills the other half of his office. You can reach Ken on the Internet at keng@mcwtech.com.

Mike Gilbert

Mike Gilbert is a senior consultant with MCW Technologies, specializing in application development using Microsoft Access, Visual Basic, SQL Server, and Microsoft Office. He has worked with Microsoft on numerous ventures, including the Workgroup Templates, Office Developer’s Kit, and DevCast. He writes for several periodicals and is a contributing editor to Smart Access and Access/Visual Basic Advisor. Mike was co-author of Microsoft Access 95 Developer’s Handbook and Access 97 Developer’s Handbook. He is a trainer with Application Developer’s Training Company and a regular speaker at conferences such as Tech*Ed, Advisor Publication’s DevCon, and VB Teach. He spends what spare time he has enjoying the quiet, Southern life in Richmond, Virginia, with his wife Karen and their two cats, Chicago and Cairo. You can reach Mike on the Internet at mikeg2@mcwtech.com.