Microsoft® Office Access™ 2007 All-in-One Desk Reference For Dummies®
Published by
Wiley Publishing, Inc.
111 River St.
Hoboken, NJ 07030-5774
www.wiley.com
Copyright © 2007 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
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.
Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, 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. 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.
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, 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.
For technical support, please visit www.wiley.com/techsupport.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
Library of Congress Control Number: 2006925890
ISBN-13: 978-0-470-03649-5
ISBN-10: 0-470-03649-4
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
1B/QW/RS/QW/IN
Alan Simpson is the author of over 115 computer books on all sorts of topics: Windows, databases, Web-site design and development, programming, and network administration. His books are published throughout the world, in over a dozen languages, and have sold millions of copies. Though definitely in the techno-geek category, we let him contribute anyway because sometimes people like that come in handy.
Margaret Levine Young has co-authored several dozen computer books about the Internet, UNIX, WordPerfect, Access, and (stab from the past) PC-File and Javelin, including The Internet For Dummies (Wiley) and Windows XP Home Edition: The Complete Reference (Osborne/McGraw-Hill). She met her future husband Jordan in the R.E.S.I.S.T.O.R.S., a high-school computer club before there were high-school computer clubs. Her other passions are her children, music, Unitarian Universalism (www.uua.org), reading, and anything to do with cooking or eating.
Alison Barrows has authored or co-authored books on Windows, the Internet, Microsoft Access, WordPerfect, Lotus 1-2-3, and other topics. In addition to writing books, Alison writes and edits technical documentation and training material. In real life she hangs out with her “guys” — Parker, 6, and Mason, 4, and Evan 2 — and tries to carve out some time to practice yoga. Alison lives with her family in central Massachusetts.
April Wells is a graduate of the University of Pittsburgh and holds an MBA from West Texas A&M. She is a database administrator with expertise in a wide variety of enterprise database software programs, including Oracle, DB2, MySQL, and Access. She is the author of several books and white papers on database software and is a frequent public speaker, trainer, and consultant.
To Susan, Ashley, and Alec, as always. (AS)
To Matt, Parker, Mason, and Evan. (AB)
To the three people who are always there for me, always support me, and never let me down — my family, Larry, Adam, and Amandya. (AW)
We would like to acknowledge the care of Kyle Looper, Chris Morris, and Barry Childs-Helton, and all the others who shepherded this book through the editing and production process, as well as all the folks listed on the Publisher’s Acknowledgements page who worked on this book.
Alison thanks Dotty, Annie, and Matt for taking great care of my little guys so I can get work done. Matt (also known as Honey) gets special thanks as my hardware guru.
We’re proud of this book; please send us your comments through our online registration form located at www.dummies.com/register/.
Some of the people who helped bring this book to market include the following:
Acquisitions, Editorial, and Media Development
Senior Project Editor: Christopher Morris
Acquisitions Editor: Kyle Looper
Senior Copy Editor: Barry Childs-Helton
Technical Editor: Dan DiNicolo
Editorial Manager: Kevin Kirschner
Media Development Manager: Laura VanWinkle
Editorial Assistant: Amanda Foxworth
Senior Editorial Assistant: Cherie Case
Cartoons: Rich Tennant (www.the5thwave.com)
Composition Services
Project Coordinator: Kristie Rees
Layout and Graphics: Claudia Bell, Carl Byers, Stephanie D. Jumper, Barbara Moore, Barry Offringa, Lynsey Osborn, Heather Ryan, Rashell Smith, Erin Zeltner
Proofreaders: John Greenough, Susan Moritz, Jennifer Stanley
Indexer: Steve Rath
Anniversary Logo Design: Richard Pacifico
Special Help Linda Morris
Publishing and Editorial for Technology Dummies
Richard Swadley, Vice President and Executive Group Publisher
Andy Cummings, Vice President and Publisher
Mary Bednarek, Executive Acquisitions Director
Mary C. Corder, Editorial Director
Publishing for Consumer Dummies
Diane Graves Steele, Vice President and Publisher
Joyce Pepple, Acquisitions Director
Composition Services
Gerry Fahey, Vice President of Production Services
Debbie Stailey, Director of Composition Services
Title
Introduction
About Access 2007 All-in-One Desk Reference For Dummies
Conventions
Foolish Assumptions
What You Don’t Have to Read
Icons
Organization
Where to Go from Here
Book I : Essential Concepts
Chapter 1: Introducing Access 2007
The Six Types of Access Objects
Essential Database Concepts
Chapter 2: Getting Started, Getting Around
Running Access
Opening a Database
Playing with the Access Sample Databases
The Access Navigation Bar, Ribbon, and File menu
Mission Control: The Navigation Pane
Creating, Deleting, Renaming, Copying, and Printing Objects
Using Wizards
Getting Help
Saving Time with Keyboard Shortcuts
Chapter 3: Creating a Database from Templates
Finding Templates
Exploring a Template
Modifying Objects
Using a Template Database
Chapter 4: Designing Your Database the Relational Way
What Are Tables, Fields, and Keys?
What Are Relationships?
Designing a Database
Tips for Choosing Field Types
Storing Single Facts
Creating a Database
Book II : Tables
Chapter 1: Creating and Modifying Tables
About Table Views
Saving Your Table
Creating Tables for Your Data
Refining Your Table Using Design View
Formatting Fields with Field Properties
Defining the Primary Key
Indexing Fields
Printing Table Designs
Chapter 2: Entering and Editing Data in Datasheets
Looking at a Datasheet
Navigating the Data
Adding and Editing Records
Entering and Editing Hyperlinks
Using the Attachment Data Type
Checking Your Spelling
Using AutoCorrect for Faster Data Entry
Formatting a Datasheet
Taking Advantage of Subdatasheets
Adding a Totals Row to the Datasheet
Chapter 3: Sorting, Finding, and Filtering Data
Sorting the Rows of a Datasheet
Finding (and Replacing) Data
Filtering a Datasheet
Filtering Using Advanced Filter/Sort
Chapter 4: Importing and Exporting Data
Cutting, Copying, and Pasting
Importing or Linking to Data
Getting Data from Another Access Database
Getting Data Out of Access
Collecting Data with Outlook
Chapter 5: Avoiding “Garbage In, Garbage Out”
Finding the Right Tool to Keep Garbage Out
Using Input Masks to Validate and Format Data
Creating a Lookup Field
Validating Data As It’s Entered
Chapter 6: Relating Your Tables and Protecting Your Data
Creating Relationships and Protecting Your Data with Referential Integrity
Referential Integrity with Many-to-Many Relationships
Printing the Relationships Window
Book III : Queries
Chapter 1: Creating Select Queries
Types of Queries
Creating a Query in Design View
Creating a Query with the Simple Query Wizard
Viewing Your Query
Understanding Design View
Tips for Creating a Query
Editing a Query
Limiting Records with Criteria Expressions
Working with Multiple Related Tables
Working with Query Datasheets
Saving Queries
Chapter 2: Letting Queries Do the Math
Doing Math in Queries
Writing Expressions in Access
Using the Expression Builder
Going Beyond Basic Arithmetic
Date and Time Calculations
Manipulating Text with Expressions
Writing Decision-Making Expressions
Testing for Empty Fields
Creating Flexible Parameter Queries
Totals, Subtotals, Averages, and Such
Chapter 3: Doing Neat Things with Action Queries and Query Wizards
Creating Action Queries
Changing Data with Update Queries
Creating New Tables with Make-Table Queries
Moving Data from One Table to Another with Append Queries
Deleting Lots of Records with Delete Queries
Finding Unmatched Records with a Wizard
Finding Duplicate Records
Chapter 4: Viewing Your Data from All Angles Using Crosstabs and PivotTables
Aggregating Data in a Crosstab Query
Analyzing Data with PivotTables
Book IV : Forms
Chapter 1: Designing and Using Forms (and Reports)
Forms and Reports Are Secretly Related
Creating Forms with AutoForms and Wizards
Viewing a Form
Creating Forms (and Reports) in Design View
Configuring the Whole Form or Report
Sizing Forms
Storing Your Forms and Reports
Editing Data Using Forms
Chapter 2: Jazzing Up Your Forms (and Reports)
Taking Control of Your Form or Report
Making Controls That Display Text
Displaying Number, Currency, and Date Fields
Moving, Renaming, Resizing, Deleting, and Copying Controls
Formatting Your Text
Creating Check Boxes for Yes/No Fields
Neatening Up Your Controls
Adding Lines, Boxes, and Backgrounds
Controlling Cursor Movement in Your Form
Chapter 3: Creating Smarter Forms
Creating and Configuring Combo and List Boxes
Cool Looks for Yes/No Fields
Creating Option Groups
Creating Command Buttons
Making a Close Button
Adding and Linking Subforms
Adding Form Headers and Footers
Creating Tabbed Forms
You Can’t Type That Here!
Making Switchboards — A Friendly Face for Your Database
Chapter 4: Doing Calculations in Forms (and Reports)
Doing Elementary Calculations
Calculating and Formatting Numbers
Calculating and Formatting Dates
Calculating and Formatting Text
Displaying Values That Depend on Conditions
Adding Subtotals and Totals from Subforms
Formatting Calculated Controls
Book V : Reports
Chapter 1: Creating and Spiffing Up Reports
If You Know Forms, You Already Know Reports
Creating Reports Automagically
Editing Reports in Design View
Report Sections and How They Work
Formatting Tips and Tricks
Copying Forms to Reports
Adding and Formatting Subreports
Displaying Empty or Long Fields
Displaying Fields That May Be Empty
Creating Mailing Labels
Chapter 2: Printing Beautiful Reports
Viewing Your Report
Formatting the Page
Printing the Report
Sending a Report to Another Application
Chapter 3: Creating Charts and Graphs from Your Data
Displaying Information with Charts and Graphs
Analyzing Your Data Graphically with PivotCharts
Book VI : Macros: Automating Stuff in Access
Chapter 1: Making Macros Do the Work
What Is a Macro?
Creating and Editing Macros
Running Macros
Opening Databases That Contain Macros
Attaching Macros to Forms
Chapter 2: Making Macros Smarter
Only Run This If I Say So
Changing the Way Your Form Looks Dynamically
Displaying Forms and Datasheets
Setting Up Your Own Main Menu Form
Book VII : Database Administration
Chapter 1: Database Housekeeping
Compacting and Repairing Your Database
Making Backups
Converting Databases
Analyzing and Documenting Your Database
Loading and Managing Add-Ins
Locking Up Your Database as an ACCDE File
Chapter 2: Sharing the Fun — and the Database: Managing Multiuser Access
Putting Your Database Where They Can See It
Splitting Your Database into a Front End and a Back End
Putting Your Favorite Objects into Groups
Editing with Multiple Users
Chapter 3: Securing Your Access Database
Windows Security
Setting Startup Options
Password-Protecting Your Database
Granting Database Access to Specific Users
Book VIII : Programming in VBA
Chapter 1: What the Heck Is VBA?
Finding VBA Code
Enabling VBA Code
Using the Visual Basic Editor
Discovering Code as You Go
Chapter 2: Writing Code
How VBA Works
VBA Syntax
Declaring Module Options
Writing Your Own VBA Procedures
Typing and Editing in the Code Window
Testing and Running Your Code
Chapter 3: Writing Smarter Code
Creating Variables and Constants
Making Decisions in VBA Code
Executing the Same Code Repeatedly
Using Custom Functions
Chapter 4: Controlling Forms with VBA
Displaying Custom Messages
Opening Forms with DoCmd
Changing Form Controls with VBA
Understanding Objects and Collections
Chapter 5: Using SQL and Recordsets
Recordsets and Object Models
SQL and Recordsets
Running Action Queries from VBA
Chapter 6: Debugging Your Code
Considering Types of Program Errors
Fixing Compiler Errors
Trapping Runtime Errors
Dealing with Logical Errors
Appendix: Installing Microsoft Access
Activating Access
Repair, Reinstall, or Uninstall Access
: Further Reading