6048-4 FM.F
10/19/99
5:04 PM
Page i
Master Microsoft® Access 2000 V I S U A L L Y™
IDG’s
Series Curtis Frye
IDG Books Worldwide, Inc. An International Data Group Company Foster City, CA • Chicago, IL • Indianapolis, IN • New York, NY
6048-4 FM.F
10/19/99
5:04 PM
Page ii
Master Microsoft® Access 2000 VISUALLY™ Published by IDG Books Worldwide, Inc. An International Data Group Company 919 E. Hillsdale Blvd., Suite 400 Foster City, CA 94404 www.idgbooks.com (IDG Books Worldwide Web site) Copyright © 2000 IDG Books Worldwide, Inc. All rights reserved. No part of this book, including interior design, cover design, and icons, may be reproduced or transmitted in any form, by any means (electronic, photocopying, recording, or otherwise) without the prior written permission of the publisher. ISBN: 0-7645-6048-4 Printed in the United States of America 10 9 8 7 6 5 4 3 2 1 IP/RR/RS/22/FC Distributed in the United States by IDG Books Worldwide, Inc. Distributed by CDG Books Canada Inc. for Canada; by Transworld Publishers Limited in the United Kingdom; by IDG Norge Books for Norway; by IDG Sweden Books for Sweden; by IDG Books Australia Publishing Corporation Pty. Ltd. for Australia and New Zealand; by TransQuest Publishers Pte Ltd. for Singapore, Malaysia, Thailand, Indonesia, and Hong Kong; by Gotop Information, Inc. for Taiwan; by ICG Muse, Inc. for Japan; by Intersoft for South Africa; by Eyrolles for France; by International Thomson Publishing for Germany, Austria and Switzerland; by Distribuidora Cuspide for Argentina; by LR International for Brazil; by Galileo Libros for Chile; by Ediciones ZETA S.C.R. Ltda. for Peru; by WS Computer Publishing Corporation, Inc., for the Philippines; by Contemporanea de Ediciones for Venezuela; by Express Computer Distributors for the Caribbean and West Indies; by Micronesia Media Distributor, Inc. for Micronesia; by Chips Computadoras S.A. de C.V. for Mexico; by Editorial Norma de Panama S.A. for Panama; by American Bookshops for Finland. For general information on IDG Books Worldwide’s books in the U.S., please call our Consumer Customer Service department at 800-762-2974. For reseller information, including discounts and premium sales, please call our Reseller Customer Service department at 800-434-3422. For information on where to purchase IDG Books Worldwide’s books outside the U.S., please contact our International Sales department at 317-596-5530 or fax 317-596-5692. For consumer information on foreign language translations, please contact our Customer Service department at 800-434-3422, fax 317-596-5692, or e-mail
[email protected]. For information on licensing foreign or domestic rights, please phone +1-650-655-3109. For sales inquiries and special prices for bulk quantities, please contact our Sales department at 650-655-3200 or write to the address above. For information on using IDG Books Worldwide’s books in the classroom or for ordering examination copies, please contact our Educational Sales department at 800-434-2086 or fax 317-596-5499. LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK. THE PUBLISHER AND AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. THERE ARE NO WARRANTIES WHICH EXTEND BEYOND THE DESCRIPTIONS CONTAINED IN THIS PARAGRAPH. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS. THE ACCURACY AND COMPLETENESS OF THE INFORMATION PROVIDED HEREIN AND THE OPINIONS STATED HEREIN ARE NOT GUARANTEED OR WARRANTED TO PRODUCE ANY PARTICULAR RESULTS, AND THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY INDIVIDUAL. NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES.
For press review copies, author interviews, or other publicity information, please contact our Public Relations department at 650-655-3000 or fax 650-655-3299.
For authorization to photocopy items for corporate, personal, or educational use, please contact Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, or fax 978-750-4470. Library of Congress Cataloging-in-Publication Data 99-043747 Trademarks: All brand names and product names used in this book are trade names, service marks, trademarks, or registered trademarks of their respective owners. IDG Books Worldwide is not associated with any product or vendor mentioned in this book. is a trademark under exclusive license to IDG Books Worldwide, Inc., from International Data Group, Inc.
6048-4 FM.F
10/19/99
5:04 PM
Page iii
Welcome to the world of IDG Books Worldwide. IDG Books Worldwide, Inc., is a subsidiary of International Data Group, the world’s largest publisher of computer-related information and the leading global provider of information services on information technology. IDG was founded more than 30 years ago by Patrick J. McGovern and now employs more than 9,000 people worldwide. IDG publishes more than 290 computer publications in over 75 countries. More than 90 million people read one or more IDG publications each month. Launched in 1990, IDG Books Worldwide is today the #1 publisher of best-selling computer books in the United States. We are proud to have received eight awards from the Computer Press Association in recognition of editorial excellence and three from Computer Currents’ First Annual Readers’ Choice Awards. Our best-selling ...For Dummies® series has more than 50 million copies in print with translations in 31 languages. IDG Books Worldwide, through a joint venture with IDG’s Hi-Tech Beijing, became the first U.S. publisher to publish a computer book in the People’s Republic of China. In record time, IDG Books Worldwide has become the first choice for millions of readers around the world who want to learn how to better manage their businesses. Our mission is simple: Every one of our books is designed to bring extra value and skill-building instructions to the reader. Our books are written by experts who understand and care about our readers. The knowledge base of our editorial staff comes from years of experience in publishing, education, and journalism — experience we use to produce books to carry us into the new millennium. In short, we care about books, so we attract the best people. We devote special attention to details such as audience, interior design, use of icons, and illustrations. And because we use an efficient process of authoring, editing, and desktop publishing our books electronically, we can spend more time ensuring superior content and less time on the technicalities of making books. You can count on our commitment to deliver high-quality books at competitive prices on topics you want to read about. At IDG Books Worldwide, we continue in the IDG tradition of delivering quality for more than 30 years. You’ll find no better book on a subject than one from IDG Books Worldwide.
John Kilcullen Chairman and CEO IDG Books Worldwide, Inc.
Eighth Annual Computer Press Awards 1992
Ninth Annual Computer Press Awards 1993
Steven Berkowitz President and Publisher IDG Books Worldwide, Inc.
Tenth Annual Computer Press Awards 1994
Eleventh Annual Computer Press Awards 1995
IDG is the world’s leading IT media, research and exposition company. Founded in 1964, IDG had 1997 revenues of $2.05 billion and has more than 9,000 employees worldwide. IDG offers the widest range of media options that reach IT buyers in 75 countries representing 95% of worldwide IT spending. IDG’s diverse product and services portfolio spans six key areas including print publishing, online publishing, expositions and conferences, market research, education and training, and global marketing services. More than 90 million people read one or more of IDG’s 290 magazines and newspapers, including IDG’s leading global brands — Computerworld, PC World, Network World, Macworld and the Channel World family of publications. IDG Books Worldwide is one of the fastest-growing computer book publishers in the world, with more than 700 titles in 36 languages. The “...For Dummies®” series alone has more than 50 million copies in print. IDG offers online users the largest network of technology-specific Web sites around the world through IDG.net (http://www.idg.net), which comprises more than 225 targeted Web sites in 55 countries worldwide. International Data Corporation (IDC) is the world’s largest provider of information technology data, analysis and consulting, with research centers in over 41 countries and more than 400 research analysts worldwide. IDG World Expo is a leading producer of more than 168 globally branded conferences and expositions in 35 countries including E3 (Electronic Entertainment Expo), Macworld Expo, ComNet, Windows World Expo, ICE (Internet Commerce Expo), Agenda, DEMO, and Spotlight. IDG’s training subsidiary, ExecuTrain, is the world’s largest computer training company, with more than 230 locations worldwide and 785 training courses. IDG Marketing Services helps industry-leading IT companies build international brand recognition by developing global integrated marketing programs via IDG’s print, online and exposition products worldwide. Further information about the company can be 1/24/99 found at www.idg.com.
6048-4 FM.F
10/19/99
5:04 PM
Page iv
CREDITS Acquisitions Editor
Book Designer
Michael Roney
MaranGraphics™
Development Editors
Production
Melanie Feinberg Denise Santoro Chip Wescott Paul Winters
IDG Books Worldwide Production
Technical Editor
Maryann Brown Copy Editors
Zoe Brymer Corey Cohen Ami Knox Dennis Weaver
Proofreading and Indexing
Publication Services, Inc.
6048-4 FM.F
10/19/99
5:04 PM
Page v
To my twin brother, Doug.
6048-4 FM.F
10/19/99
5:04 PM
Page vi
6048-4 FM.F
10/19/99
5:04 PM
Page vii
ACKNOWLEDGMENTS This project was a huge undertaking, and I thank Michael Roney, Senior Acquisitions Editor, for putting his faith in me to get the job done. Various editors shared the editing load — thanks to Denise Santoro, Chip Wescott, Paul Winters, and Melanie Feinberg of IDG for their advice and efforts, as well as Zoe Brymer, Corey Cohen, Ami Knox, and Dennis Weaver, who provided valuable copy editing. I’d also like to acknowledge many folks who produced the book’s graphics, laid out the pages (both for the printed page and for Web browsers), and prepared the companion CD. Special thanks go to Maryann Brown, my technical editor. Her sharp eye and experience kept my writing on target and my wits sharp. Finally, I’d also like to thank my agent, Neil Salkind, as well as Sherry, David, and the rest of the folks at StudioB. Without them I would neither have gotten the opportunity to write this book nor have kept my spirits up as I went along.
Curtis Frye
10/19/99
5:04 PM
Page viii
MICROSOFT ACCESS 2000
®
6048-4 FM.F
I
FIRST STEPS
1. Getting Started 2. Create a New Database
II
CREATE TABLES, FORMS, AND REPORTS
3. Create Tables 4. Enter and Edit Table Data 5. Find and Sort Table Data 6. Establish Keys and Relationships 7. Import, Export, and Link Table Data 8. Print 9. Create Queries 10. Create Advanced Queries 11. Create Forms 12. Create Reports 13. Customize Forms and Reports 14. Create Charts 15. Create Pivot Tables 16. Create Macros
6048-4 FM.F
10/19/99
5:04 PM
Page ix
WHAT’S INSIDE Appendix: Using the CD-ROM
III
BUILD AN APPLICATION
End User License Agreement
17. Create a Project 18. Create an Application 19. Create Switchboards 20. Create Custom Toolbars and Menus 21. Create Simple Visual Basic Procedures
IV
Index
COLLABORATE USING ACCESS 2000
22. Database Administration and Security 23. Publish on the Web Using Data Access Pages
CD-ROM Installation Instructions
6048-4 FM.F
10/19/99
5:04 PM
Page x
TABLE OF CONTENTS
I
FIRST STEPS 1 GETTING STARTED Introducing Access 2000 ......................................................4 Using the Mouse....................................................................8 Shortcut Menus ....................................................................9 Start Access 2000 from the Start Menu ..............................10 Open a Sample Database ....................................................12 Maximize or Minimize a Window ......................................14 Move or Size a Window ......................................................16 Switch Between Windows ..................................................18 Arrange Windows................................................................20 Getting Help: Where to Get Help ........................................22 Getting Help: Using the Office Assistant ............................24 Getting Help: Using the Contents Tab ................................26 Getting Help: Using the Index Tab......................................28 Getting Help: Using the Answer Wizard Tab ......................30 2 CREATE A NEW DATABASE Create a New Database ........................................................32 Using a New Database Wizard: Launch the Wizard ..............................................................34 Using a New Database Wizard: Add Fields............................................................................36 Create a Blank Database ......................................................42 Refresh the Database Window ............................................44 Open, Organize, and Delete Files: Open ............................46 Open, Organize, and Delete Files: Organize........................48 Open, Organize, and Delete Files: Delete............................50
6048-4 FM.F
10/19/99
5:04 PM
II
Page xi
CREATE TABLES, FORMS, AND REPORTS 3 CREATE TABLES Introducing Tables ..............................................................60 Data Types ..........................................................................63 Create a New Table Using the Wizard ................................66 Adding Fields ......................................................................68 Rename a Field ....................................................................70 Delete a Field ......................................................................71 Setting a Key and Creating the Table ..................................72 Create a New Table from Scratch ........................................74 Accept the Default Data Type ..............................................76 Enter a Field Description ....................................................77 Insert a Field........................................................................78 Delete a Field ......................................................................79 Rearrange Fields ..................................................................80 Assign or Change a Data Type ............................................82 Select a Data Format............................................................84 Change Field Size ................................................................86 Add a Caption......................................................................87 Assign a Default Value ........................................................88 Require Data Entry ..............................................................89 Allow Zero-Length Strings ..................................................90 Create a Yes-No Field ..........................................................91 Change the Number of Decimal Places ..............................92 Create an Index ..................................................................93 Add Pictures to Records ......................................................94 Create a Lookup Column ....................................................96 Add a Validation Rule ........................................................100 Create an Input Mask ........................................................102
6048-4 FM.F
10/19/99
5:04 PM
Page xii
TABLE OF CONTENTS 3 CREATE TABLES (CONTINUED) Save a Table ......................................................................104 Open a Table......................................................................105 Close a Table......................................................................106 Rename a Table..................................................................107 Copy a Table from One Database to Another ....................108 Copy a Table Within a Database........................................110 Delete a Table ....................................................................111 4 ENTER AND EDIT TABLE DATA Enter and Edit Table Data..................................................112 Open a Table in Datasheet View ........................................114 Switch Between Datasheet View and Design View ............116 Enter Data into a Table ......................................................118 Move Through Records: Move Forward or Back One Record ..................................120 Move Through Records: Move to the First or Last Record ......................................122 Scroll Through Data ..........................................................124 Scroll Through Data: Moving Up and Down One Page at a Time ......................126 Zoom into a Cell................................................................128 Add a Record ....................................................................130 Delete a Record..................................................................131 Edit Data............................................................................132 Copy Data ..........................................................................134 Move Data..........................................................................136 Check Spelling: Open the Spelling Window ..............................................138 Check Spelling: Accept the First Suggestion ..............................................139
6048-4 FM.F
10/19/99
5:04 PM
Page xiii
Check Spelling: Accept a Suggestion from the List ....................................140 Check Spelling: Enter a Correction Manually ............................................141 Check Spelling: Changing All Occurrences of a Misspelling ......................142 Check Spelling: Ignore a Word..........................................143 Check Spelling: Ignore All Occurrences of a Word ..........144 Check Spelling: Ignore a Field ..........................................145 Check Spelling: Working with Dictionaries ......................146 Check Spelling: Create a Custom Dictionary ....................147 Check Spelling: Undo Last Change ..................................148 Check Spelling: Exiting Spell Check ................................149 Change Column Width ....................................................150 Change Row Height ..........................................................151 Change Font of Data..........................................................152 Change Cell Appearance ..................................................153 Hide a Field ......................................................................154 Unhide a Field ..................................................................156 Freeze a Column................................................................158 Rename a Column ............................................................159 Insert and Name a Text Column........................................160 Insert and Name a Hyperlink Column ..............................162 Create a Hyperlink Within a Table ....................................164 5 FIND AND SORT TABLE DATA Find, Sort, and Filter Table Data ......................................166 Introducing Wildcards and Expression Operators ............169 Find Data ..........................................................................170 Replace Data ......................................................................172 Sort Records ......................................................................174 Sort Using Multiple Criteria ..............................................176
6048-4 FM.F
10/19/99
5:04 PM
Page xiv
TABLE OF CONTENTS 5 FIND AND SORT TABLE DATA (CONTINUED) Filter Records by Selection ................................................180 Filter Records by Exclusion ..............................................181 Filter by Form ..................................................................182 Create Advanced Filters ....................................................184 Create Advanced Filters: Sort Within a Filter............................................................186 Remove a Filter..................................................................188 Reapply a Filter..................................................................189 6 ESTABLISH KEYS AND RELATIONSHIPS Establish Keys and Relationships ......................................190 Define a Primary Key ........................................................192 Create a Relationship ........................................................194 Enforce Referential Integrity..............................................198 View Relationships ............................................................200 Edit Relationships..............................................................201 Delete Relationships ..........................................................202 Save Relationships ............................................................203 Hide a Table in the Relationship Builder ..........................204 Clear the Relationship Builder ..........................................205 Show Direct Relationships of a Table ................................206 Show All Relationships......................................................207 7 IMPORT, EXPORT, AND LINK TABLE DATA Import, Export, and Link Table Data ................................208 Export Tables to Another Access Database ......................210 Export Tables to Another Database ..................................212 Import a Table ..................................................................214 Export Data to a Text File..................................................216 Link a Table ......................................................................220
6048-4 FM.F
10/19/99
5:04 PM
Page xv
Copy Cells to a Microsoft Word Table ..............................222 Copy Cells to a Microsoft Excel Spreadsheet ....................224 8 PRINT Print ..................................................................................226 Preview Before Printing ....................................................230 Zoom in Print Preview ......................................................232 Preview More Than One Page ..........................................234 Change Page Setup: Change a Margin................................................................236 Change Page Setup: Change Page Orientation ..................................................238 Pick a Printer ....................................................................240 Print Information ..............................................................244 Print Selected Records ......................................................246 Print Mailing Labels ..........................................................248 Print the Relationships Window ......................................254 9 CREATE QUERIES Create Queries ..................................................................256 Use the Simple Query Wizard ..........................................258 Create a Query from Scratch: Select Tables ......................262 Create a Query from Scratch: Select Fields ......................264 Create a Query from Scratch: Set Criteria ........................266 Create a Query from Scratch: Sort Within a Query ..........267 Select All Fields in a Table ................................................268 Clear the Grid....................................................................269 Delete a Field ....................................................................270 Insert a Field......................................................................271 Change from Design View to Datasheet View ..................272 Change from Datasheet View to Design View ..................273 Hide a Field ......................................................................274
6048-4 FM.F
10/19/99
5:04 PM
Page xvi
TABLE OF CONTENTS 9 CREATE QUERIES (CONTINUED) Rearrange Fields ................................................................276 Show a Field ......................................................................278 Save a Query ......................................................................280 Close a Query ....................................................................281 Open a Query in Design View ..........................................282 Open a Query in Datasheet View ......................................283 Rename a Query ................................................................284 Delete a Query ..................................................................285 10 CREATE ADVANCED QUERIES Create Advanced Queries...................................................286 Use Queries to Perform Calculations ................................288 Show the Top Values in a Field..........................................290 Show the Bottom Values in a Field....................................292 Create a Crosstab Query....................................................294 Create an Update Query ....................................................300 Check and Run Your Query ..............................................302 Create an Append Query ..................................................304 Create a Make-Table Query ..............................................308 Use Queries to Summarize Data ........................................312 Find Unmatched Records ..................................................318 Display the SQL Version of a Query ..................................322 Detect Minimum and Maximum Values............................324 Find Duplicate Records ....................................................328 11 CREATE FORMS Create Forms ....................................................................332 Create a Form Using an AutoForm ..................................334 Create a Tabular AutoForm Using the Form Wizard ........336 Create a Columnar Form Using an AutoForm..................338 Create a Datasheet Form Using an AutoForm ..................340
6048-4 FM.F
10/19/99
5:04 PM
Page xvii
Create a Justified Form Using the Form Wizard ..............342 Open a Form in Form View ..............................................346 Open a Form in Design View ............................................347 Change the View of a Form ..............................................348 Close a Form ....................................................................351 Move Forward or Back One Record ..................................352 Move to the First or Last Record ......................................354 Move to a Specific Record ................................................356 Add a Record ....................................................................357 Delete a Record..................................................................358 Enter Data into an Empty Cell ..........................................360 Replace Cell Data ..............................................................361 Enter Data in a Lookup Field ............................................362 Move to the Next Field......................................................363 Move to the Previous Field................................................364 Save a Form ......................................................................365 Rename a Form..................................................................366 Delete a Form ....................................................................367 12 CREATE REPORTS Create Reports ..................................................................368 Create an AutoReport ........................................................370 Create a Tabular AutoReport ............................................372 Create a Columnar AutoReport ........................................374 Create a Report Using the Report Wizard ........................376 Change from Design View to Print Preview ......................384 Change from Print Preview to Design View ......................385 Save a Report ....................................................................386 Save a Report Under Another Name..................................387 Open a Report....................................................................388 Close a Report ..................................................................389 Rename a Report................................................................390 Delete a Report ..................................................................391
6048-4 FM.F
10/19/99
5:04 PM
Page xviii
TABLE OF CONTENTS 13 CUSTOMIZE FORMS AND REPORTS Customize Forms and Reports ..........................................392 Select an Autoformat ........................................................396 Display the Toolbox ..........................................................398 Hide the Toolbox ..............................................................399 Create a Label ....................................................................400 Create a Text Box ..............................................................402 Create a Toggle Button ......................................................404 Create an Option Button ..................................................405 Create a Check Box ..........................................................406 Insert a Page Break ............................................................407 Create an Option Group ....................................................408 Create a Combo Box..........................................................412 Create a List Box................................................................416 Create a Command Button ................................................420 Insert an Image ..................................................................424 Insert and Resize an Unbound Object ..............................426 Create a Tab Control..........................................................430 Create a Tab Control: Move to a Page ..............................431 Create a Tab Control: Add a Page......................................432 Create a Tab Control: Delete a Page ..................................433 Create a Tab Control: Name a Page ..................................434 Create a Tab Control: Change Page Order ........................436 Create a Subform or Subreport..........................................438 Add a Line ........................................................................440 Add a Rectangle ................................................................441 Change the Color of a Line ..............................................442 Change the Fill/Back Color of an Object ..........................443 Change the Border Color of an Object ..............................444 Change the Special Effect of an Object..............................445 Edit Text ............................................................................446 Change the Color of Text ..................................................447
6048-4 FM.F
10/19/99
5:04 PM
Page xix
Change the Font of a Text Selection..................................448 Change the Size of Selected Text ......................................449 Resize a Control ................................................................450 Move a Control..................................................................452 Duplicate a Control ..........................................................453 Delete a Control ................................................................454 Paste a Control ..................................................................455 Use the Rulers and Grid: Select All Objects Between Two Points on a Ruler ............456 Use the Rulers and Grid: Turning Snap to Grid On and Off......................................458 Group and Ungroup Controls ..........................................460 Align Controls: Align Controls by an Edge ................................................462 Align Controls: Space Controls Evenly ......................................................463 Align Controls: Increase Spacing ................................................................464 Align Controls: Decrease Spacing ..............................................................465 Add Headers and Footers: Add a Page Header and Footer ..........................................466 Add a Form Header and Footer ........................................467 Name a Control ................................................................468 Select a Control from the Object Combo Box ..................469 Insert the Date and Time ..................................................470 Insert Page Numbers ........................................................471 Move an Object to the Front or Back ................................472 Insert a Hyperlink..............................................................474 14 CREATE CHARTS Create Charts ....................................................................480 Create a Chart....................................................................482
6048-4 FM.F
10/19/99
5:04 PM
Page xx
TABLE OF CONTENTS 14 CREATE CHARTS (CONTINUED) Use the Chart Wizard: Select Fields ......................................................................484 Use the Chart Wizard: Select and Preview a Chart Type........................................486 Use the Chart Wizard: Assign Axis Value Sources ................................................488 Use the Chart Wizard: Changing Your Chart from Record to Record ..................489 Use the Chart Wizard: Complete the Chart ..........................................................490 Delete a Chart....................................................................491 Open a Chart ....................................................................492 Close a Chart ....................................................................494 Edit a Chart: Change Colors of Chart Elements ....................................496 Edit a Chart: Edit Chart Data..................................................................498 Edit a Chart: Show Data Labels ..............................................................499 Edit a Chart: Show the Data Table ..........................................................500 Edit a Chart: Add Axis Titles ..................................................................502 Edit a Chart: Show and Place the Legend ..............................................504 15 CREATE PIVOT TABLES Create Pivot Tables ............................................................502 Examine a Pivot Table ......................................................504 Pivot a Pivot Table ............................................................506 Filter a Pivot Table ............................................................507 Create a Pivot Table ..........................................................508
6048-4 FM.F
10/19/99
5:04 PM
Page xxi
Create a Pivot Table: Define Your Pivot Table’s Layout ......................................512 16 CREATE MACROS Introducing Macros ..........................................................516 Create and Save a Macro....................................................518 Open a Macro ....................................................................520 Close a Macro ....................................................................521 Define Macro Actions ........................................................522 Group Macros ....................................................................524 Insert a Row ......................................................................526 Delete a Row......................................................................527 Debug a Macro ..................................................................528 Make a Macro Action Conditional ....................................530 Invoke Controls from Macros: Create a Source Control ....................................................532 Invoke Controls from Macros: Create a Target Control ....................................................534 Invoke Controls from Macros: Create a Sample Macro ......................................................536 Invoke Controls from Macros: Create a Trigger Control ....................................................538 Invoke Controls from Macros: Run the Macro ..................................................................540
III
BUILD AN APPLICATION 17 CREATE A PROJECT Create a Project..................................................................544 Create a Project Based on an Existing Database ..........................................546
6048-4 FM.F
10/19/99
5:04 PM
Page xxii
TABLE OF CONTENTS Create a Project Not Based on an Existing Database ..................................548 18 CREATE AN APPLICATION Create an Application ........................................................550 View and Assign Event Properties for a Form or Report..........................................................552 19 CREATE SWITCHBOARDS Create Switchboards ..........................................................554 Modify a Switchboard Created by the Database Wizard ..........................................................556 Create a New Switchboard Page ........................................560 Add Items to a Switchboard Page ......................................562 Delete a Switchboard Page Item ........................................564 Delete a Switchboard Page ................................................565 Change Switchboard Art....................................................566 Create a Custom Switchboard ..........................................568 20 CREATE CUSTOM TOOLBARS AND MENUS Create Custom Toolbars and Menus ................................572 Show or Hide an Existing Toolbar ....................................574 Create a Custom Toolbar ..................................................576 Add Buttons to a Toolbar ..................................................578 Move or Copy a Toolbar Button ........................................580 Create a Custom Toolbar Button ......................................582 Change and Reset Button Images ......................................584 Edit a Button Image ..........................................................586 Create a Custom Menu Bar................................................588 Add a Built-In Menu to a Custom Menu Bar ......................................................590 Add a Custom Menu to a Menu Bar ..................................592
6048-4 FM.F
10/19/99
5:04 PM
Page xxiii
Add an Item to a Menu......................................................594 Create a Shortcut Menu ....................................................596 Attach a Menu to a Form or Report ..................................598 21 CREATE SIMPLE VISUAL BASIC PROCEDURES Create Simple Visual Basic Procedures..............................600 Familiarize Yourself with Visual Basic ..............................602 Examine a Sample Procedure ............................................604 Close the Visual Basic Editor ............................................605 View All Predefined VBA Procedures ................................606 Add a Predefined Procedure to a Module..........................608 Create a Sample Procedure ................................................610
IV
COLLABORATE USING ACCESS 2000 22 DATABASE ADMINISTRATION AND SECURITY Database Administration and Security ..............................616 Back Up a Database ..........................................................618 Restore a Database ............................................................620 Replicating a Database ......................................................622 Create a Partial Replica......................................................624 Document a Database ........................................................628 Encrypt a Database ............................................................630 Decrypt a Database ............................................................631 Create User Accounts ........................................................632 Create a New User Group..................................................634 Add a User to a Group ......................................................636 Use the User-Level Security Wizard ..................................638 Use the User-Level Security Wizard: Add Users to Groups ........................................................642
6048-4 FM.F
10/19/99
5:04 PM
Page xxiv
TABLE OF CONTENTS 23 PUBLISH ON THE WEB USING DATA ACCESS PAGES Publish on the Web Using Data Access Pages....................................................644 Create a Data Access Page Using the Wizard ..............................................................648 Create a Data Access Page in Design View ........................652 Edit an Existing Data Access Page ....................................653 Add Fields to a Data Access Page ......................................654 Group Fields on a Data Access Page..................................656 Add and Remove Group Captions ....................................658 Calculate a Value for One Record......................................660 Add a Pivot Table to a Data Access Page ..........................662 Add a Worksheet Control to a Data Access Page ........................................................664 Add a Background Picture to a Data Access Page ........................................................666 Appendix: Using the CD-ROM..........................................668 Index..................................................................................672 End User License Agreement ............................................684 CD-ROM Installation Instructions ....................................686
6048-4 FM.F
10/19/99
5:04 PM
Page xxv
6048-4 ch01.F
10/19/99
1:27 PM
Page 4
1
CHAPTER 1: GETTING STARTED FIRST STEPS
1 CHAPTER 1: ACCESS BASICS
INTRODUCING ACCESS 2000 icrosoft Access is a database program. You use it to enter, organize, and sort your vital information smoothly and efficiently. Access manages your data and creates detailed
M
reports you can customize with ease. Access makes it easy to use your computer to track important business or personal information.
Projects and Databases–
Creating Custom Forms and Reports–
When you need a place to store information, you create a database. You can open, copy, move, rename, and delete your databases. If you accidentally delete a database or any of its components, you can usually restore the file from the recycle bin. You can also create projects, which allow users to look at and ask questions about the database without necessarily being able to change the underlying information. You can also use advanced cutand-paste techniques, like object embedding and linking, to share Access data with your other files and programs. Projects
You can create attractive screens that make entering information into or reading information from your databases pleasantly simple. Creating forms, which can easily be made more attractive than standard paper forms, makes data entry much quicker and more enjoyable. Reports do the same for your printed records by creating easily understood summaries of your information. Monthly Sales
Sales
Name
Date
John
$10,398
Amy
$12,257
Susan
$11,076
Alan
$9362
Ralph
$9877
Amount
4
6048-4 ch01.F
10/19/99
1:27 PM
Page 5
I Documenting Your Database
Customization and Personalization You can change the appearance and behavior of Access to suit your needs: Choose which toolbars to display and place them in more convenient locations on the screen; display database elements by name, small icon, or large icon; and create shortcuts to elements you use frequently. Creating custom toolbars and menus makes it easy for you to find your favorite files and commands instantly. You can also choose the colors and font Access uses to display your information, what margins will be used for forms and reports, and whether Access should use sound to reinforce its feedback. Working with Other Databases Access allows you to work with information from other commercial database programs. You can import data directly from other programs, link to it from within a table, or export your Access data to other databases like Paradox, dBase, and FoxPro. Access has a wide variety of filters built in to make transferring data a snap. You can also export data to text files and spreadsheets.
$10,500
$10,500
$10,500
$10,500
$10,500
$10,500
$10,500
$10,500
$10,500
$10,500
FIRST STEPS
The Access Documenter is a powerful tool to illustrate how the elements of your database work together. With the Documenter, you can print out charts that help others understand your database’s structure. The charts also give you a handy reference to make sure you’ve included everything you need in the database. You can compare the graphical description of your design with printed lists, allowing you to spot areas that need work.
Making Custom Applications Creating standalone applications is a great way to ensure your database can be used by anyone with a computer. You can make using your application easy with custom switchboards, which allow users to effortlessly switch between different database tasks. Those tasks include adding new records to the database or generating a report. You can also create custom dialog boxes for your applications, helping users perform tasks that go beyond the basic abilities included in Access. You can also extend your application’s usefulness by writing macros or Visual Basic routines. Administering Your Database Access gives you a variety of ways to improve your database’s performance. You can find out how fast your database runs by using the Performance Analyzer. You can also back up your database, repair a damaged database, and, if necessary, restore your database from a backup. Access lets you update copies of your databases, create partial copies, and view vital information about your databases. You can also compact large files, saving disk space without losing any of your important information.
CONTINUED
5
6048-4 ch01.F
10/19/99
1:27 PM
1
Page 6
CHAPTER 1: GETTING STARTED
INTRODUCING ACCESS 2000 Making Your Database Secure– You can make your database as secure as you like with Access. Creating user groups with separate permissions is easy, especially if you run Access under Windows NT, an operating system with permissions and built-in user groups. You can also ensure the database will not be harmed if two users attempt to change a record at the same time. If security is very important, you can encrypt your database and require users to enter a password when opening any file associated with your database.
Sensitive Data
Access Projects– Microsoft Access lets you build powerful databases, but it also gives you the ability to develop attractive user interfaces for databases designed in programs other than Access. One such program is Microsoft’s SQL Server 6.5, which is available from Microsoft on a trial basis. Access projects are similar to databases in that the user can enter data and generate reports through forms you provide, but the user does not have access to the underlying tables that make up the database. Projects are especially appropriate for users and 6
CONTINUED
administrators on a network, where the database might reside on a different machine than a user’s account. Data Access Pages– Data access pages are dynamic Hypertext Markup Language (HTML) documents linked to a database. While data access pages can be used like forms, they are designed to be used with a Web browser like Internet Explorer 5.0 or later. Data access pages are maintained in the file system, rather than being stored within the database itself. Data access pages give you an easy way to allow Internet or local network users to examine the information in your database. You can create data access pages with an intuitive wizard that makes publishing your information on the Web simple.
6048-4 ch01.F
10/19/99
1:27 PM
Page 7
I Modified Database Window–
FIRST STEPS
The main Access window has been redesigned for the following three reasons: to address user concerns from previous versions of Access, to enable inclusion of objects new to Access 2000, and to make the Access 2000 interface consistent with the other Microsoft Office programs. In particular, Access 2000 includes a new section for data access pages; a new section for Views, Stored Procedures, and Database Diagrams; a user interface consistent with Microsoft Outlook; the ability to create new objects from the object list; and tools to create groups of diverse objects.
To improve product stability and integrate the Visual Basic Editor, Access’s designers changed how the program handles multiple users simultaneously accessing a database. You can still allow multiple-user access, but only one user at a time can change the database’s design. Online Collaboration– If you have installed the Web Server Extensions available with Microsoft Office, Access 2000 allows you to collaborate with other users over the Internet, an intranet, or a local network. These network discussions are stored separately from the document being discussed, but they are transparently merged with the document when you view it. Online discussions help users exchange opinions about databases and projects while they are still in production, and stores user notes in an easily accessed, integrated format. No one needs to chase paper copies of database designs and tables around the office. Administrators may also set up subscription services to deliver updates and notes to important users. New York
London
Programmability– Previous versions of Access had a different Visual Basic programming environment than PowerPoint, Word, and Excel. Access 2000 has been redesigned so that Visual Basic modules are found in the Editor instead of the Module window. Access 2000 also includes a new Microsoft Script Editor. You can find the Script Editor under the Tools menu. As with the Visual Basic Editor, the Script Editor is consistent across all Office applications.
Chicago
Server
7
6048-4 ch01.F
10/19/99
1
1:27 PM
Page 8
CHAPTER 1: GETTING STARTED
USING THE MOUSE
mouse is a handheld device that lets you select and move items on your screen. When you move the mouse on your desk, the mouse pointer on your screen moves in the same
A
direction. The mouse pointer assumes different shapes, such as an arrow pointer or a blinking line, depending on its location on the screen and the task you are performing.
Click–
Drag and Drop–
Press and release the left mouse button. A click is used to select an item on the screen. Right-Click– Press and release the right mouse button. A right-click is used to display a list of commands you can use to work with an item. Cleaning the Mouse– You should occasionally remove the small cover on the bottom of the mouse and clean the ball inside the mouse with rubbing alcohol. Make sure you also remove dust and dirt from the inside of the mouse with a cotton swab to help ensure smooth motion. Double-Click– Quickly press and release the left mouse button twice. A double-click is used to open a document or create a new one.
8
Position the mouse pointer over an item on the screen and then press and hold down the left mouse button. Still holding down the button, move the mouse to where you want to place the item and then release the button. Dragging and dropping makes it easy to move an item to a new location. Mouse Pads– A mouse pad provides a smooth, nonslip surface for moving the mouse. A mouse pad also reduces the amount of dirt that enters the mouse and protects your desk from scratches. Hard plastic mouse pads attract less dirt and provide a smoother surface than fabric mouse pads.
1
6048-4 ch01.F
10/19/99
1:27 PM
Page 9
I
FIRST STEPS
1
CHAPTER 1: GETTING STARTED
SHORTCUT MENUS hen you right-click most items in Windows, a shortcut menu appears. The shortcut menu includes commands appropriate for the item. Access makes extensive use of shortcut menus.
W
⁄ Right-click an item of interest.
For example, the shortcut menu for an Access form includes commands to Cut, Copy, Delete, Rename, Print, Export, or change the Properties of the form. Similar commands are available for reports, queries, tables, and other Access objects.
■ A menu appears, displaying the commands available for the item.
The default action for Access database objects is performed when you double-click an object. In almost every case, the default action will be to open the object so you can examine and modify it.
■ If you click a command with an arrow, a submenu of additional commands appears.
■ To close the menu without selecting a command, click outside the menu or press the Alt key.
¤ Click the command you want to use.
9
6048-4 ch01.F
10/19/99
1:27 PM
1
Page 10
CHAPTER 1: GETTING STARTED
START ACCESS 2000 FROM THE START MENU ou can start Access 2000 by using the Start button. The Start button appears on the taskbar and is the easiest way to launch Access and other programs. When you click the Start button, a menu with commands for Programs, Documents,
Y
⁄ Click Start on the taskbar. ■ The Start menu appears.
10
Settings, and a few other items appears. Clicking the Programs command opens a submenu with your installed programs, including Access. While you’re in Access, you can still use the Start button to quickly open another program, such as Excel, Word, or
Note: You can also press and hold down the Ctrl key and then press the Esc key to display the Start menu. If you have a windows key on your keyboard, you can press it to display the Start menu.
PowerPoint, without having to close or minimize Access. After you start Access, a button for the program appears on the taskbar. To return to Access from another program, click the button.
¤ Click Programs to display the programs available on your computer.
‹ Click the program you want to start. In this case, choose Access.
6048-4 ch01.F
10/19/99
1:27 PM
Page 11
I
Can I rearrange the items in the Start menu? You can rearrange the items in the Start menu by clicking on the Start button and choosing Settings ➪ Taskbar. You can then rearrange, add, and delete items on the Start menu.
■ Access starts.
FIRST STEPS
How do I close the Start menu? To close the Start menu, press the Esc key or click outside the menu area.
Is there an easier way to add an item to the Start menu? Yes. Just find the file you want to add and drag it to the Start button. Do not release the mouse button; the Start menu will appear. You can then drag the file to the location you want on the Start menu or any submenu.
› Click on the Cancel
■ Access shuts down and
■ The button for Access
button and then the Close box to close Access.
disappears from your screen.
disappears from the taskbar.
11
6048-4 ch01.F
10/19/99
1:27 PM
1
Page 12
CHAPTER 1: GETTING STARTED
OPEN A SAMPLE DATABASE ou can learn a lot about databases by looking at the sample Northwind database included with Access 2000. The Northwind database includes tables, forms, reports, and queries that can serve as models for your own designs. You should take the time to examine each element of the
Y
⁄ Start Access.
Northwind database. For example, you can find out about designing tables by comparing the different tables included in the Northwind database. You can also examine how the database forms correspond to tables of the same name, and how the designer used color and spacing to make the forms easy to use.
Looking at the reports in the Northwind database will give you a good idea of how you can sort and organize information on inventory, customers, and your customers’ orders.
■ Access starts. ¤ Click the “Open an existing file” radio button.
‹ Select the Northwind Samples Database from the file list. › Click OK.
12
6048-4 ch01.F
10/19/99
1:27 PM
Page 13
I How do I open a database that isn’t in the same directory as the sample database? You can open any database by clicking the File menu and choosing Open. You will see a list of the drives available to your computer. Simply choose the drive containing the database you want and open any folders you need to find the file. You can also open files from the opening Access dialog box by clicking More Files and clicking OK.
FIRST STEPS
There is a button called Design next to the Open button on the toolbar. Is it safe for me to use the Design button to examine objects in the Northwind database? You use the Design button to examine and modify an object’s structure, rather than its data. Since the Northwind database is a sample, it is safe for you to open database objects using the Design button. If you want to examine a database that probably should not be modified, it is much safer to use the Open button. Can I open more than one database object at once? You can open more than one database object at once, but you need to have more than one instance of Access running to do it. Your only limit to opening multiple databases is the amount of memory in your computer.
ˇ Click the Forms button in
Á Click on the Employees
the object list. The object list is in the left pane of the Database window.
form.
■ The list of forms appears
‡ Click Open on the toolbar.
° Examine the form.
· Close the form by clicking the Close box in the upperright corner of the form.
■ The form disappears.
in the right pane.
13
6048-4 ch01.F
10/19/99
1:27 PM
1
Page 14
CHAPTER 1: GETTING STARTED
MAXIMIZE OR MINIMIZE A WINDOW
s you work in Access, you may want to enlarge a window to fill your screen so you can see more information, or you might want to put the window aside while you concentrate on another task. When you maximize a window, you enlarge the window
A
to fill your screen. This allows you to view more of the contents of the window. If you maximize an Access database object, it will expand to fill the main Access Program window. When you are not using Access, you can minimize the window to remove it from your
screen. Minimizing Access reduces the window to a button on the Windows taskbar. Click the button, and the Access window will appear in its original location and in the same size it was displayed before you minimized the window.
MAXIMIZE A WINDOW
■ The window expands to fill
RESTORE
⁄ Click the Maximize button
the screen.
⁄ To return the window to
on the window’s frame.
14
its previous size, click the Restore button.
6048-4 ch01.F
10/19/99
1:27 PM
Page 15
I
How do I close a minimized window without reopening it? If you no longer need a window that is minimized on your screen, you can close it without enlarging it. To close a minimized window, right-click its button on the taskbar and then select Close.
FIRST STEPS
I keep clicking the wrong button when I try to maximize a window. Is there an easier way? If you double-click the title bar of a window, the window fills your screen. Double-clicking the title bar again will restore the window to its original size. How can I read the name of a button on the taskbar if the whole name is not displayed? Position the mouse pointer over the button. After a few seconds, a box appears, displaying the full name of the window the button represents.
MINIMIZE A WINDOW
⁄ Click the Minimize button in the window you want to minimize.
■ The window disappears.
■ The window becomes part of the Access button on the Windows taskbar.
15
6048-4 ch01.F
10/19/99
1:27 PM
1
Page 16
CHAPTER 1: GETTING STARTED
MOVE OR SIZE A WINDOW ou can have many Access windows open at one time. Adjusting the location and size of windows can help you work with their contents more easily. You can move a window to a new location if it covers important items on your screen.
Y
MOVE A WINDOW
⁄ Position the mouse over a blank area on the title bar of the window you want to move.
¤ Drag the mouse pointer to where you want to place the window. 16
If you have more than one window open, you can adjust the position of the windows to ensure that you can view the contents of each window. Click on any open window to bring it to the front. Increase the size of a window to see more of its contents.
■ An outline of the window indicates the new location.
Reduce the size of a window to see more windows at once. Just as you can move and size windows within Access, you can also move and size windows in other open programs or on your desktop.
■ The window moves to the new location.
6048-4 ch01.F
10/19/99
1:27 PM
Page 17
I
FIRST STEPS
Can I move or size a maximized window? You will not be able to move or size a window that has been maximized. Restore the window first and then move or size it.
Can I size programs other than Access? Yes. Most programs can be sized; however, some programs, like Calculator, cannot.
Can I move a database object’s window outside the main Access window? You can move most of a window off the main Access window, but some of the window will still be visible. This allows you to put a document aside, as you might on a real desk.
SIZE A WINDOW
¤ Drag the mouse arrow
■ The window changes to
⁄ Position the mouse
until the outline of the window is the size you want.
the new size.
pointer over an edge of the window you want to size. (The mouse pointer changes shape.)
17
6048-4 ch01.F
10/19/99
1:27 PM
1
Page 18
CHAPTER 1: GETTING STARTED
SWITCH BETWEEN WINDOWS
lthough you can have several windows open, you can only work in one window at a time. This window is called the active window. The active window appears in front of all the other windows. The title bar of the active window is a different color than the title bars of the other open windows.
A
SWITCH USING TITLE BARS
■ The active and inactive window have title bars of different colors.
18
When you have more than one window open, you can switch between all of the open windows by clicking the one you want to work with. The clicked window becomes the active window. If the window you want is covered by other windows, you can also make it active by choosing it from the Windows menu.
⁄ Click on the title bar of the inactive window.
The ability to have multiple windows open and to switch between them is very useful. For instance, switching between windows allows you to consult a table and form while you create a query based on them. (You’ll learn about tables, forms, and queries as you proceed through the book.)
■ The inactive window moves to the front and becomes the active window.
6048-4 ch01.F
10/19/99
1:27 PM
Page 19
I
Do my open Access windows appear on the Windows taskbar? No. Your open Access windows only appear in the Window menu on the menu bar of the active Access window. The Windows taskbar has a button for Access and any other programs you have open.
SWITCH USING THE WINDOW MENU
⁄ Click the Window menu on the menu bar of the main Database window.
How do I switch between Access and other programs without losing my place in Access? Clicking the button of another program makes the other program active without changing anything in Access. When you click on the Access button on the Windows taskbar, you will return to exactly where you left off. Or, if the program you want to switch to is not minimized, hold down the Alt key and press and release the Tab key until the open program becomes active.
■ The active window is
■ The inactive window
checked.
moves to the front and becomes the active window.
¤ Click the inactive window
FIRST STEPS
Does the Window menu appear in any Access window except for the main Database window? The Window menu appears exclusively on the menu bar of the main Database window. You may need to move or resize another window to reach the main Database window.
from the list.
■ The windows are listed in the order they were opened.
19
6048-4 ch01.F
10/19/99
1:27 PM
1
Page 20
CHAPTER 1: GETTING STARTED
ARRANGE WINDOWS ou can have many items, such as a table, a form, and a report, all open in Access at once. Windows allows you to arrange and organize these items so they are easier to use. You can arrange the windows by hand or by choosing Cascade, Tile Horizontally, or Tile
Y
⁄ Click the Window menu on the menu bar of the main Database window.
20
Vertically from the Window menu in the main Database window. Cascading displays windows one on top of the other so that you can see the title bar of each window. This is useful if you are working with more than one type of database object and have many windows open. You can move
¤ Click the way you want to arrange the windows.
between the open windows by clicking the title bar of the window you want to view. You can use the Tile commands to see two or more windows side by side or one above the other. Tiling allows you to compare the contents of your windows easily.
CASCADE
■ The windows neatly overlap each other. You can clearly see the title bar of each window.
■ You can click the title bar of the window you want to work with. The window will move in front of all other windows.
6048-4 ch01.F
10/19/99
1:27 PM
Page 21
I
How do I tile or cascade only some of the windows I have open? Minimize the windows you do not want included before you use the Tile or Cascade commands.
FIRST STEPS
How do I make a window appear in front of all other windows? Click any part of the window. You can also pick the window’s name from the list under the Window menu. Why can’t I see a difference between Tile Vertically and Tile Horizontally? Tiled windows are displayed the same way on your screen when there are four or more windows open.
TILE HORIZONTALLY
■ The windows appear one above the other. You can view the contents of each window.
■ You can compare the contents of the windows and easily exchange information between the windows.
by side. You can view the contents of each window.
■ You can click anywhere in the window you want to work with to make that window active.
■ You can compare the contents of the windows and easily exchange information between the windows.
TILE VERTICALLY
■ The windows appear side
■ You can click anywhere in the window you want to work with to make that window active.
21
6048-4 ch01.F
10/19/99
1
1:27 PM
Page 22
CHAPTER 1: GETTING STARTED
GETTING HELP: WHERE TO GET HELP If you have a problem using Access, there are many sources of help available. You can refer to Access Help, the Microsoft Technical Support Knowledge Base, and Internet newsgroups to find help. More “personal” help options include telephone support, friends, and professional consultants. Access Help– Access Help is the most convenient way to find answers while you’re using Access. The Access Help feature is automatically installed with Access and is free to use. In Help, you can either browse topics by category, search Access Help files for the information you need, use the alphabetical index of help topics, or pose your question to the Office Assistant — an interactive character installed with Access Help. Access Help does not include information about problems, or bugs, that were identified after Access 2000 was released. Newsgroups– Internet newsgroups are a great source of information and help, as people throughout
22
the world post questions, answers, tips, and stories of their own experiences using Access. The group comp.databases.ms-access is a good place to start. You can access newsgroups over the Web by using Deja News (www.dejanews.com). You can search through these messages to find the answers you need. You may, however, have to spend a great deal of time reading messages to find one that answers your question. If you cannot find the information you need in a newsgroup, you can post a message to an appropriate newsgroup asking a specific question. Other readers may e-mail the answer to you or post it in the newsgroup. Keep in mind that the information you receive from Internet newsgroups may not always be reliable or may not work with the setup of your computer. Microsoft Technical Support– You can use the Microsoft Technical Support Web site to obtain information about Access. Microsoft Technical Support can be found on the Internet at support.microsoft.com.
6048-4 ch01.F
10/19/99
1:27 PM
Page 23
I
Telephone Support– You can speak to a Microsoft support technician who will try to solve your problem over the phone. Depending on your location, and how and when you purchased Access, the Microsoft telephone support may be free. Otherwise, Microsoft has many fee-based telephone support options that are explained to you when you call the appropriate number for your region. The number for your region is usually included with your license information. If you purchased Access preinstalled on a new computer, your manufacturer or vendor may also provide telephone support. Telephone support can sometimes be a frustrating experience. You may spend a long time on hold, and if you are paying longdistance charges, it can be expensive. Friends and Colleagues–
sometimes make things worse. Friends are usually not experts, and may not understand how your computer’s setup differs from their own. A procedure that worked on your friend’s computer may create even more problems on your computer. True, it seems like every office or neighborhood has a computer guru who can provide information and help less experienced users solve problems. However, these people typically get inundated with pleas for help every day. Do your expert friends a favor and try to find an answer yourself before sending out that SOS.
FIRST STEPS
The Web site contains known problems and solutions to the problems that have been identified by Access users and the Microsoft technical support staff. This Web site is constantly updated with new problems and solutions. However, the site is not comprehensive, and you may have to read many pages before you find the information you want.
Consultants– Consultants are experienced professionals who provide expert, on-location help and advice. They are trained in specific areas of computer hardware or software. You can have a consultant come to your home or office to solve your problem. Ask for recommendations from your friends, colleagues, or other knowledgeable computer users when looking for a consultant. Before you hire a consultant, make sure the consultant’s expertise is in the area in which you need help. For example, a consultant experienced in hardware maintenance may not be able to help you with your Access 2000 problems.
Everyone likes asking their friends for help; it’s easier than looking in a manual or researching on the Internet, and you can have a more natural dialogue than with a remote technical support person. However, friends and colleagues may not always be able to help solve your computer problems, and can
23
6048-4 ch01.F
10/19/99
1:27 PM
1
Page 24
CHAPTER 1: GETTING STARTED
GETTING HELP: USING THE OFFICE ASSISTANT ou can use the Office Assistant to search Access help files for answers to your questions. The Office Assistant is an interactive character that helps you search for help on topics you describe. It lets you ask a
Y
⁄ To show the Office Assistant, click the Help menu in any window and select Show the Office Assistant.
24
question in plain English and offers a selection of Help entries for you to choose from. You can choose what your Office Assistant will look like and when it appears. If you want, you can set the Office Assistant so that it will only appear when
you ask for it. You can also have the Office Assistant move out of the way of any open windows, offer tips on selected topics only, and offer a tip whenever you start Access.
¤ Write your question in this area. ‹ Press the Search button.
■ Pressing the Options button will let you customize your Office Assistant.
6048-4 ch01.F
10/19/99
1:27 PM
Page 25
I
How do I turn off the Office Assistant permanently? To turn off the Office Assistant, click the Assistant and select the Options button. Click the Options tab and click in the Use the Office Assistant box to remove the check mark. If you change your mind, you can always check the box again.
Is using the Office Assistant the only way to learn about Access? No. You can have the Office Assistant give you a tip whenever you start Access by clicking on the Assistant while it’s visible and selecting the Options button. Click the Options tab and click the Show Tip of the Day at Startup box.
FIRST STEPS
How do I close the Office Assistant? Open the Help menu and choose Hide the Office Assistant. You can also right-click on the Assistant and click Hide from the menu that appears.
How do I get a different Office Assistant character? Click the Office Assistant and click the Options button. Click the Gallery tab and choose the character you prefer.
■ The Office Assistant lists
■ You can click on any of
■ The help file for the topic
■ You can click words and
a number of topics containing the words in your question.
the listed topics. Look for your mouse pointer to turn into a pointing finger.
you selected appears.
phrases printed in blue to display help topics on the highlighted words.
⁄ Click a topic of interest or look at more topics.
25
6048-4 ch01.F
10/19/99
1:27 PM
1
Page 26
CHAPTER 1: GETTING STARTED
GETTING HELP: USING THE CONTENTS TAB ou can use the Contents tab to browse through Access help topics by subject. The Contents tab contains categories of help topics arranged into books. The books contain general help, specialized information, tips, and problemsolving techniques on a wide range of Access topics. Even experienced users will find useful information under the Contents tab. The Databases: General book is useful if you are new to Access in
Y
⁄ Click the Help menu. ¤ Click Microsoft Access Help.
26
particular or databases in general, and would like information on how to get started with Access or to design a database. The Forms: Basics book contains step-by-step procedures to help you create new forms and bind them to objects within your database. You can also find out how to modify objects associated with the form. The Queries: Troubleshooting book contains a number of techniques you can use to ensure your queries work properly. You
can also find out how to exclude certain records from your query results and to delete duplicate records. The Security: Basic book contains a list of steps you can take to make sure your database can only be accessed by authorized users. You can also find out how to hide objects in the Database window and encrypt an entire database.
■ The Access Help window
‹ Click the Contents tab.
appears.
■ This area displays the help topics organized by category. The icon beside each item tells you about the item.
› Double-click a Folder icon or click the plus sign (+) next to it to display the topics in that category.
6048-4 ch01.F
10/19/99
1:27 PM
Page 27
I
Can I reduce the size of the Access Help window? You can hide part of the Access Help window to more clearly view your other Access windows. This is helpful if you are using Help to learn how to perform a task and need to work within another window. Click the Hide button to hide the left pane of the window. Click the Show button to once again display the full window.
■ The topics in the new category appear.
ˇ Repeat step 4 until the topic of interest appears.
Á Click the topic you want information about.
Can I print a help topic from the Contents tab? Yes. To print the displayed help topic, right-click the topic in the left pane of the Access Help window and then select Print. In the Print dialog box, you can choose to print the current topic or every topic under the current heading.
FIRST STEPS
Is there a shortcut to Help? Pressing the F1 key will open the Help feature in Access and in nearly every Windows program.
■ This area displays
■ When you finish reviewing
information about the topic you selected.
the information, click the Close box to close the Access Help window.
27
6048-4 ch01.F
10/19/99
1:27 PM
Page 28
1
CHAPTER 1: GETTING STARTED
GETTING HELP: USING THE INDEX TAB
he Index tab contains an alphabetical listing of all the Access help topics. You can use the Index tab to find information in the same way you would use the index in a book. When you type the first few characters of the help topic you
T
⁄ Click the Help menu. ¤ Click Microsoft Access Help.
28
want to find, Access will take you to the topic’s location in the index. Access categorizes topics so you can quickly find the information you need. For example, if you want to sort the records within a database, you can type the word sort. Listed
■ The Access Help window appears.
under “sort,” you will find topics for sorting records and working with existing sorts. After you find the help topic you want, you can display the help information for the topic.
‹ Click the Index tab to display an alphabetical list of help topics.
■ This area displays help
› To search for a help topic of interest, click this area and then type the first few letters of the topic.
ˇ Double-click the topic or category you want to display information on.
topics containing the word you typed.
6048-4 ch01.F
10/19/99
1:28 PM
Page 29
I
How do I return to a help topic I have already viewed? You can click the Back or Forward buttons in the Access Help window to move through the help topics you have viewed.
Á Double-click the help topic of interest.
Can I copy help information into a document? You can create your own help documents by copying Access help information. In the Access Help window, drag the mouse over the text you want to copy to a document to select the text. Right-click the selected text and then click Copy. Open the document you want to receive a copy of the information. Click on the Edit menu and then select Paste.
■ The information on the
■ The Help window
help topic appears in this area.
disappears.
FIRST STEPS
Can I make the Access Help window any smaller? To change the size of the window, position the mouse pointer over an edge of the window (the mouse pointer changes to a vertical or a horizontal line with a doubleheaded arrow through it). Drag the mouse until the outline of the window display is the size you want.
Note: When you finish reviewing the information, click the Close box to close the Access Help window.
29
6048-4 ch01.F
10/19/99
1:28 PM
Page 30
1
CHAPTER 1: GETTING STARTED
GETTING HELP: USING THE ANSWER WIZARD TAB ou can use the Answer Wizard tab to search all of the words contained in the Access help topics. You can type one or more words and have Access search the help topics to find matches for the words.
Y
⁄ Click the Help menu. ¤ Click Microsoft Access Help.
30
When the search is complete, Access displays a list of the matching help topics. If a lot of help topics are displayed, you can narrow your search by adding another word or searching for a more specific word.
■ The Access Help window appears.
Access displays the help topics containing all of the words you typed, regardless of the order of the words. After you find the help topic you want, you can display the help information for the topic.
‹ Click the Answer Wizard tab. › Click this area and then type the word(s) you want to find.
Note: If you want to find more than one word, separate the words with a space.
ˇ Click Search or press the Enter key.
6048-4 ch01.F
10/19/99
1:28 PM
Page 31
I
Can I ask my question in plain English? Access allows you to phrase your request as a question. Rather than try to understand the question as a whole, Access identifies words within the question that correspond to the titles of help topics. Access then presents the help topic list in the Select Topic to Display window and waits for you to choose a topic.
FIRST STEPS
Is there an easy way to look up topics discussed in the topic that is currently displayed? Any term occurring in the text of a help topic that has its own help topic is underlined and printed in blue text. Click on the highlighted and underlined words to view the help topic related to the term you selected. Can I search for help information on the Internet? If you have registered with Microsoft, you can connect to Microsoft’s Web site to access the most up-to-date help information about Access 2000. At the bottom of every help topic you will find a link to the Web site. Click the Link to the Web or Other Sources link to open Internet Explorer and display the site.
■ This area displays the
■ This area displays Access
■ When you finish reviewing
help topics matching your search.
Help pages. Access Help automatically opens the first topic.
the information, click the Close box to close the Access Help window.
Á Double-click other topics of interest.
31
6048-4 ch02.F
10/19/99
1:34 PM
Page 32
2
CHAPTER 2: CREATE A NEW DATABASE
CHAPTER 2: CREATE A NEW DAT
CREATE A NEW DATABASE
ccess gives you a great deal of flexibility when creating new databases. You can take advantage of the wizards Access provides, or build your own tools. If you use a wizard to create your database, you can set report and title styles, which will
A
New Database Wizard– You can create a new Access database using the wizards included with the program. Each wizard guides you through the database creation process efficiently, allowing you to revisit and change any choice you’ve made. Access has a variety of wizards from which to choose. Pick the wizard that is most like the database you want to create and double-click it to start. You can name your database whatever you like. Windows 95, Windows 98, and Windows NT allow you to have filenames up to 255 characters long.
give your database and its output a distinctive style. Access also has the tools to manage your databases and the files they contain. You can open folders or files, create new folders to organize your files, and delete folders or files at any time.
screen and when you print it out. You can choose from several motifs, such as a globe, a stone face, or a plain piece of paper. You can preview as many styles as you like before you make a final decision. You can also choose what your reports will look like. Select from a variety of themes, ranging from a simple title and text to a sophisticated corporate style. You can put a title at the top of each report as well, perhaps your database’s name or another phrase of your choosing. If you like, you can include a picture in the title of your reports. Pick a picture from anywhere on your computer or from a machine you can access over a network.
Title
Title Choosing Report and Title Styles– Access also enables you to determine what each part of the database will look like on the 32
6048-4 ch02.F
10/19/99
1:34 PM
Page 33
1 Create a Database from Scratch–
You can delete any files you don’t want from the Open window. Click the file you want to delete and then click either the Delete button on the toolbar or Delete from the Tools menu. Deleting files does not remove the file immediately. Instead, the file is transferred to the Recycle Bin. You can look in the Recycle Bin at any time, to verify there are no files there you want to keep, or to locate a file you accidentally throw away. You can return any files from the Recycle Bin to their original location by using the File menu in the Recycle Bin window.
FIRST STEPS
You can choose to create a database from scratch. Creating a blank database gives you the ability to design the best system for your data storage needs. A blank table will appear when you create your new database. You can enter information and get a feel for navigating around the table using the mouse and arrow keys on your keyboard. You can name your database whatever you like, with the familiar limit of 255 characters.
Delete Files–
Organize Files– You can organize your files with ease, moving them between folders, disks, and other computers, if you are connected to a network. You can change a file or folder’s name from the Open window. The Tools button on the toolbar gives you several other options as well. If you want to create a new folder in which to store your databases or other Access files, you can do so from the Open window.
33
6048-4 ch02.F
10/19/99
1:34 PM
2
Page 34
CHAPTER 2: CREATE A NEW DATABASE
USING A NEW DATABASE WIZARD: LAUNCH THE WIZARD ou can create a new Access database in one of two ways — from scratch, or by using one of the database wizards included with the program. There may be times when it makes sense for you to create a database from the ground up, but the
Y
⁄ Click the “Access database wizards, pages, and projects” radio button. ■ The button changes from an empty circle to a filled-in circle.
34
wizards at your disposal make the task much easier. The wizards step you through creating databases of several kinds, including asset tracking, address keeping, contact management, event management, and inventory control.
¤ Click OK.
Remember to give your database a descriptive name. You can give your database any name up to 255 characters in length (including spaces), so you can include a lot of information.
‹ Click the Databases tab. ■ A list of database wizards appears.
› Double-click the icon representing the wizard you want to use. Note: In this case, Asset Tracking has been chosen.
6048-4 ch02.F
10/19/99
1:34 PM
Page 35
1
■ The File New Database window appears.
ˇ Enter the name of the new database here. Note: We typed “assets.”
Á Click Create or press Enter.
FIRST STEPS
Can I change how the wizards are displayed? You can change how the wizards are displayed by clicking the Small Icon button or the List Details button to the right of the window where the wizards are listed.
Can I save my new database in another directory? You can select another directory for your database by clicking the Desktop button in the left pane of the File New Database window. The right pane will show My Computer, which you can use to select another directory.
■ The Asset Tracking Database Wizard appears.
‡ Click Next to continue. Note: If you think the default database the wizard creates will meet your needs, click Finish and the wizard creates the database automatically.
35
6048-4 ch02.F
10/19/99
1:34 PM
2
Page 36
CHAPTER 2: CREATE A NEW DATABASE
USING A NEW DATABASE WIZARD: ADD FIELDS
fter choosing a wizard to base your new database on, Access shows you a list of the tables the wizard will include in your database. Access also shows you the fields within each table. You can
A
■ The list of tables in the database appears here.
■ The list of fields in the highlighted table appears in this area. Note: Optional fields are listed in italics.
36
add optional fields that aren’t required but could help flesh out individual tables. You can determine what each part of the database looks like on the screen and when you print it out. Choose from several motifs,
Note: You can remove any field from a table by clicking the box next to the field name. The box s check will disappear. Note: Fields listed in regular print are necessary for the database to function properly.
such as a globe, a stone face, or a plain piece of paper, to customize your database.
⁄ Click another table name to display the fields in that table.
¤ Click Next to keep going. Note: You can click Back at any time to review your decisions or change a selection.
6048-4 ch02.F
10/19/99
1:34 PM
Page 37
1
Can I preview more than one style before I choose one? You can preview as many styles as you like before making a selection. If you change your mind later, click Back to revisit the window.
FIRST STEPS
Can I start over from scratch? You can start over from scratch at any time by clicking the Cancel button. Clicking the Cancel button closes the wizard without saving any of your work. Can I add all of the optional fields to a table? You can add as many optional fields as you like. Adding optional fields is a good idea if you want to print a table and would like more information about the table entries to be contained in each record than is needed for the database to function properly.
■ The Style Selection window appears.
‹ Click a style name to display it.
■ The new style appears.
› Click Next to continue when you are happy with the style you’ve chosen.
CONTINUED
37
6048-4 ch02.F
10/19/99
1:34 PM
2
Page 38
CHAPTER 2: CREATE A NEW DATABASE
USING A NEW DATABASE WIZARD CONTINUED hen you create your database using a wizard, you’re not limited to the standard Windows color scheme (blue title bar, gray background, black lines, and white fills for objects). Instead, you can choose from a variety of built-in looks you can apply to the objects in your database.
W
■ The Report Style window appears.
⁄ Click the name of a style to display it.
38
The available designs (referred to elsewhere in Access as autoformats, and covered further in Chapter 13) include corporate looks with a lot of deep reds, conservative designs with a rice paper finish for the form’s background, and, if you want, the standard Windows color scheme.
¤ Click Next to continue when you are happy with the style you've chosen.
You can choose a format for your reports as well. In addition to deciding on a basic color scheme, you can add a title to the top of every page. The title can display your company’s name on every page, show the current date, or include your company’s logo at the top of each report page.
‹ Type a title for your reports here. › Check this box to include a picture on all reports.
ˇ Click Picture to select a picture to include in your reports.
6048-4 ch02.F
10/19/99
1:34 PM
Page 39
1
Can I create a report style of my own? Access gives you the tools to create your own report style. You can find out how to create a custom report in Chapter 13.
FIRST STEPS
Can I choose a picture that’s not in the My Pictures folder? You can choose a picture that’s not in the My Pictures folder by clicking Desktop in the left pane of the window. Can I choose from a number of graphics file formats? Access lets you choose from several popular file formats, including JPEG, GIF, and EPS. Supported file types are listed in the Files of Type area at the bottom of the Insert Picture window.
■ The Insert Picture window appears.
Á Double-click My Pictures to open a list of available pictures.
‡ Select a picture.
° Click OK.
Note: You can look for graphics elsewhere on your computer or any networked computer as well.
39 CONTINUED
6048-4 ch02.F
10/19/99
1:34 PM
2
Page 40
CHAPTER 2: CREATE A NEW DATABASE
USING A NEW DATABASE WIZARD CONTINUED hen you have completed designing your database, Access can automatically create it. Step back through your choices for a final check using the Back and Next buttons before you create your new database.
W
■ The picture you selected appears in the preview window.
40
If you wish, Access can open your new database automatically when you click Finish. A new Database window will appear displaying the objects the wizard created for your new database. You can also have Access show its help topics on using a new
⁄ Click Next.
database when you create yours. For instructions on how to use Access Help, turn to Chapter 1. You should take some time to look through your new database and familiarize yourself with its components.
■ The Checkered Flag screen appears.
¤ Click the box next to “Yes, start the database” if you do not want your database to open when you are done creating it.
Note: Clicking the box will cause its check mark to disappear. If the box is checked, your database will open when you click Finish.
‹ Click Finish.
6048-4 ch02.F
10/19/99
1:34 PM
Page 41
1
■ The new database appears.
› Click the Close box to close your new database.
FIRST STEPS
Can I modify a database I create with a wizard? You can change any aspect of your database any time you like, from adding new tables, deleting old ones, and changing the look of the objects in your database.
What if, when I reach the Checkered Flag screen, I want to change a decision I made on an earlier screen? If you want to change any setting you made previously, click the Back button to return to the screen you want and make the change.
■ The Access Main Window appears.
ˇ Click the Close box or click the File menu and click Exit to close Access.
41
6048-4 ch02.F
10/19/99
1:34 PM
2
Page 42
CHAPTER 2: CREATE A NEW DATABASE
CREATE A BLANK DATABASE
he wizards included with Access allow you to create a lot of useful databases, but if none of them fit the bill then you can create a database from the ground up.
T
⁄ Start Access as you learned to do in Chapter 1. ¤ Click the “Blank Access database” radio button.
42
As with wizard-created databases, you should give your custom database a descriptive name. Once you’ve created the blank file, Access will present you with a new table to begin
‹ Click OK.
fleshing out your database. (For more information on creating new tables with wizards or from scratch, see Chapter 3.)
■ The File New Database window appears.
› Type the name of your database here.
ˇ Click Create.
6048-4 ch02.F
10/19/99
1:34 PM
Page 43
1
FIRST STEPS
How do I create a new blank database from within another database? You can create a new blank database from inside Access by clicking the New button on the toolbar. Click the General tab in the window that appears and you will see an icon entitled Blank Database. Click the Blank Database icon and click OK.
Can the name of my new database include periods and spaces? Windows 95, Windows 98, and Windows NT support long filenames (up to 255 characters). Your filenames can include periods and spaces.
You can also click the File menu and then click New.
■ The new database and a blank table appear.
Á Click the Close box to close the table.
‡ Click the Close box to close your new database.
Note: Learn how to work with tables in Chapter 3.
43
6048-4 ch02.F
10/19/99
1:34 PM
2
Page 44
CHAPTER 2: CREATE A NEW DATABASE
REFRESH THE DATABASE WINDOW
ccess is a user friendly but powerful program. To make sure you’re making the changes you want to make and including all of the information you need in your databases, you’ll find yourself opening more than one object at
A
Note: Opening multiple windows uses lots of memory.
44
a time. You can move between windows with ease, but your computer may lose track of which window goes on top and which patch of screen belongs to which window. If Windows does lose track of what goes where, you can simply
have it redraw the screen to put everything in its proper place. Make the operating system’s job easier by keeping the number of objects you have open at any one time to the minimum necessary for you to do your work.
Note: Access can lose track of some windows and redraw the screen incorrectly.
⁄ Click the Minimize button.
6048-4 ch02.F
10/19/99
1:34 PM
Page 45
1
FIRST STEPS
How can I avoid having Access lose track of my open windows? You can make it easier for Access to keep track of and redraw its open windows by closing unneeded programs and Access windows.
Is there a keyboard shortcut to refresh the Access window? You can hit the F5 key to refresh the Access window.
If you have closed every nonessential window and are still having problems, you might consider adding more RAM to your computer.
■ The Access window disappears.
¤ Click the Access button on the Windows taskbar.
■ Access redraws the window correctly.
45
6048-4 ch02.F
10/19/99
2
1:34 PM
Page 46
CHAPTER 2: CREATE A NEW DATABASE
OPEN, ORGANIZE, AND DELETE FILES: OPEN
ccess allows you to have only one database open at a time, but that limitation doesn’t make it impossible for you to copy objects between databases, switch among three or more databases, or compare a table in one database with its counterpart in another. All you need to do is open the files sequentially — any objects you’ve copied to the
A
⁄ Click File. ¤ Click Open.
46
Clipboard will remain there. If you want to look at a database but not change it, you can open it in read-only mode. Once you open a database in read-only mode you can’t make any changes, even if you are the person who created the database. To modify anything in the database, you’d need to close it and reopen it normally.
Note: You can also click the Open button on the toolbar.
You can also ensure you’re the only person looking at the database at any time. To do so, just open the file in exclusive mode. While you have the database open, Access locks it and makes sure other users can’t open the file. You should open a database in exclusive mode whenever you want to make changes to the database’s structure.
■ The Open window appears.
‹ Click a filename. › Click Open.
6048-4 ch02.F
10/19/99
1:34 PM
Page 47
1
■ The database opens.
ˇ Click the Close box to close the database.
FIRST STEPS
How do I open a database so that I can’t accidentally change it? You can make sure you don’t change a database by opening it in read-only mode. You can open a database in read-only mode by clicking the down arrow on the right edge of the Open button. Choose Open Read Only from the menu that appears.
How do I open a database so that I know I’m the only one who can examine or change it while I have it open? You can make sure you are the only person examining or changing a database by opening it in exclusive mode. You can open a database in exclusive mode by clicking the down arrow on the right edge of the Open button. Choose Open Exclusive from the menu that appears.
■ The database closes.
47
6048-4 ch02.F
10/19/99
1:34 PM
2
Page 48
CHAPTER 2: CREATE A NEW DATABASE
OPEN, ORGANIZE, AND DELETE FILES: ORGANIZE ou can use the standard tools of the Windows operating system, such as My Computer and Windows Explorer, to move your files from folder to folder and ensure they’re easy to find. You can also do the same for any unopened database files from within Access.
Y
⁄ Click File.
You can rename your files, change their location on your hard drives, and copy the files over a network using the Directory Navigation and File Manipulation windows. You can make your data management easier by creating folders for your databases,
¤ Click Open.
■ The Open window appears.
48
allowing you to maintain separate versions of databases, create a storage area for archival copies of your work, and give yourself a place to store experimental files.
‹ Click the New Folder button on the toolbar.
6048-4 ch02.F
10/19/99
1:34 PM
Page 49
1
■ The New Folder dialog box appears.
ˇ Click OK.
FIRST STEPS
How do I rename a file or folder? You can rename a file or folder by clicking the file or folder and clicking the Tools button on the Access File window’s toolbar. Click Rename on the menu that appears, type in the new name for your file, and press Enter.
Can I make a backup copy of a file from inside Access? You can make a backup copy of a file from inside the Access File window by clicking the file, clicking the File menu, and clicking Save As. You name your backup copy by typing a different name in the Save To text box.
■ Your new folder appears in the directory window.
› Type the name of your folder here.
49
6048-4 ch02.F
10/19/99
1:34 PM
2
Page 50
CHAPTER 2: CREATE A NEW DATABASE
OPEN, ORGANIZE,AND DELETE FILES: DELETE ou can also use the file and directory navigation tools to delete any files you don’t need. Deleting files can be done in a number of ways: by right-clicking the file and choosing Delete from the shortcut menu that appears, by clicking the file and then clicking
Y
⁄ Click File.
50
the Delete toolbar button, or by clicking the file and choosing Delete from the Tools menu. If you delete a file on a hard drive, Access doesn’t delete the file right away. Instead, the file is transferred to the Recycle Bin. The file is only deleted when you empty the Recycle Bin. If you
¤ Click Open.
delete a file from a floppy disk, however, the file is deleted immediately. Access will ask you to confirm all of your deletions, so you will have a chance to change your mind. Once you confirm the file should be deleted, however, it will be impossible to bring it back.
‹ Click the file you want to delete.
› Click the Delete button on the toolbar.
6048-4 ch02.F
10/19/99
1:34 PM
Page 51
1
FIRST STEPS
How can I see which files are in the Recycle Bin? You can look at the contents of the Recycle Bin by right-clicking it and choosing Open from the menu that appears.
■ The Confirmation dialog box appears.
ˇ Click Yes to delete the file, or No to keep the file.
I’m certain all the files in the Recycle Bin should be deleted. How do I get rid of them? You can empty the Recycle Bin by clicking the File menu and clicking Empty Recycle Bin.
■ The deleted file disappears.
51
6048-4 ch03.F
10/19/99
1:48 PM
Page 60
3
CHAPTER 3: CREATE TABLES
2 CHAPTER 3: CREATE TABLES
INTRODUCING TABLES
ables are the building blocks of Access databases. They embody the design of your database, store your information, and can be indexed to make searching faster.
T
Access also lets you establish rules to make sure that the data entered into your database is correctly formatted.
Fields–
Records
Fields represent individual elements of information in a table. A table storing addresses might include the fields First Name, Last Name, Address, City, State, Postal Code, and Country. In the graphical representation of a table, a field is a column. Mon.
Tues.
Wed.
Thur.
Fri.
Fields can contain many different types of information. You can enter data such as text, numbers, dates, and pictures.
60
Where fields represent the columns of a table, records represent the rows. A record is a set of information about a particular object or individual. A record in an address table might read: Curtis Frye, 1234 98th Ave., Portland, Oregon, 97299, USA. Mon.
Tues.
Wed.
Thur.
Fri.
6048-4 ch03.F
10/19/99
1:48 PM
Page 61
Keys–
Design View–
Owner
Date
Grp
Ins
Add
LMS 212
Steve R.
9/2/97
9/2/99
Y
As of this month, all carried
LMS 541
Rick S.
9/2/98
9/2/00
Y
All of the above resources
II CREATE TABLES, FORMS, AND REPORTS
A key is a unique value that identifies a record within a table. Just as a car’s license number uniquely identifies it within a state, a key value uniquely identifies a particular record. Keys also make it easier to sort and index a table. A key can be made up of one or multiple fields.
Access offers you a simple way to create and modify your own tables. By opening a table in Design View, you can name your fields, choose what type of data they will contain, and add a description. In addition to numbers and text boxes, your fields can hold graphics, dates, and times.
Indexes– Like keys, indexes allow you to look up information in a table more quickly. Unlike keys, however, index fields do not have to have unique values. Just as indexed words can occur multiple times in a book, so can indexed values within your database. You can index as many fields as you like, though indexing every field — even a small database — could slow down data entry and processing significantly. 1
Smith
2
Jones
3
Frye
4
Short
5
Smith
6
Almy
7
Forrest
Almy 6 Forrest 7 Frye 3 Jones 2 Short 4 Smith 1, 5
CONTINUED
61
6048-4 ch03.F
10/19/99
3
1:49 PM
Page 62
CHAPTER 3: CREATE TABLES
INTRODUCING TABLES Datasheet View–
Opening a table in Datasheet View allows you to enter data directly into the table. You can move around the table using the keyboard or mouse and add, modify, or delete any column or row in the table. Switching between Design View and Datasheet View lets you rearrange, add, or delete fields while you are entering data.
CONTINUED
Input Masks– Input masks allow you to define exactly how data should be entered into a field. For instance, if you prefer a specific format for dates, you can design a custom input mask that gives users a template to follow when entering date information. Access gives you a number of predefined input masks to choose from as well.
Validation Rules– Validation rules are like input masks in that they ensure the content of a field meets certain criteria. Unlike input masks, which set the format in which data is entered into the database, validation rules make sure a field’s contents fall within acceptable limits. A simple validation rule might require that a number be between 1 and 100.
[Later than current date?]
62
3
6048-4 ch03.F
10/19/99
Page 63
CHAPTER 3: CREATE TABLES
II CREATE TABLES, FORMS, AND REPORTS
3
1:49 PM
DATA TYPES
ccess has the capability to store your data in a variety of formats. While many fields will be simple text entries, such as customer names and product descriptions, you can establish fields for numbers, currency, and dates. You are not limited to simple numbers and dates. You can have Access track the number of records in your table and assign each a unique number. You can also include fields referring to
A
pictures elsewhere on your computer or even links to World Wide Web pages anywhere on the Internet. If you have a limited set of acceptable values for a given field, Access gives you the ability to create a menu to choose from within a field. This menu, called a Lookup Column, makes entering data even easier than before.
Text–
Memo– Text fields are the basic building blocks of tables. You can vary the maximum length of a text field from 1 to 255 characters. Fortunately, Access allows you to make text fields larger than they need to be, without costing you disk space. Even if you set a text field’s maximum length to 50 characters, the field will only claim as much disk space as necessary to store what is actually typed in each record.
John Smith
A Memo field is a text field set to its maximum length of 255 characters. Memo fields are useful for storing notes about meetings, phone conversations, and other encounters when a shorter text field would not be large enough to accommodate your entry.
Very good customer, call back promptly
CONTINUED
63
6048-4 ch03.F
10/19/99
3
1:49 PM
Page 64
CHAPTER 3: CREATE TABLES
Number–
Number fields are useful for tracking the quantity of a particular item you have on hand and recording weights and measures. If necessary, you can limit the number of decimal places a field will record.
Currency data type. You can save amounts in any national currency; Access comes with a complete set of currency symbols, including the new European currency.
39.25 3.14158
AutoNumber– 433-1800
Date/Time– Exactly when an event occurs is often important information. The event in question could involve placing an order, verifying that a bill was sent out, or determining how long it took a customer to pay. Access enables you to store that information in your database, choosing from a variety of formats which present dates and times both separately and together.
AutoNumber fields are particularly useful for tables in which the data does not have an obvious key field. When setting a key for an address database, for instance, it is much simpler to use an AutoNumber field instead of a key combining a first name, last name, and city.
1 2 3
6/21/97
1 2
4
3 4
Currency– Monetary values such as shipping costs, consulting fees, and sales tax can all be recorded in your Access database using the 64
6048-4 ch03.F
10/19/99
1:49 PM
Page 65
Yes/No–
Hyperlink–
II CREATE TABLES, FORMS, AND REPORTS
Some fields are best summed up as a simple choice between yes and no. One use might be a sales representative noting whether a phone call had been returned.
The Hyperlink data type allows you to include addresses of World Wide Web sites in your database. You could use hyperlinks to include your customers’ Web sites in your contact database. http://www. idgbooks.com
Yes No
OLE Object– Access allows you to include graphic, sound, video, and other file types in your database through Object Linking and Embedding (OLE). You could use OLE to create an online photo album to send to relatives around the world.
Lookup Wizard– A Lookup Wizard enables the person entering data into a table to choose from a list of values you defined while creating the database. Lookup Wizards streamline data entry and are an easy way to reduce typographical errors. Pine Oak Cedar Ash
65
6048-4 ch03.F
10/19/99
1:49 PM
Page 66
3
CHAPTER 3: CREATE TABLES
CREATE A NEW TABLE USING THE WIZARD
ccess allows you to create new tables for your database using a wizard. The wizard guides you through the process to create your new table. You can create a new table in a new or existing database.
A
■ The opening dialog box appears when you start Access. ⁄ Click the radio button next to Blank Access database.
66
When you start Access, choose whether to open an existing database or create a new one. You can learn a lot about table design by examining the fields in the sample tables, not only before you start but also when you reach the middle of the creation process.
¤ Click OK.
You can name your table almost anything you like. The name can include spaces.
‹ Type in the name of your new database here.
› Click Create.
6048-4 ch03.F
10/19/99
1:49 PM
Page 67
II
■ A new database appears. ■ A blank table appears.
ˇ Close the blank table by clicking the Close box.
CREATE TABLES, FORMS, AND REPORTS
How do I create a new table within an existing database? You can create a new table within an existing database by clicking the Table button in the Objects pane of the main database window and double-clicking Create table in Design view.
Can I start adding data to the blank table that appears when I create my new database? You can add data to the blank table as soon as you create it, or later.
■ The main database window appears.
Á Double-click Create table by using wizard.
67
6048-4 ch03.F
10/19/99
1:49 PM
3
Page 68
CHAPTER 3: CREATE TABLES
ADDING FIELDS
ccess includes an easy-touse wizard for creating new tables. You can launch it from the main database window and use it to create new tables quickly and easily. The New Table Wizard gives you quite a few predefined tables
A
■ A set of predefined business tables appears.
68
to choose from when adding fields to your new table. You can choose fields from personal tables, such as Addresses and Recipes, and combine them with fields from business tables, such as Customers and Products, to create your own unique tables.
⁄ Click the Personal radio button.
If you believe you’ve made all the choices you need to make regarding your new table, Access can do the rest automatically.
■ The list of Personal Sample Tables appears with the Addresses sample table selected and the Addresses sample fields displayed.
6048-4 ch03.F
10/19/99
1:49 PM
Page 69
II
⁄ Click the AddressID field in the Sample Field list. ¤ Click the forward arrow.
■ The AddressID field appears in the “Fields in my new table” list. ‹ Click the Add All Fields
CREATE TABLES, FORMS, AND REPORTS
Can I add fields from more than one table to the “Fields in my new table” list? You can add fields to your new table from as many different predefined tables as you like. Simply click the next table you’d like to take fields from and select the fields normally.
I’m sure I’ve made all the choices I need to make to get the table I want. How do I create it right now? You can create your new table from any screen by clicking Finish.
■ All of the fields in the Addresses Sample Fields list appear in the “Fields in my new table” list.
button.
69
6048-4 ch03.F
10/19/99
1:49 PM
Page 70
3
3
CHAPTER 3: CREATE TABLES
RENAME A FIELD ccess gives you a lot of flexibility in creating your new table. You can rename any field in your table from within Design View.
A
⁄ Click the down arrow on the “Fields in my new table” scroll bar until the field named “EmailAddress” comes into view.
70
You might want to rename a field if you combine two tables into one. If the tables use the same field name to represent different information that should
¤ Click the Rename Field button.
be included in your new table, you can rename one or both of the fields to avoid any confusion.
■ The Rename field dialog box appears.
Note: The new field name in this case is Email.
‹ Type the new name for your field in this space.
› Click OK.
6048-4 ch03.F
10/19/99
1:49 PM
Page 71
3
CHAPTER 3: CREATE TABLES
II CREATE TABLES, FORMS, AND REPORTS
DELETE A FIELD ou can delete fields from a table easily. Deleting fields from a table while creating it with the wizard is simple, as is restoring the fields if you change your mind.
Y
⁄ Click the field named DateLastTalkedTo in the “Fields in my new table” list.
You might want to delete one or more fields if you combine tables that contain the same field or feel a field might be better placed in another table.
¤ Click the back arrow.
You can delete fields one at a time or, if you would like to redesign your field from the beginning, you can delete all of the fields you’ve added at once.
■ The DateLastTalkedTo field disappears from the “Fields in my new table” list.
‹ Click Next.
71
6048-4 ch03.F
10/19/99
1:49 PM
3
Page 72
CHAPTER 3: CREATE TABLES
SETTING A KEY AND CREATING THE TABLE f you wish, Access can establish a key for your database automatically, or you can set it yourself. Setting a key allows Access to sort and search through your table data more efficiently.
I
⁄ Type the name of your new table here. Note: Leave the “Yes, set a primary key for me” radio button selected. You can learn about setting keys in Chapter 6.
72
You can use the Back button to step back through the wizard to examine and, if you wish, change any of the choices you made while creating your table. You can begin entering data directly into your table once
¤ Click Next to continue.
created, or you can view it in Design View.
■ The Checkered Flag screen appears.
‹ Click Finish to create your new table. Note: Leave the “Enter data directly into the table” radio button selected. Learn about modifying a table’s design later in this chapter and about creating forms in Chapter 11.
6048-4 ch03.F
10/19/99
1:49 PM
Page 73
II CREATE TABLES, FORMS, AND REPORTS
How can I get help once I finish the table? You can display the Access help topic on working with tables when you create your table by checking the “Display Access help topic” checkbox on the final screen of the wizard.
My table didn’t turn out the way I wanted it to. Can I start over without saving this table? You can exit the wizard without saving your work at any time by clicking the Cancel button.
I’d like to change my table’s design immediately after I create it. How do I do that? You can modify your table’s design, such as by adding rules for data entry or changing data types, by clicking the “Examine table in Design View” radio button.
■ Your new table appears. › Click the Close box to close the table.
Note: You can learn how to enter data into a table in Chapter 6.
■ The database window appears. Your new table is listed.
73
6048-4 ch03.F
10/19/99
1:49 PM
3
Page 74
CHAPTER 3: CREATE TABLES
CREATE A NEW TABLE FROM SCRATCH reating a new table from scratch gives you the flexibility to design your own tables from the ground up. You can add fields of any kind, without having to rely on the predefined choices in the wizard.
C
CREATE A TABLE
⁄ Double-click the Create table in Design view icon.
74
You can create a new table at any time by bringing the main database window to the front and double-clicking the Create Table in Design View icon. Once you’ve opened your new table in Design View, you can
jump right in and begin creating fields.
■ The Design view table creation screen appears.
6048-4 ch03.F
10/19/99
1:49 PM
Page 75
II
Can I use spaces in my table names? You can include spaces in your table names. It’s a good idea to use spaces to make your table names more readable.
NAME A FIELD
⁄ Click in the cell directly under the Field Name header.
¤ Type Name in the cell.
‹ Press Enter.
CREATE TABLES, FORMS, AND REPORTS
How long can my table names be? Your table names can be up to 64 characters long.
Is there an easier way to move between fields in the table than by using the mouse? You can move to the next field in the table by pressing either the Enter key or the Tab key. You can also use the arrow keys to move to the field in the direction the arrow points.
■ The cursor shifts to the Data Type column.
■ The word “Text” appears automatically. Note: Learn how to assign or change a data type later in this chapter.
75
6048-4 ch03.F
10/19/99
1:49 PM
3
Page 76
3
CHAPTER 3: CREATE TABLES
ACCEPT THE DEFAULT DATA TYPE henever you create a new field in Design View, Access assigns that field the Text data type. The Text data type is extremely
W
⁄ Press Enter.
76
flexible and is the best data type for most fields. You can accept the default data type by simply pressing the Enter key or the Tab key,
advancing to the Description area for that field. Learn how to change a field’s data type later on in this chapter.
■ The cursor moves to the Description cell.
6048-4 ch03.F
10/19/99
1:49 PM
Page 77
3
CHAPTER 3: CREATE TABLES
II CREATE TABLES, FORMS, AND REPORTS
ENTER A FIELD DESCRIPTION
ccess gives you space to enter a description for each field in your database. Field descriptions are an important part of your database because they set out what kind of information goes in each field.
A
⁄ Type your field description here.
Descriptions can help remind you of the purpose you had in mind for each field when you created the database and also give users and other designers insight into your database and how it represents information.
¤ Press Enter.
Field descriptions are an important part of any database’s documentation, though they are not required.
■ The cursor moves to the second row.
77
6048-4 ch03.F
10/19/99
1:49 PM
3
Page 78
3
CHAPTER 3: CREATE TABLES
INSERT A FIELD hen you create a table from scratch it is easy to forget to include a field or two. Access allows you to insert a field in your table with a minimum of fuss.
W
Your fields are represented as table rows in Design View. You can insert a field by choosing Insert Rows from the main Access window or by right-
⁄ Click in any cell of the LastName row.
¤ Right-click any of the column names.
■ The cursor appears in the cell.
‹ Choose Insert Rows from the menu that appears.
clicking the Design View screen’s column headings. If you accidentally insert a field at the wrong spot in a table, it’s easy to move it or delete it and try again.
■ The new field appears above the field where the cursor was located. › Type MiddleInitial as the
■ An arrow appears in the
field name.
column next to the Field Names.
ˇ Press Enter.
78
Á Press Enter to accept Text as the data type. ‡ Type your description here.
6048-4 ch03.F
10/19/99
1:49 PM
Page 79
3
CHAPTER 3: CREATE TABLES
II CREATE TABLES, FORMS, AND REPORTS
DELETE A FIELD ou can delete a field from a table at any time while in Design View. You might want to delete fields from a table if you accidentally
Y
⁄ Select the MiddleInitial row by clicking the row selector next to the field name. ■ The row is highlighted.
enter the same field twice, or decide a field is not necessary or is better suited for another table. If you delete a field accidentally, you can always add
¤ Right-click any of the column names.
it back later. (See the previous task to learn how.)
■ The row disappears.
‹ Choose Delete Rows from the menu that appears.
79
6048-4 ch03.F
10/19/99
1:49 PM
Page 80
3
CHAPTER 3: CREATE TABLES
REARRANGE FIELDS
he first step in designing effective tables is to make sure all of the information you need is represented by fields within the table. Once all the information is there, you should arrange the fields in a logical order.
T
⁄ Click the row selector next to the row you want to move. ¤ Click the row selector again and, still holding the mouse button down, drag the row on top of the LastName row. 80
Rearranging your fields into a workable order makes understanding your database much easier. As you create your table, keep in mind how you want the forms and reports generated from the table to appear. Choosing the
■ A faint outline appears around the LastName row when the mouse pointer is in position. ‹ Release the mouse button.
proper field order in your table designs will save you work when you create your forms and reports. Find out how to create forms and reports in Chapters 11 and 12.
■ The FirstName field moves above the LastName field. › Click the row selector next to Address.
ˇ Click the row selector next to Address again and, still holding the mouse button down, move the mouse pointer over the City field. Note: Do not double-click the row selector.
6048-4 ch03.F
10/19/99
1:49 PM
Page 81
II
How do I save my changes? Access asks if you want to save your table changes when you close the table.
■ The Address field appears beneath the Last Name field and above the City field. ‡ Click the row selector next to the StateOrProvince field.
° Move the pointer over the row selector next to StateOrProvince. Hold the left mouse button down and move the pointer over the PostalCode field.
CREATE TABLES, FORMS, AND REPORTS
How do I know where the field I’m moving will appear? The field you’re moving will appear at the dark line, which shows when you release the mouse button.
How do I move more than one field at once? You can move more than one field at once by holding down the left mouse button and dragging over the first fields that you want to move. The fields do need to be next to each other in the layout.
■ The StateOrProvince field appears beneath the City field and above the PostalCode field.
Note: Do not double-click the row selector.
81
6048-4 ch03.F
10/19/99
1:49 PM
3
Page 82
CHAPTER 3: CREATE TABLES
ASSIGN OR CHANGE A DATA TYPE ccess automatically assigns the Text data type to new fields. Although the Text data type is the most flexible and common data type, it
A
⁄ Click the first empty cell in the Field Name column. ■ A black arrow appears in the row selector of the row you picked.
82
is not always the best choice for your fields. Access lets you design fields to hold, among other data types, numbers, currency information,
¤ Type Birthday. ‹ Press Enter.
yes/no choices, and images. You can modify your choices at any time by opening the table in Design View.
› Click the drop-down menu button.
6048-4 ch03.F
10/19/99
1:49 PM
Page 83
II
ˇ Select Date/Time.
CREATE TABLES, FORMS, AND REPORTS
Why should I use a data type other than Text? If you know that a field will contain a number, date, time, or other specific kind of information, it definitely pays off to assign that type. That way, users are forced to enter information that matches that type, which ensures greater accuracy in your data (for example, a user cannot enter “tree” into a date field). Also, you can set specific formatting rules to nontext data types (described in the next task) so that scanning and sorting by the field is more reliable. (If you direct users to enter dates in a text field, for example, you might end up with multiple formatting variations: 11/1/99; November 1, 1999; 1 Nov. 1999; and so on. With a date field, you eliminate these variations.)
Can I change a field’s data type after I’ve begun entering records? Yes. If you change a field’s data type, Access attempts to convert the data from the old type to the new type and warns you if any problems exist.
■ The data type for Birthday changes to Date/Time.
83
6048-4 ch03.F
10/19/99
1:49 PM
3
Page 84
CHAPTER 3: CREATE TABLES
SELECT A DATA FORMAT ccess allows you to select the format that a field’s data will take. Data formats are available for Number, Date/Time, and Yes/No fields.
A
⁄ Click the Data Type cell of the Birthday field.
Picking a format ensures consistent presentation of your data. You can choose which data format you want to assign a field
■ A black arrow appears in the row selector of the row you picked.
by clicking on the drop-down menu in the data type cell of the field. You can change your data format at any time.
■ The Field Properties window changes to display the Birthday field's properties.
Note: The General tab screen should appear automatically. If the Lookup tab screen appears, click the General tab and continue.
¤ Click the text box next to Format.
84
6048-4 ch03.F
10/19/99
1:49 PM
Page 85
II
‹ Click the drop-down menu button. ■ The list of formats available for a Date/Time field appears.
Note: Take a moment to look over the different formats available for a Date/Time field.
CREATE TABLES, FORMS, AND REPORTS
How do I get help on creating my own format? You can get help on creating a data format by pressing the F1 key while the Format text box in the Field Properties pane is active.
How do I create my own data format? You can create your own data format by entering it in the Format text box in the Field Properties pane.
■ Short Date appears in the Format text window of the Field Properties pane.
› Click Short Date.
85
6048-4 ch03.F
10/19/99
1:49 PM
3
Page 86
3
CHAPTER 3: CREATE TABLES
CHANGE FIELD SIZE
ccess enables you to change the number of characters allowed in a field. The size range is between 1 and 255 characters. Changing the field size allows you to reduce data entry errors by
A
⁄ Click anywhere in the FirstName row. ■ A black arrow appears in the row selector of the row you picked.
86
ensuring the number of characters does not exceed a certain limit. Access automatically stores table data using the least possible disk space. Your data is stored according to the number
¤ Click anywhere in the Field Size text box.
of characters in the field, not the maximum field size. So if there’s a possibility for long field entries, don’t set a character limit.
‹ Type the new size of the field.
Note: The size of a field indicates the maximum number of characters you can enter in that field.
6048-4 ch03.F
10/19/99
1:49 PM
Page 87
3
CHAPTER 3: CREATE TABLES
II CREATE TABLES, FORMS, AND REPORTS
ADD A CAPTION
ccess automatically uses field names as labels for your fields on forms and reports. You can change this by assigning a caption. Captions are useful tools. They enable you to include
A
⁄ Click anywhere in the row to which you would like to add a caption.
directions and additional information about what data should be entered into a field. Captions can be very long, up to 2,048 characters. If a caption is too long to appear on the title bar, Access displays as many
¤ Click the text box next to Caption in the Field Properties pane.
characters as the screen size allows. For this reason, it’s probably best to keep your captions concise, despite the generous limit.
‹ Type the caption in this space.
■ A black arrow appears in the row selector of the row you picked.
87
6048-4 ch03.F
10/19/99
1:49 PM
3
Page 88
3
CHAPTER 3: CREATE TABLES
ASSIGN A DEFAULT VALUE ccess enables you to assign a default value to a field. The default value is entered in the field automatically, though that value can be changed during data entry.
A
⁄ Click anywhere in the row to which you would like to assign a default value.
88
Default values are a handy tool with which to streamline data entry. By assigning a default value to a field, users can skip a field where the default value is appropriate for that record.
■ A black arrow appears in the row selector of the row you picked.
Default values are only entered for new records. If you change a field’s default value after some records have been entered, Access will not change those records automatically.
¤ Type the default value for your field in the text box next to Default Value in the Field Properties pane.
6048-4 ch03.F
10/19/99
1:49 PM
Page 89
3
CHAPTER 3: CREATE TABLES
II CREATE TABLES, FORMS, AND REPORTS
REQUIRE DATA ENTRY ou can require users to enter data in a field by changing the field’s Required property to Yes. The default value is No, which allows users to skip the field when entering data.
Y
⁄ Click anywhere in the row that will have required data entry. ■ A black arrow appears in
You should always require data entry for a key field, the field that establishes a record’s unique identity within a database. Requiring data entry for every important field eliminates the possibility that
¤ Click in the text box next to Required.
vital information will be left out during data entry.
‹ Click the drop-down menu button.
› Click Yes.
■ A drop-down menu button appears.
the row selector of the row you picked.
89
6048-4 ch03.F
10/19/99
1:49 PM
3
Page 90
3
CHAPTER 3: CREATE TABLES
ALLOW ZERO-LENGTH STRINGS ou can allow fields to accept zero-length strings. You can enter a zero-length string by pressing the Enter or Tab key when the cursor is within a field.
Y
⁄ Click anywhere in the row where you would like to allow zero-length strings. ■ A black arrow appears in the row selector of the row you picked.
90
A zero-length string can be used as a placeholder in a field, even one that requires data entry. Allowing zero-length strings is a useful option when users are entering data that is incomplete.
¤ Click in the text box next to Allow Zero Length. ■ A drop-down menu button appears.
One example of allowing zerolength strings in a required field is for a field storing contacts’ middle names. Not everyone has a middle name, so zero-length strings could be appropriate.
‹ Click the drop-down menu button.
› Click Yes.
6048-4 ch03.F
10/19/99
1:49 PM
Page 91
3
CHAPTER 3: CREATE TABLES
II CREATE TABLES, FORMS, AND REPORTS
CREATE A YES-NO FIELD
ometimes it’s helpful to make a field a simple yes or no choice, such as if a teacher is tracking parental permission slips for a field trip. By establishing a Yes-No field, the teacher could easily find out
S
⁄ Type LetterOwed as the new field name in the next available cell in the Field Name column.
which students had not returned their slips. You can establish three types of Yes-No fields: Yes/No, True/False, and On/Off. Having three options gives you a great
¤ Press Enter.
deal of flexibility in establishing your database’s functionality. One possible use of a field set to True/False is to ask True/False test questions by building them into an Access form.
■ The cursor moves to the Data Type cell of the row you are working in.
‹ Click the drop-down menu button. › Click Yes/No.
91
6048-4 ch03.F
10/19/99
1:49 PM
3
Page 92
3
CHAPTER 3: CREATE TABLES
CHANGE THE NUMBER OF DECIMAL PLACES
ccess enables you to change the number of decimal places a field stores. A Number field automatically stores as many digits to the right of the decimal point as the user enters.
A
⁄ Click in the Data Type cell of the field you want to assign a different number of decimal places. Note: The Data Type must be set to Number or Currency.
92
It is sometimes useful to establish a maximum number of digits allowed to the right of the decimal point. One example of where this would be useful is a timed sports event, where competitors’ times are separated
¤ Click in the text box next to Decimal Places in the Field Properties pane. ‹ Click the drop-down menu button.
› Click 4.
by hundredths or even thousandths of a second. Access adds zeros to the end of a number if the user did not enter the maximum number of decimal places.
■ The number of decimal places changes to match your choice.
6048-4 ch03.F
10/19/99
1:50 PM
Page 93
3
CHAPTER 3: CREATE TABLES
II CREATE TABLES, FORMS, AND REPORTS
CREATE AN INDEX
ccess can keep an internal index of the values in any field in your database. You can establish indexes for any number of fields, though indexing every field might slow data entry significantly.
A
⁄ Click anywhere in the row you would like to index.
Indexes speed up sorting and search operations within Access. Because Access can look in one file, instead of paging through every record in a database, to find a particular value or determine a sort order, those
¤ Click in the text box next to Indexed in the Field Properties pane.
operations happen much more quickly when performed on indexed fields. You can choose to index a field at any time.
‹ Click the button and select Yes (Duplicates OK) from the menu.
Note: The Indexed property changes to match your choice.
■ A drop-down menu button appears.
93
6048-4 ch03.F
10/19/99
1:50 PM
3
Page 94
CHAPTER 3: CREATE TABLES
ADD PICTURES TO RECORDS
n addition to text and numerical values, you can store pictures in your Access database. Access uses the Object Linking and Embedding (OLE) protocol to make that possible.
I
⁄ Type the name of your field here.
94
Pictures are useful items to store in a database. Sales representatives can call up photos or illustrations of products as well as price and availability information to better inform customers about products.
¤ Press Enter.
You can also allow users to include video, sound, and other file types in your database through the Object Linking and Embedding protocol.
‹ Click the drop-down menu button.
› Click OLE Object from the menu that appears.
6048-4 ch03.F
10/19/99
1:50 PM
Page 95
II
What graphic file formats can be put in an OLE Object field? Access supports most of the popular graphics file formats, including JPEG (.jpg), GIF (.gif), and Windows bitmaps (.bmp).
■ OLE Object appears in the Data Type cell.
Á Type a caption for the field here.
ˇ Type a description for the
Note: Only enter a caption if you want something other than the field name to be the caption.
field here.
CREATE TABLES, FORMS, AND REPORTS
How do I include other types of files, such as sound and video, in an OLE Object field? Simply set the field’s data type to OLE Object. You can enter any file’s name in the field when you are entering data.
MAKE THE PHOTO FIELD REQUIRED
¤ Click the drop-down menu button.
⁄ Click the text box next to Required in the Field Properties pane.
‹ Select Yes from the menu.
95
6048-4 ch03.F
10/19/99
1:50 PM
3
Page 96
CHAPTER 3: CREATE TABLES
CREATE A LOOKUP COLUMN ou can include a list of values that users may choose from when entering data in a field. Establishing a lookup column is another way to make data entry easier and reduce spelling mistakes.
Y
⁄ Click the Data Type column of the field you want to make a lookup column.
Including a lookup column in a field is a good idea if a number of values occur frequently in that field. You might also want to include a lookup field if the data elements are hard to remember, such as state
¤ Click the drop-down menu button. ‹ Click Lookup Wizard.
abbreviations, product codes, or departments. Access can draw the values for your lookup column from an existing field, or you can enter them yourself.
■ The Lookup Wizard appears.
› Click the top radio button to use data from another table. ˇ Click Next.
96
6048-4 ch03.F
10/19/99
1:50 PM
Page 97
II
Á Click the table to provide the values for your lookup column.
‡ Click Next.
CREATE TABLES, FORMS, AND REPORTS
How do I create my own list of values for my lookup column? The first screen of the Lookup Wizard gives you a choice between entering your own values or picking a table or query to provide values. To enter your own set of values, click the radio button next to “I will type in the values that I want.”
How do I retrace my steps and change my lookup column? You can revisit previous screens in the wizard by clicking the Back button.
■ The next screen appears. ° Click the field you would like to include in your lookup column.
· Click the forward arrow to add the field to the Selected Fields list.
CONTINUED
97
6048-4 ch03.F
10/19/99
1:50 PM
Page 98
3
CHAPTER 3: CREATE TABLES
CREATE A LOOKUP COLUMN lookup column is essentially a menu of choices for a field. Instead of entering data by hand, your users simply pick a choice from the lookup column. When you have a limited set of values for a particular field, a lookup column is a good choice, because it reduces the possibility of data entry errors.
A
■ The field appears in the Selected Fields list.
If a field might have many possible values, however, you probably shouldn’t use a lookup column. Either your users won’t be able to enter the values they want or they will need to scroll through an excessively long list. Access provides a handy wizard that automatically creates the lookup column for you; all you have
‚ Click Next.
CONTINUED to do is provide the values. You can either type in the values by hand or copy the values from another Access table or even a query. (To learn about queries, see Chapters 9 and 10.)
■ The Column Width screen appears. — Position the mouse pointer over the right edge of the column.
Note: The pointer changes into a vertical bar with a double-headed arrow across it when it is in the proper position.
± Drag the edge until it is the desired size.
Á Click Next.
98
6048-4 ch03.F
10/19/99
1:50 PM
Page 99
II
ª
Type the name of your lookup column here.
£ Click Finish.
CREATE TABLES, FORMS, AND REPORTS
Can Access use a query to generate the values for my lookup column? Access can use an existing table or query to generate values for your lookup column by clicking the radio button next to Queries in the second screen of the Lookup Wizard. If you want to see a list of all your tables and queries, click the radio button next to Both.
How do I stop the wizard without creating the lookup column? You can stop the wizard at any time by clicking the Cancel button.
■ The Design View of your table appears.
Note: To accept the default value, do nothing.
99
6048-4 ch03.F
10/19/99
1:50 PM
3
Page 100
CHAPTER 3: CREATE TABLES
ADD A VALIDATION RULE sing Access, you can set rules that data entered into your database must follow. For instance, data in a field listing the sales tax in a state would need to be between zero and one.
U
⁄ Click anywhere in the row to which you would like to add a validation rule.
100
Validation rules can be as simple or as complex as you want to make them. You build your rule with the Expression Builder. Validation rules are another way to reduce data entry
¤ Click in the text box next to Validation Rule in the Field Properties pane.
mistakes. By ensuring each entry meets the guidelines you set for the field, you reduce the chance of incorrect data entering your database.
■ An ellipsis button appears.
‹ Click the ellipsis button.
6048-4 ch03.F
10/19/99
1:50 PM
Page 101
II CREATE TABLES, FORMS, AND REPORTS
What kind of data validation does Access do automatically? Access makes sure the data in a field matches the field’s data type. For instance, Access won’t let a user enter text data in a number field.
How do I erase what I just did in the Expression Builder without canceling the entire expression? You can undo your latest change by clicking the Undo button on the right side of the Expression Builder.
How do I get help using the Expression Builder? You can open the Help Topics associated with the Expression Builder by clicking the Help button on the right side of the Expression Builder or clicking the Help button on the Expression Builder’s title bar.
■ The Expression Builder appears. › Click in the Expression Window.
ˇ Type your validation rule here. One rule might be "Between 1 and 20."
■ The validation rule appears.
Á Click OK.
101
6048-4 ch03.F
10/19/99
1:50 PM
3
Page 102
CHAPTER 3: CREATE TABLES
CREATE AN INPUT MASK ou can make your database easier to use by assigning input masks. Input masks prompt users to enter data in a pattern you define. Input masks are particularly useful for entering dates and
Y
⁄ Click anywhere in the row of the field you would like to assign an input mask to. ¤ Click in the text box next to Input Mask in the Field Properties pane.
102
times. Rather than allowing users to enter data inconsistently, input masks guide users through the process and ensure the data is entered consistently. Access includes several predefined input masks, and you
‹ Click the Ellipsis button. Note: You might be asked to name and save your table. If you are, click Yes to continue.
can also define your own input masks. An easy-to-use wizard guides you through the mask selection process.
■ The Input Mask Wizard appears. › Click the mask you would like to use.
ˇ Click Next.
6048-4 ch03.F
10/19/99
1:50 PM
Page 103
II
Can I test an input mask to see how it works? You can test the input mask you’ve chosen by clicking in the Try It text area at the bottom of the wizard screen.
■ The next screen appears.
Á Click Next to accept the mask and placeholder characters.
CREATE TABLES, FORMS, AND REPORTS
How do I get help in creating my new input mask? You can get help in creating your new input mask by clicking the Edit List button at the bottom left of the first Input Mask Wizard screen and then clicking the Help button on the right side of the Customize Input Mask Wizard screen that appears.
How do I change the placeholder character in my input mask? You can change the placeholder character by clicking the drop-down menu button beside the words “Placeholder character” in the second screen of the wizard. How do I create my own input mask? You can create your input mask, or change an existing one, by clicking the Edit List button at the bottom left of the first Input Mask Wizard screen and making your changes on the screen that appears.
■ The Checkered Flag screen appears.
‡ Click Finish.
103
6048-4 ch03.F
10/19/99
1:50 PM
3
Page 104
3
CHAPTER 3: CREATE TABLES
SAVE A TABLE orking in Access is easy, but you wouldn’t want to repeat any of your work unnecessarily. The best way to make sure you don’t lose any of your work is to save your tables frequently.
W
⁄ Click File on the Access Main Window menu bar.
Access prompts you to name your table when you save it for the first time. You can choose any name up to 255 characters, including spaces. You should pick a name that is short enough to work with easily but long enough
¤ Click Save.
to distinguish this table from the other tables in the database. Access warns you if you choose a name that has already been assigned to another table in your database.
■ The Save As dialog box appears. ‹ Enter a name for your table.
104
› Click OK.
6048-4 ch03.F
10/19/99
1:50 PM
Page 105
3
CHAPTER 3: CREATE TABLES
II CREATE TABLES, FORMS, AND REPORTS
OPEN A TABLE ou can open tables from the main database window. You can have as many tables open at one time as your computer’s memory allows. It’s helpful to have a number of tables open at one time if the
Y
⁄ Click the table you want to open.
tables are related and you need to compare their designs. Click a table window to make it active. You can also minimize table windows, then click their buttons at the bottom of the Access window to activate them. Or
¤ Click Design on the toolbar.
choose the table from the window menu.
■ The table opens in Design View.
105
6048-4 ch03.F
10/19/99
1:50 PM
Page 106
3
3
CHAPTER 3: CREATE TABLES
CLOSE A TABLE he more tables you have open, the more memory your computer devotes to keeping track of them and redrawing the screen when you
T
⁄ Click the Close box.
106
move or switch between windows. With this in mind, it’s a good idea to close any tables you are not currently using.
Closing unneeded tables lets your computer redraw the screen and update your changes more quickly.
■ The table closes.
6048-4 ch03.F
10/19/99
1:50 PM
Page 107
3
CHAPTER 3: CREATE TABLES
II CREATE TABLES, FORMS, AND REPORTS
RENAME A TABLE ou can rename a table quickly and easily in Access. You may want to rename a table to resolve any naming conflicts that arise, or to make a table’s name better reflect
Y
⁄ Right-click the name of the table to be renamed.
how it functions within a database. You might also want to rename a table if it is no longer used in the database but might be useful in the future. Renaming the table in a way that makes its
¤ Click Rename.
role clearer could help you or another Access user in the future. For example, “Sales leads 12/98” would be a good contrast to “current sales leads.”
‹ Type your new name for the table.
› Press Enter.
■ The Table Shortcut Menu appears.
107
6048-4 ch03.F
10/19/99
1:50 PM
3
Page 108
CHAPTER 3: CREATE TABLES
COPY A TABLE FROM ONE DATABASE TO ANOTHER
opular tables, such as those containing information about people, can often be used in more than one database. Access enables you to copy tables from one database to another quickly and easily. With
P
a few simple commands from the shortcut menus, available by right-clicking the tables, you can copy a table in just a few seconds. That’s preferable to spending the minutes or hours it would take to recreate the table
⁄ Right-click the table you want to copy.
‹ Click File on the Main Access Window menu bar.
■ The Table Shortcut Menu
■ The File menu appears.
appears.
¤ Click Copy.
108
› Click Open.
and any validation rules or input masks associated with it. Access warns you if a table exists in the target database with the same name as the table you want to copy.
ˇ Click the database to which you want to copy the table.
Á Click Open. Note: The original database closes. Access allows only one database to be open at a time.
6048-4 ch03.F
10/19/99
1:50 PM
Page 109
II CREATE TABLES, FORMS, AND REPORTS
Can I copy a table to more than one database at a time? Yes. The table you copied remains in the clipboard after you paste it to the target database. If you want to copy the table to a second database, simply open the other database and paste the table into it.
How do I move the table from the first database to the second? To move a table from one database to another, removing the table from the first database, choose Cut instead of Copy from the shortcut menu.
How do I make sure I don’t accidentally erase another table with the same name? Access warns you if you are about to add a table with the same name as an existing table. If you want to replace the existing table with the one you copied, click Yes. If not, click No.
■ The target database opens.
■ The database shortcut menu appears.
· Type the name of your table here.
‡ Right-click any blank
° Click Paste.
Note: The name of the table in this database does not have to be the same as its name in the old database.
space in the database window.
‚ Click OK. Note: Your table appears in the database window. You have several paste options available; in this example, we copied the table's data and structure.
109
6048-4 ch03.F
10/19/99
1:50 PM
3
Page 110
3
CHAPTER 3: CREATE TABLES
COPY A TABLE WITHIN A DATABASE ometimes, you may want to create two tables that are almost alike, but different in some important respects. Rather than duplicate your
S
⁄ Right-click the table you want to copy. ■ The Table shortcut menu appears.
110
efforts and create a second table from scratch, you can reuse your work on the first table. To do so, you simply copy the table and save it under a different name.
¤ Click Save As.
Access warns you if you accidentally try to save the second table under the same name as the original.
■ The Save As dialog box appears. ‹ Type the name of your table here.
Note: The name of the copy must be different from the name of the original.
› Click OK.
6048-4 ch03.F
10/19/99
1:50 PM
Page 111
3
CHAPTER 3: CREATE TABLES
II CREATE TABLES, FORMS, AND REPORTS
DELETE A TABLE
ccess makes it easy to delete unwanted tables. By clicking the table you want to delete and clicking the Delete button on the toolbar, you can get rid of any tables you no longer need.
A
Access asks you to confirm that you want to delete the table. You can configure Access to not verify every delete action by clicking the Help button in the Confirm Delete dialog box.
⁄ Click the table you want to delete.
■ The Confirm Delete dialog box appears.
¤ Click the Delete button on the toolbar.
‹ Click Yes.
You can restore a table by clicking the Edit menu in the main Access window and clicking Undo Delete.
■ The table disappears.
111
6048-4 ch04.F
10/19/99
1:54 PM
4
Page 112
CHAPTER 4: ENTER AND EDIT TABLE DATA CREATE TABLES, FORMS,AND REPORTS
2 CHAPTER 4: ENTER AND EDIT TABLE DATA
ENTER AND EDIT TABLE DATA To enter and edit table data, you use Datasheet view (as opposed to the Design view you used to create the table). You can click directly into a cell to edit the data using standard keyboard techniques. Columns in the datasheet correspond to the fields in your table, and rows to the records in the table. You can use all of the data and text editing techniques that are possible in other Windows
applications. For instance, you can highlight text and press the Delete key to erase the text. You can also highlight a selection of text and begin typing your replacement text. Access substitutes the text you type for the text you had highlighted. You can also correct spelling and insert words by clicking at the end of, or within, a text string and typing the text you want to add.
Copying and Moving Data–
Moving Through Records–
Within Access, you can copy and move data from one cell to another, either within a table or between tables. You can select all of the data in a cell by double-clicking in the cell, move it by clicking the Cut button on the Access toolbar, or copy it by clicking the Copy button. You can move data from more than one cell by clicking in one cell and, while holding down the mouse button, dragging the cursor into the other cells containing the information you want to move. If you want to copy or move the data from an entire column, simply click the column selector and cut or copy the text normally. LName
FName
Smith Martin
Rob Rick
LName
FName Steve
112
Access gives you a number of ways to move among the records in your table. You can step up and down one record at a time to compare records, make sure there are no duplications, and ensure the data has been entered properly. Move one page at a time, or use the slider on the vertical scroll bar to move through a document quickly. You can move within your table by using the controls at the bottom of the screen, which resemble those of a videocassette recorder, or by using the keyboard. Access uses a number of clear visual signals to let you know which record is active and which cell would be modified if you were to enter data from the keyboard.
6048-4 ch04.F
10/19/99
1:54 PM
Page 113
Checking Spelling–
Hyperlinks–
Ka t
? Suggest:
cat
II CREATE TABLES, FORMS,AND REPORTS
Access gives you a powerful tool for checking the spelling of the information in your tables. You can check your spelling in American or British English as well as a number of other languages. The Spelling Checker’s interface is easy to understand and simple to use. Access displays the word it cannot find in its active dictionary, suggests alternatives where possible, and lets you enter your own corrections if none of the program’s suggestions is appropriate. The main Spell Check window also gives the option of ignoring one or all occurrences of the word in question, change this one or every occurrence of the word, ignore a field, or add the word to a custom dictionary.
There are times when you might want to refer to information or documents outside of your table. Those documents might be Web pages of companies or friends, other Access databases, or text documents of use to your users. Adding a hyperlink lets you refer to documents in your database, elsewhere on your computer, anywhere on your local network, or on the Internet. Clicking a hyperlink moves the user to the new document; Access will start the appropriate program to ensure the user can download or view the new document. Hyperlinks are an extremely flexible tool for overcoming the limitations of Access’ data types. For instance, including a hyperlink to a text document means that you can make notes available to yourself and your users that contain more than 255 characters, the maximum length of an Access text field.
http://www...
113
6048-4 ch04.F
10/19/99
1:54 PM
4
Page 114
CHAPTER 4: ENTER AND EDIT TABLE DATA
OPEN A TABLE IN DATASHEET VIEW
pening a table in Datasheet view enables you to work with that table’s data. You can add new information, modify existing information, copy information to other Access (and Office) documents, and compare the contents of any documents you have open at the same time.
O
OPEN A TABLE IN DATASHEET VIEW
⁄ Start Access as you learned in Chapter 1.
¤ Click the radio button next to “Open an existing file.” 114
Unlike Design view, which you most often use to modify the structure of your table (you used Design view in Chapter 3 to create a table), Datasheet view is best suited to entering data into and modifying data already in your tables. It is possible to change your table’s structure from within Datasheet view, but you’ll
‹ Click the database you want to open. › Click OK.
find Design view’s interface better suited to making those changes. Opening a table in Datasheet view also allows you to scan your data for patterns or unusual values. You can use filters (covered in Chapter 5) and queries (covered in Chapters 9 and 10) to ask questions about your data.
■ The database appears. ˇ Click the table you want to open.
Á Click the Open button on the toolbar. Note: You can also open a table in Datasheet view by double-clicking it.
6048-4 ch04.F
10/19/99
1:54 PM
Page 115
II
■ The table appears.
CLOSE A TABLE IN DATASHEET VIEW
⁄ Click the Close box at the upper-right corner of the window.
CREATE TABLES, FORMS,AND REPORTS
How do I know how many records there are in a table? You can tell how many records there are in a table by looking at the gray area just below the Records window. The number of records appears next to the Enter New Records control.
I have more fields than will fit on the screen. How can I look at them? To scroll horizontally within your table, use the horizontal scroll bar at the bottom right of the Datasheet View window.
■ The table disappears.
Note: You may be asked to save any changes you made. If you want to save your changes, click Yes.
115
6048-4 ch04.F
10/19/99
1:54 PM
4
Page 116
CHAPTER 4: ENTER AND EDIT TABLE DATA
SWITCH BETWEEN DATASHEET VIEW AND DESIGN VIEW f you happen to be in one view and want to perform a task that is easier to do in the other view, you can switch quickly and easily. Design view is better suited to making changes to the structure of your table, such as creating new fields, changing data types, or adding field descriptions.
I
SWITCH FROM DATASHEET VIEW TO DESIGN VIEW
⁄ Right-click the title bar of the Datasheet View window.
116
Datasheet view, on the other hand, is perfect for entering data into your table once its structure is established. For instance, if you are entering data into an existing table and realize you need to add another field, you can save your changes, switch from Datasheet to Design view, add the field, and
¤ Click Table Design in the shortcut menu that appears.
return to Datasheet view to continue entering data. The field you added will be blank, but you can step back through your datasheet and add the values you need.
Note: Save the table if you are prompted to do so.
■ The table reappears in Design view.
6048-4 ch04.F
10/19/99
1:55 PM
Page 117
II
SWITCH FROM DESIGN VIEW TO DATASHEET VIEW
⁄ Right-click the title bar of the Design View window.
¤ Click Datasheet View in the shortcut menu that appears.
CREATE TABLES, FORMS,AND REPORTS
I started entering data in a blank table in Datasheet view.What is the easiest way for me to name the fields and set data types? The easiest way to name the fields and set the data types in your new table is to switch from Datasheet to Design view, saving and naming the table when prompted.
When should I work with a table in Design view and when should I use Datasheet view? Design view is best suited for changing the structure of your table, whereas Datasheet view is much better suited for data entry.
■ The table reappears in Datasheet view.
117
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 118
CHAPTER 4: ENTER AND EDIT TABLE DATA
ENTER DATA INTO A TABLE ou can enter data into a table in a variety of ways. The most straightforward method, covered in this task, is to enter the data directly into the table by hand. Access gives you a number of visual signals to let you know
Y
⁄ Click the name of the table into which you want to enter data.
118
which record is active, when you have reached the end of a record, and into which cell you are entering data. You can use a number of keys to let Access know you are finished entering data into a cell and want to move to the next
¤ Click Open.
one. You can use the Tab key, the Enter key, the right arrow key, or even the mouse (by clicking inside the next cell) to move from your current cell.
■ The table appears.
‹ Enter data into the first field.
6048-4 ch04.F
10/19/99
1:55 PM
Page 119
II
■ A Pencil button appears next to the record being entered.
› Press Enter when you are done entering data into this field.
■ When you begin entering data, a new record appears below the current record.
Note: You can also press the Tab key to move to the next field.
CREATE TABLES, FORMS,AND REPORTS
How do I save my new records without using the File menu? Access automatically saves a record when you move to the next record.
Can I press a key other than the Tab key to move to the next field? You can move to the next field in your table by pressing the Enter key or the right arrow key.
■ The cursor appears in the next cell.
119
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 120
CHAPTER 4: ENTER AND EDIT TABLE DATA
MOVE THROUGH RECORDS: MOVE FORWARD OR BACK ONE RECORD hen you open your tables, regardless of whether you open them in Design view or Datasheet view, Access allows you to move through the records one at a time. If your tables are
W
MOVE FORWARD ONE RECORD
⁄ Click the Next Record button.
120
small, or if there’s a relatively small selection of records you’re interested in, you can become quite familiar with your data by stepping through it. Access lets you know which record is active as you move
■ The number of records in this table and the number of the current record are displayed here.
through your tables. If you look at a table in Datasheet view, an arrow appears in the row selector of the active record, and the first field in the record is selected.
■ The next record becomes active.
6048-4 ch04.F
10/19/99
1:55 PM
Page 121
II
MOVE BACK ONE RECORD
⁄ Click the Previous Record
CREATE TABLES, FORMS,AND REPORTS
Is there a keyboard shortcut for moving back one field? You can use the key combination Shift+Tab to move back one field in your table.
How do I scroll up and down my list of records? You can use the PgUp and PgDn keys to scroll through your records one page at a time.
■ The previous record becomes active.
button.
121
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 122
CHAPTER 4: ENTER AND EDIT TABLE DATA
MOVE THROUGH RECORDS: MOVE TO THE FIRST OR LAST RECORD t’s easy to move up or down one record at a time in your database, but Access also makes it simple for you to move to the first or last record of your database with a single click of the mouse.
I
MOVE TO THE FIRST RECORD
⁄ Click the First Record button.
122
You can move to the first or last record of your database using controls at the bottom of the screen, which resemble those of a videocassette recorder, or by using the keyboard.
Wherever you are in your table, you can add a new record by clicking the control at the bottom of the Table window.
■ The first record becomes active.
6048-4 ch04.F
10/19/99
1:55 PM
Page 123
II
Is there a keyboard shortcut for moving to the last field of the last record? You can move to the last field of the last record by pressing Ctrl+End.
MOVE TO THE LAST RECORD
⁄ Click the Last Record button.
CREATE TABLES, FORMS,AND REPORTS
Is there a keyboard shortcut for moving to the first field of the first record? You can move to the first field of the first record by pressing Ctrl+Home.
I know the number of the record I want to move to. Is there an easy way to get there without scrolling? You can move directly to a record by pressing F5, typing the record number in the Record Number box, and pressing Enter.
■ The last record becomes active.
CREATE A NEW RECORD
⁄ Click the New Record button to enter a new record.
123
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 124
CHAPTER 4: ENTER AND EDIT TABLE DATA
SCROLL THROUGH DATA ccess gives you the ability to move through your data one record at a time. You can scroll through your table without changing which cell is active.
A
SCROLL DOWN ONE RECORD AT A TIME
⁄ Click the down arrow on the vertical scroll bar.
124
Scroll through your records by using the scroll bar at the right side of the table window. You can also scroll within a record using the horizontal scroll bar at the bottom of the window.
Scroll up or down one record at a time by clicking the up and down arrows on the scroll bar, or scroll one page at a time by clicking on the bar itself.
■ The list of records moves up one place.
Note: Scrolling through a table does not change which record is active.
6048-4 ch04.F
10/19/99
1:55 PM
Page 125
II
SCROLL UP ONE RECORD AT A TIME
CREATE TABLES, FORMS,AND REPORTS
Does scrolling through my records change which record is active? Using the scroll bar to scroll up and down your list of records does not change which record is active. Using the up and down arrow keys moves the cursor into another record, changing which record is active.
Can I use the keyboard to move up and down my list of records? You can use the up and down arrow keys to move through your records.
■ The list of records moves down one place.
⁄ Click the up arrow on the vertical scroll bar.
125
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 126
CHAPTER 4: ENTER AND EDIT TABLE DATA
SCROLL THROUGH DATA: MOVING UP AND DOWN ONE PAGE AT A TIME
ccess gives you the ability to move through your data one screen at a time. You can scroll through your table without changing which cell is active.
A
SCROLL DOWN ONE PAGE AT A TIME
⁄ Click the vertical scroll bar below the slider.
126
Scroll through your records by using the scroll bar at the right side of the table window. You can also scroll within a record using the horizontal scroll bar at the bottom of the window.
To scroll one screen at a time, simply click any blank space on the scroll bar. Clicking above the slider scrolls up one screen, clicking below it scrolls down one screen.
■ The list of records moves down one page.
6048-4 ch04.F
10/19/99
1:55 PM
Page 127
II
SCROLL UP ONE SCREEN AT A TIME
⁄ Click the vertical scroll bar above the slider.
CREATE TABLES, FORMS,AND REPORTS
How do I keep track of where I am in the table if I move through the records using the slider? A balloon appears with the number of the record displayed at the top of the screen.
Is there a keyboard shortcut for moving up and down screens of records? You can move up and down screens of records by pressing the PgUp and PgDn keys.
■ The list of records moves up one screen.
MOVE THROUGH RECORDS USING THE SLIDER
⁄ Click the slider and, without letting go of the mouse button, drag the slider up and down the vertical scroll bar to move through the records. 127
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 128
CHAPTER 4: ENTER AND EDIT TABLE DATA
ZOOM INTO A CELL ooming into a cell means that you can expand your view of the cell, making it easier for you to edit the data in the cell. In addition to making the contents of a cell easier to view, zooming into a cell puts all of
Z
⁄ Click in the cell you want to zoom into.
the cell’s content in the window at one time. The standard view of a cell only shows you one line of text. Zooming into the cell enables you to look at its entire value, up to the size of 255 characters.
¤ Press Shift+F2.
You can zoom into a cell at any time from your keyboard. The keyboard shortcut for zooming into a cell is Shift+F2. Adjust the font and font size of text in the Zoom window for easier viewing.
■ The Zoom window appears. ‹ Edit the cell's text. › Press OK.
128
CHANGE THE FONT AND SIZE OF ZOOM WINDOW TEXT
⁄ Zoom into a cell. ¤ Click Font.
6048-4 ch04.F
10/19/99
1:55 PM
Page 129
II
■ The Font window appears.
■ Your choice is previewed here.
‹ Choose a font and size for the Zoom window text.
› Press OK.
CREATE TABLES, FORMS,AND REPORTS
Does the font I choose for the Zoom window affect the font Access uses for the cell in Datasheet view? Your choice of font in the Zoom window does not affect the font Access uses to display the cell’s content in Datasheet view.
How do I close the Zoom window? You can close the Zoom window by clicking the Close box at the upper right of the window, clicking Cancel, or pressing the Enter key.
■ The text in the Zoom window changes to match your choice.
129
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 130
4
CHAPTER 4: ENTER AND EDIT TABLE DATA
ADD A RECORD
ccess makes it easy for you to add new records to your table. You can add new records by finishing your current record and pressing Tab, or by clicking the New Record button at the bottom of the Datasheet View window.
A
⁄ Click the New Record button.
130
You can also add a new record by clicking the Edit menu. Once the Edit menu is open, click Go To. A submenu appears. Click New Record from the submenu. Add a new record to your table to reflect each new entity in the collection. Combining
information for two or more items into one record can be tempting, but it is best to make sure each item holds a unique place in the table.
■ A new record appears.
Note: Type in your record as you learned earlier in this chapter.
6048-4 ch04.F
10/19/99
1:55 PM
CHAPTER 4: ENTER AND EDIT TABLE DATA
II CREATE TABLES, FORMS,AND REPORTS
4
Page 131
DELETE A RECORD ccess makes it easy for you to delete unneeded records from your table. You can delete records by selecting the entire row and pressing the Delete key or the Backspace key. If you like, you can also delete a record by clicking the Edit
A
⁄ Right-click the row selector of the row you want to delete. ■ The row is highlighted.
menu. Once the Edit menu is open, click Delete Record. You should delete a record from your table any time the item the record refers to is no longer needed in your table. Retaining information about unneeded objects takes up unnecessary
space and could slow performance. It is a good idea to back up your tables before deleting a large number of records, however, so you can recall that information if needed.
■ A shortcut menu appears.
■ The record disappears.
¤ Click Delete Record.
Note: If you are asked if you are sure you want to delete the record, click Yes.
Note: You can also delete a record by clicking its row selector and pressing the Delete key.
131
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 132
CHAPTER 4: ENTER AND EDIT TABLE DATA
EDIT DATA nce you’ve opened your table in Datasheet view, you can use the keyboard and mouse to edit its data. For instance, you can select the contents of a cell and type a replacement value, press Delete
O
CLICKING IN A CELL
⁄ Click in the cell you want to edit.
132
to erase the data, or click anywhere in the cell so you can change the insertion point and add or alter data. Editing data in Access is pretty much the same as in any Windows program.
■ The cursor appears in the cell.
You might edit some of your table data often — for example, a client’s address or contact information. You might never edit other data, such as a contact’s birthday.
¤ Edit the text using the keyboard.
6048-4 ch04.F
10/19/99
1:55 PM
Page 133
II CREATE TABLES, FORMS,AND REPORTS
How do I highlight all of the text in a field? You can highlight all of the text in a field by double-clicking anywhere in the field.
Are there any kinds of fields I can’t edit? You can’t edit the values in an AutoNumber field, a field that derives its value from other fields, or any field you or the database administrator have locked.
Is there a keyboard shortcut for undoing a change to the current record? You can undo a change to the current record by pressing the Esc key before moving to another record.
EDITING HIGHLIGHTED TEXT
⁄ Press Delete.
■ The text disappears.
Note: When a block of text is highlighted, it will be replaced by what you type.
133
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 134
CHAPTER 4: ENTER AND EDIT TABLE DATA
COPY DATA ou can copy data from one cell to another, whether within a table or between tables. You can copy all of the data in a cell by doubleclicking in the cell and either clicking the Copy button on the Access toolbar or using the Edit menu.
Y
⁄ Click the table containing the data you want to copy.
Copying data from one cell to another allows you to keep your data entry to a minimum. For instance, if you were entering contact information for a number of people from the same company, you could copy the company’s name and address to the Clipboard and paste it in
¤ Click Open.
each new record as you went along. If you want to copy the data in an entire column, simply click the column selector and select Copy from the Edit menu.
■ The table opens.
ˇ Right-click in the cell.
‹ Click the cell which holds the data you want to copy.
Á Click Copy from the shortcut menu that appears.
› Select the data. Note: You can select all the data in a cell by double-clicking in the cell.
134
6048-4 ch04.F
10/19/99
1:55 PM
Page 135
II
‡ Right-click in the cell where the data will be pasted.
° Click Paste from the shortcut menu that appears.
CREATE TABLES, FORMS,AND REPORTS
Can I copy information from a table in one database and paste it in a table in another database? You can copy information from a table and paste it in another table or virtually any other Windows application. The Cut and Paste function uses the Windows Clipboard, so you are not limited to cutting and pasting information to and from Access only.
How do I copy an entire record? You can copy an entire record by clicking the row selector (next to the first field in the record) and following the instructions in this task.
■ The data appears in the new cell.
135
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 136
CHAPTER 4: ENTER AND EDIT TABLE DATA
MOVE DATA
rom time to time you’ll need to move data to another area of the same table or even to another table. Unlike copying, which leaves the original information in place, moving information removes it from the original
F
⁄ Click the table containing the data you want to move.
location and places it in another location. Knowing how to move data from one area to another is handy if you ever enter data in the wrong area of your table. Say you entered data into a record with a large number of fields,
¤ Click Open.
and you noticed when you entered the last value on your list that you had skipped a field. As a result, 15 pieces of data are in the wrong cell. To fix this, you could simply move the cells’ contents to the proper location and enter the data you skipped.
■ The table opens. ‹ Click the mouse pointer in the cell with the data you want to move. › Select the data.
136
Note: You can select all the data in a cell by double-clicking in the cell.
ˇ Right-click in the cell. Á Click Cut from the shortcut menu that appears.
6048-4 ch04.F
10/19/99
1:55 PM
Page 137
II
■ The data disappears from its original cell.
° Click Paste from the shortcut menu that appears.
CREATE TABLES, FORMS,AND REPORTS
How can I replace the current value of a field with the value of the same field in the previous record? You can replace the current value of your field with the value of the same field in the previous record by pressing Ctrl+”.
How do I delete the value in a field without copying it to the Clipboard? You can delete a field without copying its contents to the Clipboard by highlighting all of the text in the field and pressing the Delete key.
■ The data appears in the new cell.
‡ Right-click in the cell where the data will be pasted.
137
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 138
CHAPTER 4: ENTER AND EDIT TABLE DATA
CHECK SPELLING: OPEN THE SPELLING WINDOW hen you enter data into a table, you need to be certain of several things. Most importantly, you need to know it’s the right data for the company, person, or object that record represents. Another important consideration is whether the information is current. If the contact information you have for a client
W
⁄ Click in the first cell of the first record. ¤ Click the Spelling button on the toolbar in the Access Main window.
138
is a year old and his or her company moved six months ago, your database is not giving you the information you need. Finally, once you’ve determined your information is accurate and timely, you need to be sure it’s spelled properly. Although the spelling dictionary won’t contain the names of your contacts and their companies,
Note: If you double-click or otherwise highlight one or more cells, only those cells will be spellchecked.
Access displays unrecognized names and asks you if they’re spelled correctly. Then, you’ll be able to look at the contact’s name in isolation and ensure it’s correct. This is especially important if you’ll be using the database to create anything clients or contacts will see, such as mailing labels.
■ The Spelling window appears.
■ The closest entry Access can find appears here.
Note: If there are no misspellings, a dialog box will appear.
■ The entire list of suggestions appears here. The closest entry is at the top of the list and highlighted.
■ The word Access can't find appears here.
4
6048-4 ch04.F
10/19/99
1:55 PM
Page 139
II CREATE TABLES, FORMS,AND REPORTS
4
CHAPTER 4: ENTER AND EDIT TABLE DATA
CHECK SPELLING: ACCEPT THE FIRST SUGGESTION hen you check your table data’s spelling, Access displays any words it doesn’t recognize in the Spelling window and offers alternatives from the dictionary you’ve chosen to work with. Access lists its suggestions according to how likely each
W
⁄ Click Change.
word in the list is the one you meant to type. While the program won’t always guess properly, it will be accurate most of the time. A handy feature of the Access Spell Checker is that it often recognizes words that have run together (that is, have been typed
without a space between them) and makes its first choice those two words with a space between them. The Spell Checker also includes some geographical names, another convenient feature.
■ The cell data changes.
■ Access moves to the next word not in its dictionary.
139
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 140
4
CHAPTER 4: ENTER AND EDIT TABLE DATA
CHECK SPELLING:ACCEPT A SUGGESTION FROM THE LIST hen you check your data’s spelling in Access, the Spell Checker offers suggestions for replacements when it finds a word it doesn’t recognize. Access will put the right word at the top of its suggestion list more often than not, but if it doesn’t, you
W
⁄ Click the suggestion with which you want to replace the cell data. ■ The suggestion you clicked appears in the Change To box.
140
will usually have several more suggestions from which to choose. Access draws the words it suggests from the dictionaries you’ve chosen. If you’re in the United States, that would mean the American English dictionary and any custom dictionary you’ve created.
¤ Click Change.
If the proper alternative in Access’ list of suggestions is not the first entry, you can click on the proper word. After the word appears in the Change To box, click Change.
■ The cell data changes.
■ Access moves to the next word not in its dictionary.
6048-4 ch04.F
10/19/99
1:55 PM
CHAPTER 4: ENTER AND EDIT TABLE DATA
II CREATE TABLES, FORMS,AND REPORTS
4
Page 141
CHECK SPELLING: ENTER A CORRECTION MANUALLY
he spelling dictionaries included with Access are quite comprehensive, though they only contain words commonly used by journalists. In particular, the dictionaries are lacking in technical terms and proper names. Access highlights any words it
T
⁄ Double-click in the Change To box.
doesn’t recognize, so any proper names or technical terms you’ve entered into your tables will appear. If you discover you have misspelled a piece of data and none of the suggestions Access offers is appropriate, you can change the misspelling manually. By default, Access won’t
■ The suggestion is highlighted.
remember the change you’ve made, so if the name or term comes up again, you’ll need to correct any spelling errors by hand. You can, however, correct every occurrence of a particular misspelling. For information on how to do that, see the next task.
¤ Type the word you want to replace the cell’s contents.
‹ Click Change. Note: Access will replace the word with your suggestion and move to the next word not in its dictionary.
141
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 142
CHAPTER 4: ENTER AND EDIT TABLE DATA
CHECK SPELLING: CHANGING ALL OCCURRENCES OF A MISSPELLING hen you enter data into a form, it’s easy to fall into habits. Reversing letters, misspelling words consistently, and running words together happen with increasing frequency as you enter data over a long period of time. If you suspect that you or your users
W
■ The word Access can't find in its dictionary appears here. ⁄ Enter (or select) the word to replace the misspelled word.
142
have made consistent data entry errors, you can replace every occurrence of the misspelling with one click of a mouse button. Clicking Change All causes Access to go through your table and change every occurrence of the misspelling shown in the Spell Checker. Like any other
¤ Click Change All.
action that changes every instance of an item in your database, you need to be very sure you are changing the misspelled value to the correct value.
■ Every instance of the misspelling changes.
4
6048-4 ch04.F
10/19/99
1:55 PM
CHAPTER 4: ENTER AND EDIT TABLE DATA
II CREATE TABLES, FORMS,AND REPORTS
4
Page 143
CHECK SPELLING: IGNORE A WORD hen you check spelling in Access, the program lets you know when it finds a word it doesn’t recognize. You can choose to change the word’s spelling manually, choose an alternative spelling from a list of suggestions Access displays in
W
■ The word Access can't find in its dictionary appears here.
the Spelling Checker dialog box, or ignore the word. Ignoring a word means that Access does nothing with this occurrence of the word it doesn’t recognize — the program doesn’t add the word to a custom dictionary or change it. The next
⁄ Click Ignore.
time Access encounters the same word, it will let you choose what you want to do with it. You can change it, replace it with a value from the list Access provides, or ignore it again.
■ Access moves to the next word it can't find in its dictionary.
143
6048-4 ch04.F
10/19/99
1:55 PM
4
Page 144
CHAPTER 4: ENTER AND EDIT TABLE DATA
CHECK SPELLING: IGNORE ALL OCCURRENCES OF A WORD
ccess gives you a powerful and versatile tool for checking the spelling of the information in your tables. You can check your spelling in American or British English, as well as a number of foreign languages. The Spelling Checker’s interface is easy to understand and simple to use. Access
A
■ The word Access can't find in its dictionary appears here.
144
displays the word it cannot find in its active dictionary, suggests alternatives where possible, and lets you enter corrections if none of the program’s suggestions are appropriate. You can also have Access ignore every occurrence of a word within your table. One instance might be if you use a particular abbreviation
⁄ Click Ignore All.
consistently throughout a table. Rather than add the abbreviation to a custom dictionary and risk having Access ignore a legitimate misspelling whenever you use that dictionary, you can have Access skip any occurrences of the word in this spell check session only.
■ Access moves to the next word it can't find in its dictionary, ignoring the word just encountered.
4
6048-4 ch04.F
10/19/99
1:56 PM
CHAPTER 4: ENTER AND EDIT TABLE DATA
II CREATE TABLES, FORMS,AND REPORTS
4
Page 145
CHECK SPELLING: IGNORE A FIELD
or the Access Spell Checker, a mistake is simply a word that’s not in its dictionary. If the Spell Checker finds a mistake, it alerts you and offers alternative spellings if it can. You can choose one of the provided spellings, retype the word yourself, or tell Access to ignore it.
F
■ The word Access can’t find in its dictionary appears here.
Sometimes, especially when your table has a lot of proper names that aren’t in the Access dictionary, it’s ponderous to have Access stop at every single “mistake.” To get around this, you can have Access ignore all of the values in a particular field. One obvious instance would be a field with individuals’ last
⁄ Click Ignore Field. Note: It is a good idea to go over the contents of an ignored field manually before moving on to other tasks.
names. Access is unlikely to have many of these in its dictionary! So rather than have the Spell Checker stop on each last name, it would be easier to have Access skip that field and do a check by hand.
■ Access moves to the next word it can’t find in its dictionary, ignoring the field you specified.
145
6048-4 ch04.F
10/19/99
1:56 PM
4
Page 146
CHAPTER 4: ENTER AND EDIT TABLE DATA
CHECK SPELLING:WORKING WITH DICTIONARIES hecking the spelling of your table data requires a baseline set of spellings, referred to in Access as a “dictionary.” The main American English dictionary included with Access contains the proper spellings for tens of thousands of words, primarily those commonly used in business and journalism.
C
■ The word to be added appears here. ⁄ Click Add.
146
When Access encounters a word it doesn’t recognize, it offers a list of suggestions based on the dictionary it has open at the time. If you want to make sure Access remembers the word, you can add the word to a dictionary. Adding a word to a dictionary is usually the best way to handle a word Access doesn’t recognize.
■ The dictionary the word is added to appears here.
If you can’t decide whether you want to add the word to a dictionary, you can always click Ignore All to make sure Access doesn’t stop when it encounters the word again. But then you may have to choose Ignore again the next time you spell-check.
■ Access moves on to the next word it can't find in its dictionary.
4
6048-4 ch04.F
10/19/99
1:56 PM
CHAPTER 4: ENTER AND EDIT TABLE DATA
II CREATE TABLES, FORMS,AND REPORTS
4
Page 147
CHECK SPELLING: CREATE A CUSTOM DICTIONARY
ccess comes with a wide variety of dictionaries, but most of them are for checking spelling in different languages. If you use a lot of scientific or topic-specific terms that Access doesn’t include in its standard dictionaries, you should create a custom dictionary containing those words so Access doesn’t grind to a halt every time
A
⁄ Type the name of the new dictionary here.
it finds what may be a very common word in your table. You can create as many custom dictionaries as you like. If you share the machine you work on, you should probably give your dictionary your own name or a distinctive name you’ll remember easily. You might also consider creating a separate dictionary for
Note: Make sure your new dictionary's name has a ".dic" extension.
every project you work on, so if you transfer the dictionary to another user they’ll know exactly which dictionary to load when working with your databases. This is a litttle more work, but it could be worth it on large projects.
■ The Confirmation dialog box appears.
‹ Click Yes.
¤ Press Enter.
147
6048-4 ch04.F
10/19/99
1:56 PM
4
Page 148
CHAPTER 4: ENTER AND EDIT TABLE DATA
CHECK SPELLING: UNDO LAST CHANGE
fter you’ve been checking the spelling of one or more documents for a while, it becomes easy to click Change or Ignore and move on to the next value without paying as close attention as you should. If you inadvertently pass over a misspelling, or if you
A
⁄ Click Undo Last.
148
accidentally pick the wrong value from the list of suggestions Access offers, you can step back and undo your last change. Access remembers every change you’ve made in your table, so it allows you to step back through as many changes as necessary to ensure you’ve made
the proper changes. Once you close the Spell Checker dialog box, however, that memory is erased, and the changes you made become permanent.
■ The last change is undone.
4
6048-4 ch04.F
10/19/99
Page 149
CHAPTER 4: ENTER AND EDIT TABLE DATA
II CREATE TABLES, FORMS,AND REPORTS
4
1:56 PM
CHECK SPELLING: EXITING SPELL CHECK xiting the Spelling Checker is as easy as clicking the Cancel button. You can exit the Spelling Checker at any time. When you reopen the Spelling Checker, Access begins checking from the cell the cursor is in. For example, if you were in the middle of a spell
E
⁄ Click Cancel.
check and needed to run a number of queries to generate data for a meeting, you could run those queries, print the results, and return to your spell check. Once you’ve exited the Spelling Checker, you can work with your table data normally. Access saves your spelling
Note: You can also click the Close box.
changes automatically, so you don’t have to worry about your work being lost. If you’ve made any changes that Access hasn’t saved, the program will display a dialog box prompting you to save your work before it lets you close the table you were working with.
■ The Spelling window disappears.
149
6048-4 ch04.F
10/19/99
1:56 PM
4
Page 150
CHAPTER 4: ENTER AND EDIT TABLE DATA
CHANGE COLUMN WIDTH hen you create a table, Access assigns a default width to each of the columns in your datasheet. If your data doesn’t fit exactly into the default-sized column, you can change the column width to any value you want.
W
⁄ Move the mouse pointer to the field selector row. ¤ Move the mouse pointer over the right edge of the column you want to change.
150
Changing column widths takes a bit of planning, or at least adaptation after you’ve started making changes. Since you only have a fixed amount of screen space to use for your datasheets, you may have to narrow a column if you widen another.
Note: The mouse pointer changes into a vertical bar with a doubleheaded arrow across it.
‹ Click the right edge of the column and, holding the mouse button down, drag the edge until the column is the desired width.
In an address tracking database, for instance, a field for a person’s middle initial could be set to a minimal width to allow more room for the street address.
■ The column changes width.
4
6048-4 ch04.F
10/19/99
1:56 PM
CHAPTER 4: ENTER AND EDIT TABLE DATA
II CREATE TABLES, FORMS,AND REPORTS
4
Page 151
CHANGE ROW HEIGHT ne of the real strengths of Access is that it allows you to display a lot of information in a small area. Datasheets are one of the best examples of that ability. Depending on the size of your monitor and the font size you display your datasheet’s contents
O
⁄ Move the mouse pointer to the row selector column. ¤ Move the mouse pointer over the bottom edge of any row.
in, you can show literally dozens of records on the screen at one time. You can maximize the number of records on your screen by reducing the height of the rows in your table and displaying your data in a smaller font size.
Note: The mouse pointer changes into a horizontal bar with a double-headed arrow across it.
If you don’t need to show that many records at once, or if you want to be able to read your table data more easily, you can increase the height of your rows and display your data in a larger typeface.
■ Every row in the table changes height.
‹ Click the bottom edge of the row and, holding the mouse button down, drag the edge until the row is the desired height. 151
6048-4 ch04.F
10/19/99
1:56 PM
4
Page 152
4
CHAPTER 4: ENTER AND EDIT TABLE DATA
CHANGE FONT OF DATA
ccess gives you a lot of flexibility in defining the appearance of the data in your table. One of those abilities is to change the font, size, and color of your data. The Font window gives you the tools to modify the font, size,
A
⁄ Select the data you want to change the appearance of. ¤ Right-click the title bar of the table.
152
style, and color of the text in your table. You can emphasize certain columns by displaying and printing them in boldface or italic, using a different color, or by presenting them in a larger typeface.
‹ Click Font.
Text you might want to set apart from the rest of your table could include calculated fields, key fields, and other fields you need to reference frequently and pick out from the rest of the data in your tables.
■ The Font window appears.
■ A preview of your choice appears here.
Note: You can choose the font, style, size, underlining, and color for your text.
› Click OK. Note: Click Cancel to leave the data as it was.
6048-4 ch04.F
10/19/99
1:56 PM
CHAPTER 4: ENTER AND EDIT TABLE DATA
II CREATE TABLES, FORMS,AND REPORTS
4
Page 153
CHANGE CELL APPEARANCE
ccess gives you a lot of flexibility in defining the appearance of your table. One of those abilities is to change how the cells and background of your database are drawn on your screen. You can modify your cells to appear flat, recessed, or
A
⁄ Right-click the title bar.
protruding in relation to the page. There is no one best way to draw your cells; you should experiment with different looks until you find the one that is right for you. You can also change your cells’ borders, colors, and line styles. You can use these settings to
¤ Click Datasheet.
improve your data’s readability and to draw attention to the most important fields in your tables. A preview function lets you experiment with these kinds of changes before they take effect.
■ The Datasheet Formatting window appears.
ˇ Choose a background color.
‹ Choose a cell effect.
Á Choose a gridline color.
› Choose which gridlines will be shown.
‡ Choose a border style. ° Choose a line style.
153
6048-4 ch04.F
10/19/99
1:56 PM
4
Page 154
CHAPTER 4: ENTER AND EDIT TABLE DATA
HIDE A FIELD
ccess gives you a lot of flexibility in defining the appearance of your table. One of those abilities is to prevent one or more of your fields from being displayed. You can do so by hiding a field or fields. Hiding a field does not remove it from your table. Instead,
A
⁄ Right-click the table title bar.
154
hiding it sets its column width to zero. When you view your table in Datasheet view, you will be able to select the field and resize it, of course. You can hide a field to help prevent sensitive data from being displayed to users who may not need to know the information. For example, you might want to
¤ Click Unhide Columns.
have an employee’s home address and phone number in easy reach for a department’s administrative staff, but that employee’s salary history should probably not come up on the same screen as their phone number.
■ The Unhide Columns window appears.
‹ Click the check box next to the column you want to hide.
6048-4 ch04.F
10/19/99
1:56 PM
Page 155
II
■ The box’s check mark disappears.
› Click Close.
CREATE TABLES, FORMS,AND REPORTS
How do I hide a column manually? You can hide a column manually by dragging the right column gridline to the left gridline. Hiding a column through the menu does the same thing automatically.
Am I able to hide more than one column at a time? You can hide as many columns as you like by clicking the check boxes next to their names in the Unhide Columns window.
■ The column disappears.
155
6048-4 ch04.F
10/19/99
1:56 PM
4
Page 156
CHAPTER 4: ENTER AND EDIT TABLE DATA
UNHIDE A FIELD
ccess gives you a lot of flexibility in defining the appearance of your table. One of those abilities is to prevent one or more of your fields from being displayed. You can easily unhide your fields as well, making the information available to your users. Hiding a field does not remove a field from your table. Instead,
A
⁄ Right-click the table title bar.
156
hiding it sets its column width to zero. Unhiding a field returns the field to the width it had before it was hidden. You should unhide a column whenever your database’s users would need to know the information the field contains. For example, while any administrative staff member should have access to an
¤ Click Unhide Columns.
employee’s home address and phone number, you could also make that employee’s salary history available to the human resources staff and department manager. You’ll learn how to restrict user access to objects in your database in Chapter 22.
■ The Unhide Columns window appears.
‹ Click the check box next to the column you want to unhide.
6048-4 ch04.F
10/19/99
1:56 PM
Page 157
II
■ A check mark appears in the box.
› Click Close.
CREATE TABLES, FORMS,AND REPORTS
I have clicked several columns that I no longer want to unhide. How do I close the Unhide Columns window without unhiding those columns? You can close the Unhide Columns window without implementing any changes by clicking the close button.
Am I able to unhide more than one column at a time? You can unhide as many columns as you like by clicking the check boxes next to the column names in the Unhide Columns window.
■ The column reappears.
157
6048-4 ch04.F
10/19/99
1:56 PM
4
Page 158
CHAPTER 4: ENTER AND EDIT TABLE DATA
FREEZE A COLUMN
ccess gives you a lot of flexibility in defining the appearance of your table. One of those abilities is to select one or more columns that will always be displayed at the left edge of the screen, regardless of how far over the user scrolls in the table. Freezing a field can help users keep track of which row contains
A
⁄ Click any cell in the column you want to freeze. ¤ Click the Format menu on the main Access window menu bar.
158
the data they are looking for. For instance, if you wanted to check whether or not you owed a friend a letter, you could freeze the First Name and Last Name columns so that you would know which record contained the information you needed. You can unfreeze all of your columns at one time. Simply click the Format menu and select
‹ Click Freeze Columns. › Click the right arrow on the horizontal scroll bar.
Unfreeze All Columns. You do need to unfreeze all of your columns at one time. If you want any columns to stay at the left edge of the screen, you will need to refreeze them as described in this task.
■ The frozen column remains visible at the left edge of the table window.
4
6048-4 ch04.F
10/19/99
1:56 PM
CHAPTER 4: ENTER AND EDIT TABLE DATA
II CREATE TABLES, FORMS,AND REPORTS
4
Page 159
RENAME A COLUMN
ccess gives you a lot of flexibility in working with your new table. You can rename any column in your table from within Datasheet view. You might want to rename a field if you combine two tables into one. If the tables use the
A
⁄ Click in any cell of the column you want to rename. ¤ Click Format on the menu bar of the main Access window.
same field name to represent different information that should be included in your new table, you can rename one or both of the fields to remove any confusion. If you want to have a value other than the column name
‹ Click Rename Column.
appear in your forms and reports, you can define a caption for the field. You can learn how to define a caption in the Chapter 13 task “Name a Control.”
■ The field name is highlighted.
› Type in the column's new name as you learned to do in task “Edit Table Data,” presented earlier in this chapter.
159
6048-4 ch04.F
10/19/99
1:56 PM
4
Page 160
CHAPTER 4: ENTER AND EDIT TABLE DATA
INSERT AND NAME A TEXT COLUMN hen you create a table in Datasheet view, it is easy to forget to include a field or two. Access allows you to insert a field in your table with a minimum of fuss. Your fields are represented as columns in Datasheet view. You
W
INSERT A TEXT COLUMN
⁄ Click anywhere in the column to the right of where you want the new column to appear.
160
can define where you want your new column to appear by clicking in the existing column to the right of where you want the new column to appear. You will be able to assign your new column a name when it appears. If you want to have a value other than the column name
appear in your forms and reports, you can define a caption for the field. You can learn how to define a caption in the Chapter 3 task “Add a Caption.”
¤ Click the Insert menu on the menu bar in the main Access window.
‹ Click Column.
6048-4 ch04.F
10/19/99
1:56 PM
Page 161
II
■ The new text column appears with the name "Field1".
¤ Click the Format menu on the menu bar in the main Access window.
RENAME A TEXT COLUMN
‹ Click Rename Column.
⁄ Click the cursor anywhere
CREATE TABLES, FORMS,AND REPORTS
How do I change my new column’s data type? The default data type is Text. If you want to change it to Number, Date/Time, Yes/No, or another type, first switch from Datasheet view to Design view (right-click the table’s title bar and choose Table Design from the shortcut menu that appears). Then click the Data Type column for your new field and follow the instructions for the task “Select a Data Format” in Chapter 3.
Are there any drawbacks to renaming columns in Datasheet view? While in Datasheet view, it is easy to forget you are changing the underlying structure of your table. If you were to rename a column while entering data, any references to the column by queries, reports, or other tables would be broken.
■ The field name is highlighted.
› Type in the column's new name as you learned to do in task “Edit Table Data,” presented earlier in this chapter.
in the new column.
161
6048-4 ch04.F
10/19/99
1:56 PM
4
Page 162
CHAPTER 4: ENTER AND EDIT TABLE DATA
INSERT AND NAME A HYPERLINK COLUMN
dding a hyperlink column gives you the flexibility to refer to documents in your database, elsewhere on your computer, anywhere on your local network, or on the Internet. You don’t need to import the information into Access; you can just include a link to it. Not only do you avoid the work of copying information into the database, you don’t have to worry about
A
INSERT A HYPERLINK COLUMN
⁄ Click anywhere in the column to the right of where you want the new hyperlink column to appear.
162
updating it if the source document changes. Of course, you don’t automatically see the linked information in your table, either — you need to click the link. A good example of how hyperlinks can be used to your advantage is in Access’ Help system. When you ask the Office Assistant for help, it returns a series of topics, each represented
by a hyperlink in the answer balloon. You can display any of the topics by clicking its hyperlink and, once you’re in the help file you chose, you are usually shown hyperlinks to related Access Help files and to the Microsoft Access technical support Web site.
¤ Click the Insert menu on the menu bar in the main Access window.
‹ Click Hyperlink Column.
6048-4 ch04.F
10/19/99
1:56 PM
Page 163
II
■ The new hyperlink column appears with the name “Field1.”
¤ Click the Format menu on the menu bar in the main Access window.
RENAME THE COLUMN
‹ Click Rename Column.
⁄ Click the cursor anywhere
CREATE TABLES, FORMS,AND REPORTS
Does using hyperlinks degrade performance? Opening the linked file opens another program, which may be of concern if your computer has low memory (RAM). However, you can exit the linked file’s program before you return to Access so impact will be minimal.
How do I insert a hyperlink in my hyperlink column? You can insert a hyperlink in your hyperlink column by clicking the Insert menu and then clicking Hyperlink. A window will appear with a list of objects you can link to your table. (See next task for instructions.)
■ The field name is highlighted.
› Type in the column’s new name as you learned to do in task “Edit Table Data,” presented earlier in this chapter.
in the new column.
163
6048-4 ch04.F
10/19/99
1:56 PM
4
Page 164
CHAPTER 4: ENTER AND EDIT TABLE DATA
CREATE A HYPERLINK WITHIN A TABLE
here are times when you might want to refer to information or documents outside of your table. Those documents might be Web pages of companies or friends, other Access databases, or text documents of use to your users. Adding a hyperlink lets you refer to documents in your database, elsewhere on your
T
⁄ Click in the cell where you want to add a hyperlink. ¤ Click the Insert menu on the main Access window menu bar.
164
computer, anywhere on your local network, or on the Internet. Clicking on a hyperlink moves the user to the new document; Access will start the appropriate program to ensure the user can download or view the new document. Hyperlinks are an extremely flexible tool for overcoming the limitations of Access’ data types.
‹ Click Hyperlink.
For instance, including a hyperlink to a text document means that you can make notes available to yourself and your users that contain more than the 255 characters allowed in an Access text field.
■ The Insert Hyperlink window appears with Create New Document selected.
› Click the Existing File or Web Page button in the Link to pane.
6048-4 ch04.F
10/19/99
1:56 PM
Page 165
II
■ The Existing File or Web Page window appears.
Á Type the address of the file or Web page here.
ˇ Type the text to display in the data cell here.
‡ Press OK.
CREATE TABLES, FORMS,AND REPORTS
What kind of objects can I establish hyperlinks to? You can establish hyperlinks to existing Web pages, other objects in the database, files on your computer or network, and e-mail addresses.
How do I access the linked file once it’s in my table? Just click the link once, as you would if it were in a Web browser. To return to the Access table, click its button on the taskbar.
■ The hyperlink appears in the designated cell.
165
6048-4 ch05.F
10/19/99
5
1:59 PM
Page 166
CHAPTER 5: FIND AND SORT TABLE DATA CREATE TABLES, FORMS,AND REPORTS
2 CHAPTER 5: FIND AND SORT TABLE DATA
FIND, SORT, AND FILTER TABLE DATA
ccess gives you a wide range of tools to find, replace, and manipulate the data in your tables. You can have Access look through your tables for fields containing specific words — or, if necessary, parts of words — to make editing and researching in your databases simple and efficient. You can sort data in a variety of ways, ranging from simple, single-field sorts, in ascending or
A
descending order, to sorts that base a table’s new order on a number of fields sorted according to your wishes. Similarly, you can filter data so that only those records you are currently interested in are displayed. Access allows you to combine filters and sorts, letting you be as selective as you like about which records you want to see.
Find Data–
Replace Data–
When your tables contain only a few records, moving through them one record at a time is acceptable. As your tables grow larger, however, you will need to take advantage of the tools Access gives you to find data in your fields. You can extend your search in a variety of ways, such as requiring the data be in a particular format, making the data match the case of your search term, or using wildcards. Make
Year
Access makes it easy to replace data in your tables automatically, using an interface that’s very similar to the Find dialog box. This is a powerful feature, but it can be tricky; you don’t want to accidentally replace values that shouldn’t change. For instance, if a company you do business with has changed its name, you should make sure to replace the entire contents of the Name field. So, if Smith Distributing changes its name to Smith/Rock Distributing, don’t replace “Smith” with “Smith/Rock” throughout your table; that operation could lead to contacts named “John Smith” being changed (incorrectly) to “John Smith/Rock”. Instead, replace the whole term (“Smith Distributing”).
piste
text
166
post
6048-4 ch05.F
10/19/99
1:59 PM
Page 167
Sort Data–
Filter Data– Although sorts determine how Access presents the data in your table, a sort doesn’t limit the amount of data displayed. If you want to eliminate certain records from a set, you need to use a filter instead. By simply highlighting the text you want to use as your criteria and pressing the Filter button on the toolbar, you can view just the records of most interest to you. You can refilter the results as well, significantly reducing the number of records on your screen.
Make
804
312
621
621
312
703
703
804
Advanced Sorts–
Year
Ford
1972
Chevy
1986
Ford
1961
Honda
1989
Mercedes
1976
Ford
1968
Make
Year
Ford
1972
Ford
1961
Ford
1968
II CREATE TABLES, FORMS, AND REPORTS
Finding records containing specific values is a handy ability, but it’s not the only tool you have at your disposal. You can also have Access sort the data in your tables or query results. You can sort your records in ascending or descending order. For instance, you could track the responses you received from ads placed in different media (magazines, television, radio, Web sites, etc.). Sorting the Responses field in ascending order would tell you which ads generated the best response; sorting the same field in descending order would let you know which ads should be altered or discontinued.
Advanced Filters–
When you work in Access, you’re not limited to sorting your data using a single criterion. By creating an advanced filter (accessed with the Advanced Filter | Sort menu command), you can sort your data with multiple criteria. For example, if you wanted to find the best customers for each sales representative, you could sort the contents of your table by employee name and sales total. The companies’ names wouldn’t need to be sorted — they would automatically follow the sales total associated with that company. Animal
Name
Animal
Name
Rat
Larry
Cat
Bob
Cat
Bob
Cat
Mirrors
Cat
Mirrors
Dog
Aquinas
Dog
Aquinas
Rat
Larry
Simple filters are useful but somewhat limited tools. The main limitation of these filters is that any criteria you enter are added together. If you want to display data that meets any of the filtering criteria you enter, you can Filter by Form. When you use this method, Access displays a blank record from the table and allows you to choose (or enter) the values you want to use as your filter criteria.
CONTINUED
167
6048-4 ch05.F
10/19/99
5
1:59 PM
Page 168
CHAPTER 5: FIND AND SORT TABLE DATA
FIND, SORT, AND FILTER TABLE DATA CONTINUED Combining Sorts and Filters– Individually, sorts and filters are powerful tools. Together, they’re even more effective. When you combine these features, you can filter a table to display only the records you’re interested in, then sort the records to make it easier to see trends in the data. By using multiple criteria for both the filter and the sort, you can group and arrange your data with great precision.
168
Make
Year
Ford
1972
Chevy
1986
Ford
1961
Honda
1989
Mercedes
1976
Ford
1968
Make
Year
Ford
1961
Ford
1968
Ford
1972
5
6048-4 ch05.F
10/19/99
1:59 PM
Page 169
ather than force you to enter every possible text combination, Access allows you to use wildcard characters to broaden the values your search or filter will return. You can use similar tools to determine if two values are equal, not equal, or less than a third value when added together. These comparison operators also work for text strings, so you could
R
make sure every entry in a particular field started with the letter “s.” Finally, Access lets you use the standard mathematical operations of addition, subtraction, multiplication, and division in evaluating your table’s data. Several other mathematical operations, such as integer division and raising numbers to exponents, are available as well.
Comparison Operators
Wildcards
= (Equals)
> (Greater than)
< (Less than)
>= (Greater than or equal to)
<= (Less than or equal to)
<> (Not equal to)
Between (Between 1 and 100 means “between 1 and 100, inclusive.”)
In (In[“cat”, “dog”, “pig”] means “in the set of cat, dog, pig.”) Is Null (There is no value entered in the field.) Is Not Null (There is a value entered in the field.) Like (Like “smi*” means “has the string ‘smi’ at the beginning of the field.”)
Logical Operators
And (“> 0 and <= 10” means “greater than zero and less than or equal to 10.”)
# (“46#7” means “any number with the first two digits 46 and the fourth and final of 7.”) [field name] ( “[MinimumOrder]” means “greater than or equal to the value in the MinimumOrder field.”)
+ (Addition)
- (Subtraction)
* (Multiplication)
/ (Division)
Or (“< -2 or > 2” means “less than –2 or greater than 2.”) Not (Means the statement is false; Not Like “smi*” means “the field does not start with ‘smi’.”)
* (Refers to any characters; “Port*” means “any string starting with Port, such as Portland, Portsmouth, and so on.”)
? (Refers to any single character; “BL-1040?” means “any string where BL-1040 is followed by a single character.”)
Math Operators
II CREATE TABLES, FORMS, AND REPORTS
5
INTRODUCING WILDCARDS AND EXPRESSION OPERATORS
\ (Integer division; all decimal values are cut off without rounding. So 3\2 = 1.) ^ (Exponent) Mod (The remainder of a division operation — 7 Mod 4 = 3.) & (Joining two text strings — hello&world = helloworld.) 169
6048-4 ch05.F
10/19/99
1:59 PM
5
Page 170
CHAPTER CHAPTER 5: FIND#:AND CHAPTER SORT TABLE TITLE DATA
FIND DATA
ccess allows you to look for data within a field or an entire table. If you limit your search to one field, Access will only look for the value in the field you specify. You can tell Access whether you want to find records with the value you entered at the start of the field, in any part of the field,
A
⁄ Right-click the column selector of the field in which you want to find data. ■ Access highlights the column.
170
or as the exact contents of the field. Access also lets you search on a range of values by using wildcards in the search field. An asterisk looks for any number of characters (sm* returns Smith and Smart), a question mark looks for any single character (sm?th returns Smith and
■ A shortcut menu appears. ¤ Click Find.
Smyth), and a pound sign looks for any single number (smith# finds Smith1 and Smith7). If you like, you can make your search string case sensitive. If you do make your search case sensitive, “cummings” would not return “Cummings”.
■ The Find and Replace window appears. ‹ Type the word or sequence of characters you want to find here.
› Click the drop-down menu button at the right edge of the Match field. ˇ Click Any Part of Field. Á Click Find Next.
6048-4 ch05.F
10/19/99
1:59 PM
Page 171
II
How do I search with a formatted search term? You can search for data in a formatted field by clicking More and then the Search Fields As Formatted check box. If you do not use the Search Fields As Formatted option, you must enter the exact value in the field. For instance, clicking the Search Fields As Formatted option would let the search term Oct 96 return dates like 10/17/96 and 10/31/96.
■ The first record matching your search criteria is highlighted.
‡ Click Cancel.
CREATE TABLES, FORMS, AND REPORTS
How do I search the entire table? You can search an entire table by clicking More and then the drop-down menu button in the text box next to Search and clicking All.
How do I make my search case sensitive? You can make your search case sensitive by clicking More and then the Match Case check box. I know how the field(s) I want to find start. How do I search on the first part of a field? You can search on just the start of a field by clicking the drop-down menu button in the text box next to Match and clicking Start of Field.
■ The Find and Replace window closes.
171
6048-4 ch05.F
10/19/99
1:59 PM
5
Page 172
CHAPTER CHAPTER 5: FIND#:AND CHAPTER SORT TABLE TITLE DATA
REPLACE DATA
ccess lets you change values within your tables easily. You can change the values one at a time or all at once. Access allows you to replace data within a field or an entire table. If you limit your replacements to one field, Access
A
⁄ Right-click the column selector of the field in which you want to replace data. Note: If you want to replace data throughout the table, right-click on any column selector and select Products:Table from the Look In text box.
172
will only look for the value in the field you specify. You should be a little bit careful when globally replacing values in a table. In general, you should replace based on the entire contents of a field rather than just part of it. One example of replacing only part of a field
■ Access highlights the column. ■ A shortcut menu appears. ¤ Click Find.
would be if you wanted to replace every occurrence of Smith to Smyth. If you allow Access to change based on a part of the field, the name Smithers would be changed to Smythers.
■ The Find and Replace window opens.
‹ Click the Replace tab.
6048-4 ch05.F
10/19/99
1:59 PM
Page 173
II
How do I make my search case sensitive? You can make your search case sensitive by clicking More and then the Match Case check box.
CREATE TABLES, FORMS, AND REPORTS
How do I skip a replacement? You can skip a replacement by clicking the Find Next button. Access will locate the next occurrence of your search string and ask if you want to replace it.
How do I undo a replacement? You can undo your last replacement by clicking the Undo Last button. Access will step back to the last replacement, undo the change, and ask if you want to replace it. You can continue to step back through your previous changes by clicking Undo Last again.
How do I stop replacing text? You can stop replacing text at any time by clicking the Close button. The Replace window will disappear.
■ The Replace window appears. › Type the text you want to replace here. ˇ Type the replacement text here.
Á Click the drop-down menu button at the right edge of the Match field. ‡ Click Find Next.
■ Access highlights the text to be replaced. ° Click Replace.
Note: Access makes the replacement and continues searching for other instances of the text. A dialog box appears when there are no more replacements to be made. Click OK to continue.
173
6048-4 ch05.F
10/19/99
1:59 PM
Page 174
5
CHAPTER CHAPTER 5: FIND#:AND CHAPTER SORT TABLE TITLE DATA
SORT RECORDS
ccess allows you to sort the data within a table. You can use sorts to arrange your table based on one or more fields. Sorts can be in either ascending or descending order. You might want to sort data in ascending order in a table with a
A
SORT RECORDS IN DESCENDING ORDER
⁄ Click anywhere in the column you want to sort.
174
Date field, such as a health club membership record. You could sort the table in ascending order to see which members joined the earliest and to track club membership growth over time. Sorting in descending order might be used for similar purposes. You could track which
¤ Click the Sort Descending button.
members visit a club by noting when each member attends the club. By sorting the Date field in descending order, you could get a feel for how recent attendance has fluctuated.
■ The records reappear in sorted order.
6048-4 ch05.F
10/19/99
1:59 PM
Page 175
II
SORT RECORDS IN ASCENDING ORDER
¤ Click the Sort Ascending button.
CREATE TABLES, FORMS, AND REPORTS
Can I sort on more than one column using the simple sort? You can sort on more than one column using the Sort Ascending and Sort Descending buttons by selecting more than one column. The columns must be next to each other in the table. Access will sort the field on the left first, using the values in the second field to order records if more than one record has the same value in the first field.
How do I undo a sort? You can undo a sort by clicking the Records menu and clicking Remove Filter/Sort. The records in the table will be returned to their previous order.
■ The records reappear in sorted order.
⁄ Click anywhere in the column you want to sort.
175
6048-4 ch05.F
10/19/99
1:59 PM
5
Page 176
CHAPTER CHAPTER 5: FIND#:AND CHAPTER SORT TABLE TITLE DATA
SORT USING MULTIPLE CRITERIA ou can sort data based on more than one criterion in Access. By using the Advanced Filter/Sort capabilities, you can specify which fields are to be sorted and in what order. Sorting on multiple criteria can be a handy way of sorting data effectively. One use might be
Y
⁄ Click the Records menu on the menu bar of the main Access window. ¤ Click Filter.
176
in a veterinarian’s database of pets and customers. Many pets have the same names, but sorting by pet names and then by an owner’s first and last name would present the database in an understandable order. You could also sort the table based on the last time a pet was
‹ Click Advanced Filter/Sort.
brought in for shots and a checkup. Sorting the table by date would let you know when to call or mail owners to remind them it was time for another checkup for their pets.
■ The Advanced Filter/Sort window appears.
› Make sure the insertion point is in the first cell of the Field row, in the Query By Example (QBE) grid.
6048-4 ch05.F
10/19/99
1:59 PM
Page 177
II
Can I add more than one field at a time to the QBE grid? You can select fields that are next to each other in the field list by clicking the first field name, holding down the Shift key, and clicking the last field name. Every field from the first to the last one you clicked will be highlighted. Click any of the field names and drag them to the QBE grid.
■ The first cell in the Field row of the QBE grid becomes active.
Á Click Last Name.
CREATE TABLES, FORMS, AND REPORTS
How do I clear the QBE grid? You can clear the QBE grid by clicking the Edit menu and clicking Clear Grid.
Do those fields have to be next to each other in the field list? If you want to select fields that are not next to each other, click on each field name while holding down the Ctrl key.
■ Last Name appears in the first cell in the Field row of the QBE grid.
‡ Click in the first cell in the Sort row.
ˇ Click the drop-down menu button. CONTINUED
177
6048-4 ch05.F
10/19/99
1:59 PM
5
Page 178
CHAPTER 5: FIND AND SORT TABLE DATA
SORT USING MULTIPLE CRITERIA CONTINUED
ccess lets you add as many fields to your sort as you like. You can add the fields to the QBE grid one at a time by dragging them from the field list, or you can add them all at once. You can have Access automatically update your sort by clicking the asterisk in the
A
■ The first cell in the Sort row becomes active. ° Click the drop-down menu button.
178
field list. Clicking the asterisk, also known as the All Fields selector, puts all of your table’s fields into a single QBE grid cell. If your table’s layout changes, Access will change the contents of the QBE grid cell to reflect the changes. Adding all of your fields by double-clicking the title bar of
· Click Ascending. ‚ Click in the second cell of the Field row.
the list of fields, clicking one of the highlighted field names, and dragging the group to the QBE grid puts each of your field names in a separate QBE grid cell. If you change your table’s layout, you will need to update your sort manually.
■ The second cell in the Field row becomes active. — Click the drop-down menu button.
± Click First Name.
Á
Click in the second cell of the Sort row.
6048-4 ch05.F
10/19/99
1:59 PM
Page 179
II CREATE TABLES, FORMS, AND REPORTS
How do I add all of my fields to the QBE grid? You can add all of your fields to the QBE grid in two ways. One way is to click the asterisk in the list of fields. The other way is to double-click the title bar of the list of fields, click one of the highlighted field names, and drag the group to the QBE grid.
What is the difference between adding all of the fields by clicking the asterisk or by dragging them? Clicking the asterisk puts all of your fields in a single cell of the QBE grid, whereas selecting them by double-clicking the title bar of the field list and dragging the fields to the QBE grid puts each field in a separate cell.
How does that arrangement affect me? If you click the asterisk to add every field to the QBE grid, Access will automatically update your sort. If you drag the names over using the second method, you will need to update the sort manually.
■ The second cell in the Sort row becomes active.
ª £ Click Ascending.
Click the drop-down menu button.
¢ ° Click Apply Filter/Sort.
Right-click the title bar of the Filter window.
■ The records appear in sorted order.
179
6048-4 ch05.F
10/19/99
1:59 PM
5
Page 180
5
CHAPTER CHAPTER 5: FIND#:AND CHAPTER SORT TABLE TITLE DATA
FILTER RECORDS BY SELECTION
ccess allows you to select which records will appear on the screen. Unlike a sort, which reorders the entire database, a filter hides those records that do not meet your filter criteria. Filtering by Selection lets you easily and quickly specify what
A
⁄ Select the text to use as your filter.
180
text you want Access to use as its filter criteria. By highlighting the text you want to use as your criteria and pressing the Filter button on the toolbar, you can view the records of most interest to you. You are not limited to a single filter by selection. If you like,
¤ Click Filter by Selection.
you can select another bit of text within the filtered table and click the Filter by Selection button again. Access will only show those records that meet both of your criteria.
■ The filtered table appears.
■ The Filter button changes to indicate the table has been filtered.
6048-4 ch05.F
10/19/99
1:59 PM
CHAPTER CHAPTER 5: FIND#:AND CHAPTER SORT TABLE TITLE DATA
II CREATE TABLES, FORMS, AND REPORTS
5
Page 181
FILTER RECORDS BY EXCLUSION
orting your records groups your table contents or query results based on the contents of your fields, whereas filtering your records limits the data Access displays. Filters come in two varieties: inclusive filters (which show records that match the criteria you set) and exclusive filters (which show records that do not match the criteria).
S
⁄ Select the text to use as your filter. ¤ Click Records.
Filtering by exclusion lets you easily and quickly specify what text you want Access to use as its filter criteria. By highlighting the text you want to use as your criteria and pressing the Filter Excluding Selection button on the toolbar, you can hide records that are not of interest to you. You are not limited to a single filter by exclusion. If you like,
‹ Click Filter.
you can select another bit of text within the filtered table and click the Filter Excluding Selection button again. Access will hide those records that meet both of your criteria.
■ The filtered table appears.
› Click Filter Excluding Selection.
181
6048-4 ch05.F
10/19/99
1:59 PM
5
Page 182
CHAPTER CHAPTER 5: FIND#:AND CHAPTER SORT TABLE TITLE DATA
FILTER BY FORM
iltering by selection and filtering by exclusion are useful, but somewhat limited, tools. The main limitation of these two tools is that any criteria you enter are added together. That is, filtering by selection shows records that
F
⁄ Click Records. ¤ Click Filter.
meet both your first and your second criteria. Filtering by exclusion hides records the same way. Filtering by form gives you the ability to filter table data that meet one criterion or another. For instance, you could tell
‹ Click Filter by Form.
Access to show all orders from a particular customer or that had a total retail value of over $1,000. You can pick values to filter in each of the fields in your table by using the drop-down menus that appear when you click in a cell in the Filter by Form grid.
■ The Filter by Form window appears. › Type the first set of values to filter by.
Note: If the field contains a lookup column, a drop-down menu button will appear. Click on it to display the list of values available for that field.
ˇ Click Or.
182
6048-4 ch05.F
10/19/99
1:59 PM
Page 183
II CREATE TABLES, FORMS, AND REPORTS
How do I exit the Filter by Form window without applying the filter? You can exit the Filter by Form window without applying the filter by clicking the Close box at the top-right corner of the Filter by Form box.
How do I add additional terms to my filter? You can add additional terms to your filter by clicking the Or tab at the bottom of the Filter by Form window. If you have already added an Or statement, click the Or tab that is farthest to the right.
Is there a limit to the number of Or statements I can have when I filter by form? You may have as many Or statements in your filter as you like.
■ Another sheet appears to accept your new filtering criteria.
‡ Click Filter.
■ The filtered table appears.
° Click Apply Filter/Sort.
Á Type the second set of values to filter by.
183
6048-4 ch05.F
10/19/99
1:59 PM
5
Page 184
CHAPTER 5: FIND AND SORT TABLE DATA
CREATE ADVANCED FILTERS
ccess gives you the ability to filter table data based on more than one criterion. By using the Query By Example (QBE) grid, you can specify which fields are to be filtered and sorted. You can also specify a sort order for a filtered field. Filtering on more than one criterion can be a handy way of
A
⁄ Click the table you want to filter.
184
effectively leveraging your data. One possible use might be in a veterinarian’s database of pets and customers. Filtering your table to view only those pets that are more than one month past due for an exam would give you a clear picture of which owners should be contacted. An advanced filter lets you combine the capabilities of
¤ Click Open.
filtering by selection, exclusion, and form. While the other methods are often quicker, they are more limited. Creating an advanced filter lets you define all of your filters in one place.
‹ Click Records. › Click Filter.
ˇ Click Advanced Filter/Sort.
6048-4 ch05.F
10/19/99
1:59 PM
Page 185
II CREATE TABLES, FORMS, AND REPORTS
How do I add all of my fields to the QBE grid? You can add all of your fields to the QBE grid in two ways. One way is to click the asterisk in the list of fields. The other way is to double-click the title bar of the list of fields, click one of the highlighted field names, and drag the group to the QBE grid.
What is the difference between adding all of the fields by clicking the asterisk or by dragging them? Clicking the asterisk puts all of your fields in a single cell of the QBE grid, while selecting them by double-clicking the title bar of the field list and dragging the fields to the QBE grid puts each field in a separate cell.
How does that arrangement affect me? If you click the asterisk to add every field to the QBE grid, Access will automatically update your filter. If you drag the names over using the second method, you will need to update the filter manually.
Á Type the name of the first field (ProductID here). ‡ Type the name of the second field (Quantity here). ° Type the ProductID of the first product (14 here is tofu).
· Type the expression to filter this field by (>20 for Product 14, Tofu).
■ The filtered table appears.
‚ Type the next ProductID and expression (16 and >50 for Pavlova). — Click Filter, then Apply Filter/Sort. 185
6048-4 ch05.F
10/19/99
1:59 PM
5
Page 186
CHAPTER 5: FIND AND SORT TABLE DATA
CREATE ADVANCED FILTERS: SORT WITHIN A FILTER n addition to filtering your data through an advanced filter, you can have Access sort the filtered table based on the contents of one or more fields. Sorting within a filter can give you an even clearer picture of your data than using a filter
I
⁄ Click Records. ¤ Click Filter.
alone. One use might be in a veterinarian’s database of pets and customers. Filtering your table to view only those pets that are more than one month past due for an exam would let you know which owners should be contacted. Sorting the records in ascending order by due date
would tell you which pets were the longest overdue. You can sort based on more than one field. Access uses the field farthest to the left as the primary field for its sort.
‹ Click Advanced Filter/Sort.
› Type the filter field names (ProductID and Quantity).
■ The Advanced Filter/Sort window appears.
ˇ Type the first ProductID (14 for Tofu). Á Type the expression to filter this field by (here >20 for Product 14, Tofu).
186
‡ Type the second ProductID and filter expression (16, for Pavlova, and >50). ° In the Sort row, click the field name cell you want to sort on, then click the dropdown menu button.
6048-4 ch05.F
10/19/99
1:59 PM
Page 187
II CREATE TABLES, FORMS, AND REPORTS
How do I sort on a field that is not part of the filter? You can sort the results of your filter based on an unfiltered field by adding the field in the leftmost column of the QBE grid and selecting the appropriate sort order.
How do I decide when to use Filter by Form versus Advanced Filter/Sort? You should use Advanced Filter/Sort whenever you want to both filter and sort the contents of one of your tables.
How do I make my sort go faster? You can make your sort go faster by creating an index for the field you use as the basis for your sort.
■ The Sort cell drop-down menu appears. · Click Descending.
â Click Filter. Ñ Click Apply Filter/Sort.
■ The filtered table appears in sorted order.
187
6048-4 ch05.F
10/19/99
1:59 PM
5
Page 188
CHAPTER 5: FIND AND SORT TABLE DATA
REMOVE A FILTER
ccess allows you to remove a filter at any time. You should remove a filter whenever you want to view your data in its original state. Removing a filter causes the data shown on the screen to
A
⁄ Click Records. ¤ Click Remove Filter/Sort.
188
revert back to its original state, but does not cause Access to erase the query from memory. Instead, Access maintains the filter in its temporary memory.
Note: You can also remove your filter by clicking the Filter button on the main Access window's toolbar.
You can reapply a filter at any time by following the steps in task “Reapply a Filter,” next. Note that if you exit Access, the filter is lost, and you can’t reapply it.
■ The unfiltered table reappears.
5
6048-4 ch05.F
10/19/99
1:59 PM
Page 189
5
CHAPTER 5: FIND AND SORT TABLE DATA
II CREATE TABLES, FORMS, AND REPORTS
REAPPLY A FILTER
ccess allows you to reapply a filter at any time. You can easily switch between the filtered and unfiltered view of your data to get a better perspective on what your data means.
A
⁄ Click Records. ¤ Click Apply Filter/Sort.
When you remove a filter, Access retains it in temporary memory. If you want to reapply the filter, simply click the Apply Filter toolbar button. You can remove a filter at any time by following the steps in
Note: You can also reapply your filter by clicking the Filter button on the main Access window's toolbar.
“Remove a Filter,” the previous task. Note that if you exit Access, the filter is erased and you’ll need to reconstruct it.
■ The filtered table reappears.
189
6048-4 ch06.F
10/19/99
6
2:01 PM
Page 190
CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS CREATE TABLES, FORMS,AND REPORTS
2 CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS
ESTABLISH KEYS AND RELATIONSHIPS
ccess gives you two powerful tools for increasing the efficiency of your databases: the ability to set keys within a table, and the ability to establish relationships between tables. Keys, which give each record a unique identity within a table, are important for ensuring your tables contain no duplicate records. Avoiding record duplication means you won’t end up having
A
two sets of electronic paperwork for a single customer or supplier. Relationships between tables, on the other hand, can be used to automatically update your database whenever a change is made. Rather than having to wade through several tables and risk missing an update or deletion, you can tell Access to implement the updates itself.
Defining a Key–
Multiple-Field Keys–
Put simply, a key is a field or combination of fields that uniquely identifies each record in a table. Automobile license plate numbers are one good example of a key. No two cars have identical numbers, so it is easy to keep track of who owns which car. Attributes of Keys– Another property of key fields is that they are indexed. Indexing a field allows Access to search, sort, and query that field much more quickly. Also, if you establish a field as the primary key in a table, Access will require you to enter a unique value in that field. Requiring a unique value in the key field goes a long way in reducing data entry errors by immediately notifying the person doing the data entry that there is a conflict.
190
001
Unique 1
002
Unique 2
003
Unique 3
004
Unique 4
There might be times when a single field in a table is not sufficient to distinguish one record from another. Access overcomes that problem by allowing you to establish keys consisting of more than one field. One such situation might arise when handling invoices for customer orders. The billing table could have two key fields: the invoice number, and the customer order number. INV001
COR073
INV002
COR062
INV003
COR113
INV004
COR004
6048-4 ch06.F
10/19/99
2:01 PM
Page 191
AutoNumber Fields as a Key Fields–
II CREATE TABLES, FORMS, AND REPORTS
If you wish, Access can automatically assign values to a key field in a table. One time this function might be helpful is when you have a table without a simple, easily known key. A collection of friends’ addresses might include two people with the same name, so it might be a good idea to let Access assign a value to the key field automatically, rather than define a key on three or more fields.
Relationship Builder– Access gives you an intuitive and easy-to-use graphical tool to define relationships between your tables. Using the Relationship Builder, which displays your tables’ relationships and, when prompted, the details of the links, you can add, modify, and delete relationships with ease.
Cascading Changes– 1
Almy, Alan
2
Almy, Lance
3
Price, Bill
4
Bartie, Mike
5
Short, Art
Relationships– Although tables in a database represent unique entities, they are usually closely related to one or more other tables in the database. For instance, customer contact information might be kept in one table and details of their orders in another. Since each order would contain the unique identifier for the customer who made it, the two tables are related by the “customer identification” field. Access lets you define these relationships to help maintain your database’s integrity. Access makes sure that related information in separate tables corresponds appropriately.
In addition to letting Access make sure the data in your tables corresponds to its relations, enforcing referential integrity gives you the ability to have Access automatically update your tables whenever a related table changes. For instance, if a supplier stops carrying a particular item, you could remove all references to that item from your active database. You should certainly archive older copies of the database to ensure your past orders can be recalled if necessary, but there would be no reason to keep that information in the current database. 1820 N. Oak Ace Pins
3245 N. Oak
Time Store
10 E. Water
Pine Logs
742 S. 42nd
1820 N. Oak 3245 N. Oak
Customer ID Address City State
Order ID Customer ID Product ID Total
191
6048-4 ch06.F
10/19/99
2:01 PM
6
Page 192
CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS
DEFINE A PRIMARY KEY
ccess allows you to define a primary key within each of your tables. A primary key field contains a unique value for each record in the table. Another important property of primary key fields is that they are indexed. By maintaining an index of a table’s primary key field, Access is able to search, sort, and query your tables much more quickly.
A
⁄ Click the table you want to open. Note: For this example, we're using a copy of the Northwind database that has had the primary keys removed from the tables.
192
Access also uses primary key fields to ensure there are no duplicate records in your table. Since the primary key is, in part, an index field that does not allow duplicates, Access will warn you automatically if you accidentally enter the same key information twice. Access will offer to create a primary key field when you create a table. You can allow
¤ Click Design.
Access to establish the primary key field or create one of your own. Initially, your table data will be sorted by the contents of the primary key field. (To learn about custom sorting and filtering options, see Chapter 5.)
■ The table opens in Design view.
‹ Click the row selector next to the first row of the table.
› Click Insert. ˇ Click Rows.
6048-4 ch06.F
10/19/99
2:01 PM
Page 193
II CREATE TABLES, FORMS, AND REPORTS
Can I use data types other than AutoNumber for a key field? You can use any data type in a primary key field. The only restriction is that each record must have a unique value in that field.
What types of fields can I relate to an AutoNumber field? You can relate an AutoNumber field to number fields set to Long Integer. Long Integer is the default setting for number fields.
Can a table have more than one primary key? A table can have multiple primary key fields. The important point to remember is that each record must have a unique value in every primary key field.
Á Type the name of your primary key field here.
° Type the field description here.
‡ Select AutoNumber as the field data type.
· Click the Primary Key button.
■ The key designator appears in the row selector of the key field.
193
6048-4 ch06.F
10/19/99
2:01 PM
6
Page 194
CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS
CREATE A RELATIONSHIP
ccess allows you to define relationships between tables at the table level. You may also define relationships between tables at the query level, a topic addressed in Chapter 9. Creating a relationship between tables gives Access the ability to track changes in one table and ensure they are reflected in related tables. One table can
A
⁄ Click the Relationships toolbar button.
194
have relationships with many other tables; you’re not restricted to simply linking table pairs. Define relationships between tables in the Relationship Builder. The Relationship Builder lets you establish relationships using an easily learned graphical tool. Access allows you to add tables to the Relationship Builder
Note: For this exercise, we're using a copy of the Northwind database with the existing relationships removed.
so you can build relationships without cluttering the screen. You can also show all of your tables, clear the window completely, and add or delete tables from the window one by one.
■ The Relationship Builder appears.
¤ If the Show Table dialog box does not appear, click the Show Table button.
6048-4 ch06.F
10/19/99
2:01 PM
Page 195
II
■ The Show Table window
› Click Add.
CREATE TABLES, FORMS, AND REPORTS
Can I have two representations of the same table in the Relationship Builder window at once? You can have two or more representations of the same table in the Relationship Builder. You might want to have two representations open if the database contains enough objects that establishing all the relationships from one object would make the diagram too confusing.
How do I get help on the Relationship Builder? You can click the Help button on the Relationship Builder toolbar at the top of the screen to get help with using the Relationship Builder.
■ The table appears in the
appears.
Relationship Builder.
‹ Click the name of the first table you want to add.
ˇ Click the name of the second table you want to add.
Á Click Add.
CONTINUED
195
6048-4 ch06.F
10/19/99
2:01 PM
6
Page 196
CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS
CREATE A RELATIONSHIP CONTINUED
ccess makes it easy for you to identify the primary key fields in a table by printing their names in bold face. Other field names are printed in regular type. Tables can be related to one another in several ways. The most common relationship
A
■ The second table appears in the Relationship Builder.
between two tables is a one-tomany relationship. In a one-to-many relationship, records from one table, called the primary or parent table, can be referred to more than once in another table. One instance of a one-to-many relationship is
‡ Click Close.
between a table listing customers and another listing orders. No two customers will have the same primary key, but it is very likely that each customer will be identified in more than one order record.
■ The Show Table window disappears.
° Click the name of the field to serve as the base of the relationship.
196
· Drag the field to the corresponding field in the other table.
6048-4 ch06.F
10/19/99
2:01 PM
Page 197
II
■ The Edit Relationship Builder appears.
‚ Click Create.
CREATE TABLES, FORMS, AND REPORTS
Can I establish a relationship between two fields with different names? You can establish a relationship between any two fields that contain the same information and are of the same data type. The only exception is AutoNumber fields, which may only be related to Long Integer fields.
How do I rearrange and resize the tables in the Relationship Builder? You can move and resize the tables in the Relationship Builder in the same way you move and resize database objects throughout Access. For more information on how to move and resize database objects, see task “Move or Size a Window” in Chapter 1.
■ A line appears, indicating the relationship between the two tables.
197
6048-4 ch06.F
10/19/99
2:01 PM
6
Page 198
CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS
ENFORCE REFERENTIAL INTEGRITY
ccess allows you to maintain referential integrity between tables. Maintaining referential integrity means Access ensures that the information in both tables accurately reflects additions, changes, and deletions performed in either table. Maintaining referential integrity also means that Access
A
⁄ Double-click the line representing the relationship you want to use to enforce referential integrity.
198
ensures neither table is changed in a way that will make the relationships between the two tables invalid. Ensuring that modifications to a primary, or parent, table are reflected in related tables is important. For instance, if a customer has an outstanding order on file, deleting that customer’s record in the Client
database could mean the order never gets shipped. Although it is not strictly necessary to enforce referential integrity between related tables, it is an effective way to ensure the information in your database is consistent.
■ The Edit Relationship Builder appears.
¤ Click the Enforce Referential Integrity check box.
6048-4 ch06.F
10/19/99
2:01 PM
Page 199
II
‹ Click Cascade Update Related Fields to automatically pass changes from one table to the other.
ˇ Click OK.
CREATE TABLES, FORMS, AND REPORTS
What happens when I click Cascade Update Related Fields? Clicking Cascade Update Related Fields means that any change in the primary key field of the parent table is reflected in the related fields of other tables. If your database used phone numbers as a primary key field, Access would automatically change entries in related tables any time you updated a customer’s phone number.
What happens when I click Cascade Delete Related Fields? Clicking Cascade Delete Related Fields means that any time you delete a record in a primary table, Access will delete that record and every record containing the key value of that record in related tables. You should use this option with caution.
■ The Edit Relationship Builder disappears.
› Click Cascade Delete Related Records to automatically pass deletions from one table to the other. 199
6048-4 ch06.F
10/19/99
2:01 PM
6
Page 200
CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS
VIEW RELATIONSHIPS
ccess allows you to view a database’s relationships at any time through the Relationship Builder tool. You should take the time to view a database’s relationships from time to time to ensure you have made all the proper connections. It is equally important that you make certain
A
⁄ Click the Relationships button.
200
you have not included too many relationships. Including too many relationships between tables can cause noticeable slowness when users are entering data. Since Access checks any related tables to make sure referential integrity is maintained before enacting a change, unneeded relationships will
hinder your database’s performance. You can view the details of a particular relationship by doubleclicking the line drawn between the related tables. The Edit Relationship Builder will appear.
■ The Relationship Builder appears.
6
6048-4 ch06.F
10/19/99
2:02 PM
CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS
II CREATE TABLES, FORMS, AND REPORTS
6
Page 201
EDIT RELATIONSHIPS ou can examine any relationship in your database by doubleclicking on the line representing that relationship. Rather than just letting you take a look at the relationship, Access allows you to change it as
Y
⁄ Double-click the line indicating the relationship you want to view or edit.
well. The Edit Relationship window appears when you double-click the line representing the relationship you want to examine. You should look at your tables’ relationships often during the design process to ensure the
links contain every feature they should. For instance, you might check to ensure Access maintains referential integrity between the critical tables in your database.
■ The Edit Relationship Builder appears.
201
6048-4 ch06.F
10/19/99
2:02 PM
6
Page 202
CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS
DELETE RELATIONSHIPS
ccess allows you to delete a relationship at any time. By simply clicking the line representing the relationship and pressing the Delete key, you can get rid of any unwanted relationships. You should delete any relationship that is not essential for the smooth operation of your
A
⁄ Click the relationship you want to delete.
202
database. Although relationships can ensure additions, changes, and deletions are reflected in related tables throughout a database, unnecessary relationships can slow performance noticeably. If you accidentally delete a relationship you intended to keep, you may either decline to
¤ Press the Delete key. Note: If you are asked if you want to delete the relationship, click Yes.
save your changes when you exit the Relationship Builder or remake the relationship by following the steps in task “Create a Relationship,” presented earlier in this chapter.
■ The relationship disappears.
6
6048-4 ch06.F
10/19/99
2:02 PM
CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS
II CREATE TABLES, FORMS, AND REPORTS
6
Page 203
SAVE RELATIONSHIPS ou should save any work you do on your database frequently; relationships are no exception. One rule of thumb is to save your work every five minutes. If your computer loses power, or
Y
⁄ Click the Relationships button.
you accidentally close Access without saving your work one last time, you will have only lost a few minutes of work. Your relationships are saved as part of your main database, so it is also a good idea to make
backup copies of your database. Store the backups away from your computer to help make sure that what caused you to lose your original does not cost you your backup as well.
■ The Relationship Builder appears.
¤ Click File.
Note: If you close the Relationship Builder without saving your work, Access will prompt you to do so.
‹ Click Save.
203
6048-4 ch06.F
10/19/99
2:02 PM
6
Page 204
CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS
HIDE A TABLE IN THE RELATIONSHIP BUILDER hen you view the relationships in a database, Access automatically shows all of the tables and their links. Since the number of tables and their connections can crowd the Relationship Builder window,
W
⁄ Right-click the title bar of the table you want to hide.
204
Access lets you selectively hide tables. Hiding tables is particularly handy if you are only concerned with a few fields in the database and want the freedom to move those tables around in the Relationship Builder without
¤ Click Hide Table.
other tables and the lines denoting their relationships getting in the way. If you accidentally hide a table you would like to work with, you can show that table in the Relationship Builder window easily.
■ The table and its relationships disappear.
Note: To make the table reappear, follow steps 1-4 in task Create a Relationship from earlier in this chapter.
6
6048-4 ch06.F
10/19/99
2:02 PM
CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS
II CREATE TABLES, FORMS, AND REPORTS
6
Page 205
CLEAR THE RELATIONSHIP BUILDER hen you view the relationships in a database, Access automatically shows all of the tables and their links. Since you might want to work with only a few tables and their connections, Access lets you clear the Relationship Builder window with the click of a button and
W
⁄ Click the Clear Layout button.
add in only the tables you want to view. Clearing the Relationship Builder window is particularly useful when you have a large number of tables and are not able to find an efficient way to rearrange them all in the window. Clearing the window gives you a
chance to start fresh and avoid a confusing tangle of lines. Clearing the Relationship Builder window does not delete any of the tables or relationships in your database. You can always show all of your database’s relationships in the Relationship Builder again.
■ All tables and their relationships disappear.
205
6048-4 ch06.F
10/19/99
6
2:02 PM
Page 206
CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS
SHOW DIRECT RELATIONSHIPS OF A TABLE
ccess allows you to show which tables are directly related to another table with the click of a button. By clicking the Show Direct Relationships button, you can add only those tables with direct links to the table with which you started.
A
⁄ Click the table.
206
Showing which tables are directly related to another table is a handy way of seeing what role a particular table plays in the database. It is also a good way of checking for unneeded relationships or, alternatively, whether the table should be related to additional tables.
¤ Click the Show Direct Relationships button.
As always, the Relationship Builder allows you to show all of the relationships in your database, show individual tables, or clear the Relationship Builder window.
■ Every related field appears.
6
6048-4 ch06.F
10/19/99
2:02 PM
CHAPTER 6: ESTABLISH KEYS AND RELATIONSHIPS
II CREATE TABLES, FORMS, AND REPORTS
6
Page 207
SHOW ALL RELATIONSHIPS
ccess allows you to show all of the relationships in your database by clicking the Show All Relationships button on the Relationship Builder toolbar. Showing all of the relationships in a database is a good way to get a quick overview
A
⁄ Click the Show All Relationships button.
of how the elements of your database work together. You can move the tables around to make the relationships more clear and to minimize the number of lines crossing in the window. Once you have shown all of the relationships in your database, you can selectively
hide tables to narrow your focus to the ones you are most interested in. (See the task “Hide a Table in the Relationship Builder,” earlier in this chapter.)
■ Every relationship in the database appears.
207
6048-4 ch07.F
10/19/99
7
2:05 PM
Page 208
CHAPTER 7 IMPORT, EXPORT, AND LINK TABLE DATA CREATE A DATABASE
2 CHAPTER 7: IMPORT, EXPORT, AND LINK TABLE DATA
IMPORT, EXPORT, AND LINK TABLE DATA f you already have working databases in other programs and are worried about switching your older information to Access, you can relax. With Access, you can directly import data created in other popular database and spreadsheet programs, such as dBASE, Paradox, and Lotus 1-2-3. You can also export data to those formats.
I
You can also link to tables created in other programs. Unlike importing, which creates a separate copy of the external table, linking lets you work on the external table as if it were an Access table. Every change you make is reflected in the linked table, but it retains its identity as a Paradox, dBASE, or other table.
Export Tables to Another Access Database–
Export Your Data to Another Program–
Information can often be used in more than one database. For example, a list of your personal and business contacts could be used in a marketing database as well as a database tracking your personal correspondence. Exporting tables from one database to another takes only a few mouse clicks and keystrokes. You just identify the table to export, tell Access which database you want the table to be exported to, and verify the table and its destination. If the target database contains a table with the same name as the one you’re exporting, you’ll be asked to change the exported table name.
Besides exporting from one Access database to another, you can also export tables to other database, spreadsheet, and word processing programs. Exporting Access tables to other programs is handy when you collaborate with users who don’t have Access on their systems. You can also export numerical data to spreadsheet packages, which are better suited to performing complex summaries and other operations. For instance, if you collected survey data in an Access database, you could export the data to Excel spreadsheets to analyze the results statistically. Export Your Data to a Text File–
Paradox Access
dBase FoxPro
208
If you want to export your data to another program but don’t know what formats it can handle, you can almost always export your data to a text file and import it into the target program. You can export your Access tables as text files with commas, semicolons, or any other character you choose separating one field from another. You do need to ensure the separator character (called a delimiter) you use doesn’t appear anywhere in the data itself. If it
6048-4 ch07.F
10/19/99
2:05 PM
Page 209
Import Tables–
Link a Table–
II CREATE TABLES, FORMS, AND REPORTS
does, the target program will misread where one field’s data ends and the next begins. Exporting data to a text file is also handy when you need to include Access data in a report. Once you’ve opened the text file you exported your data to, you can cut and paste the data or, in the case of Microsoft Word, transform the data into a table within the word processor itself.
Exporting and importing data to and from other programs is handy, but the original table and its copy aren’t connected. That is, updates to one version of the table don’t automatically appear in the other. You can ensure that changes in one table appear in the other by linking the tables. You should link tables whenever you want them to be exactly the same but don’t want to store the data in a single table in one database. The most obvious case is if you maintain a list of contacts in both an Access database and in another program, such as Paradox. If it would be impractical to convert the Paradox database to Access and combine the data from both files into a single Access database, you could link the contact tables in the two databases to ensure they remain consistent.
Access
dBase
Just as you can export your table data to other programs, you can import files created in other programs into Access databases. Importing data from other programs makes it easy for you to collaborate with users who have data you need but don’t have it saved as Access tables. For instance, if you switched from another database program to Access, you could import data from the other program and work with it in Access without needing to save the table as a text file or otherwise manipulate the data. You can also import data from spreadsheets and properly formatted text files. .txt
Access
209
6048-4 ch07.F
10/19/99
2:05 PM
7
Page 210
CHAPTER 7 IMPORT, EXPORT, AND LINK TABLE DATA
EXPORT TABLES TO ANOTHER ACCESS DATABASE
opular tables, such as those containing information about people, can often be used in more than one database. Access lets you export tables from one database to another quickly and easily. With a few
P
⁄ Click the table you want to export. ¤ Click File.
210
simple commands, you can export a table in a few seconds rather than spend the minutes or hours it would take to re-create the table and any validation rules or input masks associated with it.
‹ Click Export.
Access will warn you if there is a table in the target database with the same name as the table you want to export, so you can rename the table for the target.
■ The Export To window appears.
› Click the destination database.
6048-4 ch07.F
10/19/99
2:05 PM
Page 211
II CREATE TABLES, FORMS, AND REPORTS
Can I update information in an imported table when I update the original table? An imported table is just that; it’s essentially been copied and pasted into the new database. The imported table will not be updated when you change the original table.
How do I make sure I don’t accidentally export another table with the same name? Access will warn you if you are about to add a table with the same name as an existing table. If you want to replace the existing table with the one you exported, click Yes. If not, click No.
However, you can automatically update tables in multiple databases if you link the tables instead of import them. When tables are linked, changes to one table affect the linked table as well. To learn about linking, see the task “Link a Table,” later in this chapter.
■ The name of the destination database appears in this space.
ˇ Click Save.
■ The Export dialog box appears.
Á Click OK.
211
6048-4 ch07.F
10/19/99
2:05 PM
7
Page 212
CHAPTER 7 IMPORT, EXPORT, AND LINK TABLE DATA
EXPORT TABLES TO ANOTHER DATABASE
ccess lets you take the tables you have created and export them to another database. You can export your tables to a wide variety of other programs and formats. You might want to export your Access table to another database format when you are
A
⁄ Click the table you want to export. ¤ Click File.
212
collaborating with users who are working with other database packages. You can export your tables directly to Excel, Lotus 1-2-3, Paradox, dBASE, and other database and spreadsheet formats. You can also export your data to a text file, a format
‹ Click Export.
that is almost universally readable. You can export your data to another file on your system, to another computer on your network, or to a file that you can e-mail to another user elsewhere on the Internet.
■ The Export As window appears.
› Click the “Save as type” drop-down menu button. ˇ Click the format you want.
6048-4 ch07.F
10/19/99
2:05 PM
Page 213
II
■ Type the name of the destination table in this space.
ˇ Click Save.
CREATE TABLES, FORMS, AND REPORTS
How do I choose the location to save my exported table? You can choose the folder to save your exported table in by clicking the dropdown menu button in the “Save in” text box and selecting the proper directory.
How do I stop the operation without exporting my file? You can abort the export by clicking the Cancel button in the Export To window.
■ The Export As window disappears.
213
6048-4 ch07.F
10/19/99
2:05 PM
7
Page 214
CHAPTER 7 IMPORT, EXPORT, AND LINK TABLE DATA
IMPORT A TABLE
ccess is a popular and easy-to-use program, but it’s not the only database program on the market. You may have used another program to create data or need to collaborate with someone who uses another database package. Access allows you to import data from many of the popular
A
⁄ Click File. ¤ Click Get External Data.
database programs, like Paradox and dBASE. If you need to work with data from a spreadsheet, such as Excel or Lotus 1-2-3, you can import data from those programs as well. As always, if the database or spreadsheet program you want to import data from doesn’t translate directly into Access,
‹ Click Import.
you can use an intermediate format (such as a text file or a mutually readable database format) to get the table into Access. Just export the database data to a text file, then import the text file into Access.
■ The Import window appears.
› Click the “Files of type” drop-down menu. ˇ Click the data type of the table you want to import.
214
6048-4 ch07.F
10/19/99
2:05 PM
Page 215
II
■ The tables of the format you chose appear.
‡ Click Import.
CREATE TABLES, FORMS, AND REPORTS
How can I display a list of the available files? You can display a list of the files available for import by clicking the drop-down menu button in the “File name” text area.
How do I stop the operation without importing a file? You can abort the import by clicking the Cancel button in the Import window.
■ The confirmation message appears.
° Click OK.
Á Click the table you want to import.
215
6048-4 ch07.F
10/19/99
2:05 PM
7
Page 216
CHAPTER 7 IMPORT, EXPORT, AND LINK TABLE DATA
EXPORT DATA TO A TEXT FILE
erhaps the most useful and versatile format to work with data between databases is the text file. A text file, which uses punctuation marks like commas and semicolons to mark the beginning and end of fields, can be read by just about any database or spreadsheet program.
P
⁄ Click the table you want to export. ¤ Click File.
Working with text files can also be beneficial when you need to work with your data in a text mode. If you find it easier to edit, search for, and replace text in a word processor, exporting a database table to a text file can make it much easier for you to check your data. You can also use a word processor’s spell checker
‹ Click Export.
program on the data to ensure it is correct. You can export your data to another file on your system, to another computer on your network, or to a file that you can e-mail to another user elsewhere on the Internet.
■ The Export As window appears. › Click the “Save as type” drop-down menu button. ˇ Click Text Files.
216
Á Click Save.
6048-4 ch07.F
10/19/99
2:05 PM
Page 217
II CREATE TABLES, FORMS, AND REPORTS
When should I use a delimiter other than a comma? You should use another delimiter when you know the database you are exporting your table to uses commas for something other than separating fields or expects another character to separate fields.
Some packages must be set to a specified number of characters as the field width. Any characters beyond the indicated field width are not imported.
What are fixed-width fields? Not every database package has Access’ ability to limit the amount of disk space used to the exact amount taken up by a field’s contents. If a database reads the first 20 characters in a line of a text file as the contents of the first field, you will need to use fixed-width fields to ensure the data can be read properly.
■ The Export Text Wizard appears.
‡ Click Next.
■ The next Export Text Wizard screen appears.
° Click Advanced.
CONTINUED
217
6048-4 ch07.F
10/19/99
2:05 PM
7
Page 218
CHAPTER 7 IMPORT, EXPORT, AND LINK TABLE DATA
EXPORT DATA TO A TEXT FILE
ccess gives you a great deal of flexibility in choosing the format of the resulting file when you export your data to a text file. You can pick the character set the information will be written in, the language of the text, and how dates will be written. It’s important that Access give you quite a bit of leeway in exporting your data to a text file,
A
■ The Export Specification window appears. Note: You can use the options in this window to select the language, date and time delimiters, and character set for your exported file.
218
as you may need to format the data in a very specific manner so that it can be read by another database or spreadsheet program. For instance, if the receiving program expects all text strings containing a space be enclosed by single quotes, you can let Access know that, rather than using the default character, it should contain all text strings in “ ‘ “ characters.
· Click OK.
CONTINUED
You can also choose the format that dates will be written into the text file. Some programs have specific expectations about how the data will be written, so Access allows you to choose the manner dates will be transcribed in the new file.
■ The Export Specification window disappears.
‚ Click Next.
6048-4 ch07.F
10/19/99
2:05 PM
Page 219
II
■ The Checkered Flag screen appears.
± Click Finish.
CREATE TABLES, FORMS, AND REPORTS
How do I see a list of the export specifications I’ve saved from previous exports? You can view a list of your saved export specifications by clicking the Specs button in the Advanced screen of the Export to a Text File Wizard.
Can I save my export specifications? You can save your export specifications by clicking the Save As button in the Advanced screen of the Export Text Wizard.
■ The confirmation dialog box appears.
Á Click OK.
— Enter the name of the destination file in this space.
219
6048-4 ch07.F
10/19/99
2:05 PM
7
Page 220
CHAPTER 7 IMPORT, EXPORT, AND LINK TABLE DATA
LINK A TABLE
s with most Windows programs, you can cut and paste information from Access into documents created by other software packages. It’s easiest to cut (or copy) information from one Access datasheet and paste it in another, but you can also paste the information into Microsoft Word (where it appears as a table) or
A
⁄ Click the table you want to link to another table. ¤ Click File.
220
into a Microsoft Excel spreadsheet. Cutting and pasting is quick and easy, but it doesn’t create a relationship between the source and target of the operation. To create such a relationship, you need to link the tables. Linking an Access table and a table created in (or exported to) another database means that any
‹ Click Get External Data. › Click Link Tables.
changes in the original table will be reflected in the linked table. Importing data, like cutting and pasting, merely copies the data. You can link tables from different Access databases, or you can link an Access database to another program, such as Paradox.
■ The Link window appears.
ˇ Click the “Files of type” drop-down menu button. Á Click the file type of the file you want to link.
6048-4 ch07.F
10/19/99
2:05 PM
Page 221
II
■ The files of the type you selected appear. ‡ Click the file you want to
° Click Link. Note: A confirmation dialog box appears. Click OK.
CREATE TABLES, FORMS, AND REPORTS
Where can I look for translation software for working with database programs that aren’t listed? You can search Microsoft’s Web site at http://www.microsoft.com for additional translators, though the simplest method may be to export the table from the unsupported program to a text file.
Is the original table erased when I delete the link? When you delete a link to a table, you don’t affect the original table — only the link is removed.
· Click Close.
Note: The linked table appears in your table list.
link.
221
6048-4 ch07.F
10/19/99
2:05 PM
7
Page 222
CHAPTER 7 IMPORT, EXPORT, AND LINK TABLE DATA
COPY CELLS TO A MICROSOFT WORD TABLE
s easy as it is to export entire tables to other programs, there will be times when you just want to copy the contents from a few cells in your table for use in another program. Since most every program written for Windows will use the standard cut-and-paste procedures, you should be able to grab the cells
A
⁄ Select the cells to copy to another program.
222
you want to use in a text document and paste them over directly. While you should be able to paste the contents of your Access cells into most any word processing program, the task is particularly easy when you work with Microsoft Word. When you paste your copied cells into a Word document, Word translates
¤ Click Edit. ‹ Click Copy.
› Click Start.
them as a table, complete with predefined columns, headers, and cells. These instructions are known to work in Microsoft Word, but it is very possible they will also work for other word processing programs. Try it and see!
ˇ Click Microsoft Word.
6048-4 ch07.F
10/19/99
2:06 PM
Page 223
II
■ A blank Microsoft Word document appears.
Á Click Edit. ‡ Click Paste Cells.
CREATE TABLES, FORMS, AND REPORTS
I’ve tried pasting my cells directly into my word processor, but it doesn’t work. How should I transfer the data over? The best way to transfer cell contents to a generic word processor is to export the data to a text file and import that file into the word processor document.
How do I select an entire record to paste in a word processing document? You can select an entire record by clicking the row selector at the beginning of the record. When you click the selector, the entire row will appear in reverse video.
■ The cells appear as a table.
223
6048-4 ch07.F
10/19/99
2:06 PM
7
Page 224
CHAPTER 7 IMPORT, EXPORT, AND LINK TABLE DATA
COPY CELLS TO A MICROSOFT EXCEL SPREADSHEET ne of the strengths of most Microsoft Windows programs is the consistent support for cut-andpaste procedures. For example, you can copy text from Microsoft Word files and paste it into a Notepad, Write, or other word processor document without difficulty. You can do the same with data from Access datasheets.
O
⁄ Select the cells you want to copy.
224
Suppose you wanted to copy data from a number of Access cells to an Excel spreadsheet. You can use the mouse to copy the cell data you want to move to Excel, use the menus or keyboard shortcuts to copy the data to the Clipboard, and use the menus or keyboard to paste the values into a spreadsheet. Since Access datasheets and Excel spreadsheets both divide
¤ Click Edit. ‹ Click Copy.
› Click Start.
their contents into cells, the translation is straightforward. These instructions should also work for any other spreadsheet program you want to copy data to. If not, you can always export the data to a text file and use the spreadsheet’s Import feature to read the data into the program.
ˇ Click Microsoft Excel.
6048-4 ch07.F
10/19/99
2:06 PM
Page 225
II
■ A blank Excel spreadsheet appears.
Á Click Edit. ‡ Click Paste.
CREATE TABLES, FORMS, AND REPORTS
I’ve tried pasting my cells directly into my spreadsheet, but it doesn’t work. How should I transfer the data over? The best way to transfer cell contents to a generic spreadsheet is to export the data from Access to a text file and import that file into the spreadsheet using that program’s import or translation capabilities.
How do I select an entire record to paste in a spreadsheet? You can select an entire record by clicking the row selector at the beginning of the record. When you click the selector, the entire row will appear in reverse video.
■ The cells appear in the spreadsheet.
225
6048-4 ch08.F
10/19/99
8
2:10 PM
Page 226
CHAPTER 8: PRINT
PRINT
ne of the most basic capabilities of a computer program is to print its output. If you want, Access will let you control every aspect of the printing process, allowing you to ensure the job is done exactly as you want. Access allows you to preview what your document will look like when it is printed. You can examine your document from one to as many as six pages at a
O
time. Single-page views make it easy to ensure all the relevant information will be printed, while multipage views allow you to check for columns or rows running over the desired number of pages. You can adjust your documents by changing the margins, font and size of the text the data will be printed in, and the orientation of the data on the page.
Print Preview–
Zoom in Print Preview–
You can see how your printed pages will look by clicking the Print Preview button on the Access toolbar or by choosing Print Preview from the File menu. You might want to preview your pages to make sure your information fits neatly on the page, rather than spilling one or two columns onto another page. Preview also helps you to ensure that your columns are wide enough so that text doesn’t wrap awkwardly or get hidden beyond a cell’s border.
?
226
You can also zoom in on your document to get a more precise picture of how it will look when you print it. Zoom in on your document by using the Zoom drop-down menu on the toolbar or by opening the View menu and choosing a zoom level. You can select from a variety of zoom levels, allowing you to preview your information in as much or as little detail as you like.
walk an running to sidewalk
6048-4 ch08.F
10/19/99
2:11 PM
Page 227
Preview Multiple Pages–
II CREATE TABLES, FORMS, AND REPORTS
Different printers have different margins, resolutions, and print quality settings. When you work on systems with more than one printer, or with one laser printer and the ability to “print” documents as faxes, it’s useful to be able to see how your print job will look when printed on the various machines at your disposal. You can preview up to six pages at the same time. You should consider previewing more than one page on the same screen if the page contents aren’t as important as how the information fits on the pages. If you needed to fit information on exactly four pages, for instance, you could change the font and margins of your object in Design view and open the object in Print Preview to ensure your changes fit the information in the required space without any awkward breaks.
Change Margins in Page Setup– One of the easiest ways to change how your information appears on the page is to change a document’s margins. Changing the margins by as little as a tenth or quarter of an inch can cause a field or record’s contents to appear on one line instead of two. Conversely, if your data is hard to read because it appears as a single sentence that sprawls across the page, you can change your document’s margins so your data appears as a compact two- or threeline paragraph.
Change Page Orientation– Some database objects, tables in particular, fit better on a page when the page is turned so that it is wider than it is high. When a page is oriented so that it is taller than it is wide, it is said to be in “portrait” orientation. When the page is oriented so it is wider than it is tall, it is said to be in “landscape” orientation. You can change your document’s orientation to fit more columns on a page. Some occasions when it would be useful to fit most or all of a table’s columns on one page are with addresses, orders, and ingredients.
CONTINUED
227
6048-4 ch08.F
10/19/99
8 PRINT
2:11 PM
Page 228
CHAPTER 8: PRINT
CONTINUED
You may switch the orientation of your document as often as you wish. You may also exit Page Setup without applying any changes by clicking Cancel.
Pick a Printer– When you print an Access object, you need to pick the printer you want to use. If you’re not connected to a network, you are limited to any printers you connected to your system through the printer port. If you’ve installed a modem on your system and have software that allows you to send your documents as faxes, the fax program will be treated as a printer. If your computer is attached to a network, you can usually print your documents on any networked printer.
228
Print Information– As long as reading computer screen is harder on the eyes than reading ink on paper, you’ll need to print your database objects. Printing your information is also necessary if you want to prepare handouts for a meeting. Unless everyone attending has a laptop computer, you’ll need paper copies of your information to pass around. Printing a few pages from a form or report is a good way to give others a flavor for the type of data and structure in your databases. If you needed to show your supervisor how you proposed to maintain sales or contact data in your tables, you could create a database, populate one or two tables and reports with sample data, and print the sample documents. You could use the same approach to demonstrate any changes you’d like to make to existing documents. Although changing the physical structure of a long-established database can be done easily, it makes sense to put your proposed changes on paper so others can comment on your ideas.
6048-4 ch08.F
10/19/99
2:11 PM
Page 229
Print Mailing Labels–
II CREATE TABLES, FORMS, AND REPORTS
One of the most common uses for a database is to maintain contact information. If you use that contact information to generate mailings, you’ll find that generating your mail is much easier when you print the address labels directly from your table. Access has a wizard that automates the mailing label generation process. The Mailing Label Wizard allows you to pick the fields containing the values you want to include on your labels. For instance, if your contact information table included home and work phone numbers, you could exclude those fields from the labels. The wizard also allows you to add text to each label, add
punctuation and spacing to make the labels easier to read, and to pick the type of label you’ll use.
229
6048-4 ch08.F
10/19/99
2:11 PM
8
Page 230
CHAPTER 8: PRINT
PREVIEW BEFORE PRINTING f you’ve printed out a lot of documents, you’ve probably had one or two (or three or a hundred) that didn’t show up on paper the way they looked on the screen. You can avoid that problem by using Access’ Print Preview function. Print Preview displays your document on the
I
OPEN PRINT PREVIEW
⁄ Click the Print Preview button.
230
screen exactly as it will be printed. If you change which printer will handle the document, Access will update the Print Preview screen to reflect your changes. In addition to zooming in on your information, you can preview more than one page at
once. If your table is two pages wide, you can preview your document two pages at a time to ensure it prints properly. (You’ll learn how to use these functions in the next tasks.)
■ The Print Preview window appears.
6048-4 ch08.F
10/19/99
2:11 PM
Page 231
II
CLOSE PRINT PREVIEW
⁄ Click the Close button.
Note: The Close button in the Print Preview window does not close the document completely — it only returns you to the view you had open before you opened Print Preview.
CREATE TABLES, FORMS, AND REPORTS
Do I need to close Print Preview before I can print? No, you can print directly from the Preview window. Just choose Print from the Fill menu or click the Print button on the toolbar.
Can I open Print Preview from the menus? You can open Print Preview from the File menu. Click File and select Print Preview from the menu that appears.
■ The Print Preview window disappears.
231
6048-4 ch08.F
10/19/99
2:11 PM
8
Page 232
CHAPTER 8: PRINT
ZOOM IN PRINT PREVIEW ne handy Print Preview feature lets you zoom in on your page, so you can make sure everything you want is included in the printout. One example would be to make sure the entire contents of a cell will be printed.
O
⁄ Click the Zoom dropdown menu button.
232
You can select from a variety of zoom levels, allowing you to preview your information in as much or as little detail as you like. Viewing your document at zoom levels above 100 percent (the normal view) shows quite a bit more detail. Viewing your
document at smaller percentages, such as 50 percent, shows you how different elements of your document are related on the page, but not what the individual elements look like in detail.
■ The Zoom drop-down menu appears.
¤ Click your desired zoom level.
6048-4 ch08.F
10/19/99
2:11 PM
Page 233
II
■ Your document appears at the chosen zoom level.
‹ Click Close.
CREATE TABLES, FORMS, AND REPORTS
When would I want to use 10 percent zoom? You might use 10 percent zoom when you want to check a multipage document to make sure there are no problems, such as one column being printed on a page by itself.
What does “Fit” zoom level mean? The Fit zoom level means that Access should expand the page until it fills the Access window vertically.
■ The Print Preview window disappears.
Note: 100 percent zoom displays the document's contents at the approximate size they will appear on the printed page.
233
6048-4 ch08.F
10/19/99
8
2:11 PM
Page 234
CHAPTER 8: PRINT
PREVIEW MORE THAN ONE PAGE sing Print Preview to get a look at your document before you commit it to paper is a great way to ensure the hard copy will appear just the way you want it. If your form or report won’t fit on a single page, however, the standard Print Preview window doesn’t show you how adjacent pages fit together.
U
⁄ Click the Two Pages button on the toolbar.
234
But there is a way to view more than one page at a time. With the Two Pages button, you can view your document two pages at a time to see how it will appear when printed. Access also allows you to preview up to six pages at a time. With the Multiple Pages button, you can select the number of
pages you want to preview at once. Combining multipage previews and zooming (presented earlier in this chapter) gives you a range of tools to ensure your document will print properly.
■ The object appears two pages at a time.
¤ Click the Multiple Pages button on the toolbar.
6048-4 ch08.F
10/19/99
2:11 PM
Page 235
II
■ The Multiple Pages selection area appears. Note: Move the cursor to select the number of pages to be displayed.
‹ Click the icon that represents the range of pages you want to display.
CREATE TABLES, FORMS, AND REPORTS
I’ve clicked the Multiple Pages button but don’t want to change my preview. How do I cancel the change? You can stop Access from changing your preview by clicking the Cancel button or by clicking the Multiple Pages button again.
Is there a quick way to switch back to my previous zoom level while previewing multiple pages? You can switch back to your previous zoom level by clicking the Magnifying Glass button on the toolbar.
■ Your database objects reappear based on your selected range.
■ The selected range appears here. 235
6048-4 ch08.F
10/19/99
8
2:11 PM
Page 236
CHAPTER 8: PRINT
CHANGE PAGE SETUP: CHANGE A MARGIN ccess uses a standard margin of one inch on each edge, meaning that it leaves a one-inch border around your page blank before it starts printing. A one-inch border is usually sufficient, but you can make the border larger or smaller if you like. How small you can make your margins (that is, how close to the
A
⁄ Click File.
edge of your paper you can print) depends on your printer. You can change the margins of your document from within the Page Setup screen. Simply enter the amount of space you want for any of your document’s four margins (top, bottom, left, and right) and Access changes your document’s layout automatically.
¤ Click Page Setup.
In the Page Setup box, Access illustrates how your information fits on the page with the margins you chose. You can exit Page Setup at any time without saving your changes by clicking the Cancel button. Clicking the OK button tells Access to accept your new margins and continue.
■ The Page Setup window appears.
‹ Double-click in the box next to the margin you want to change. › Type the value for your new margin.
236
6048-4 ch08.F
10/19/99
2:11 PM
Page 237
II
■ A sample of your pages appears in this area.
ˇ Click OK.
CREATE TABLES, FORMS, AND REPORTS
I don’t want Access to print the document’s headings (name, page number, and date) on each page. How do I turn that feature off? Click the check box next to Print Headings to deselect it.
Can I use fractional margins, such as 1.5" or .75"? You can use any margin value you like. Bear in mind that your available margins will vary based on your printer’s capabilities.
■ The Page Setup window disappears.
237
6048-4 ch08.F
10/19/99
2:11 PM
8
Page 238
CHAPTER 8: PRINT
CHANGE PAGE SETUP: CHANGE PAGE ORIENTATION
ome database objects, tables in particular, fit better on a page when the page is turned so that it is wider than it is tall (also known as landscape orientation), as opposed to taller than it is wide (or portrait orientation). You can
S
⁄ Click File.
238
use the Page Setup command to change the orientation of your document and fit more columns on a page. Some occasions when it would be useful to fit most or all of a table’s columns on one page are with addresses, orders, and ingredients.
¤ Click Page Setup.
You may switch the orientation of a document as often as you wish. And remember, you can always exit Page Setup without applying any changes by clicking Cancel.
■ The Page Setup window appears.
‹ Click the Page tab.
6048-4 ch08.F
10/19/99
2:11 PM
Page 239
II
■ The Page window appears.
› Click the radio button next to Landscape.
CREATE TABLES, FORMS, AND REPORTS
How do I let Access know I want to print on paper that is not standard letter sized? You can let Access know you are using other than letter-sized paper by clicking the drop-down menu button next to Size. You may choose one of the paper types provided or define your own.
I have special paper that won’t go through the feeder on my printer. How do I get Access to let me feed the paper in manually? To have Access instruct your printer to expect paper entered manually rather than through the feeder, click the drop-down menu next to Source and click Manual.
■ The radio button next to Portrait changes from clicked to unclicked.
■ The radio button next to Landscape changes from unclicked to clicked. ˇ Click OK.
239
6048-4 ch08.F
10/19/99
8
2:11 PM
Page 240
CHAPTER 8: PRINT
PICK A PRINTER
ccess allows you to pick which printer you want to print your information. Your default printer, the printer defined in Windows as the main printer for your system, appears automatically. You can choose another printer from the dropdown menu that is accessible from the Page tab in the Page Setup window.
A
⁄ Click File.
240
You’re not limited to printing on printers directly connected to your computer. If your machine is connected to a network, you can print on any printer that is also connected to the network. You can use remote printers as a means to reduce communication costs by printing instead of faxing documents, but you should make sure there will be
¤ Click Page Setup.
someone near the printer to watch for jams and other interruptions. You can also use the Printer drop-down menu to send faxes using Microsoft Fax. Simply choose Microsoft Fax from the list of printers and follow the instructions to fax your document.
■ The Page Setup window appears.
‹ Click the Page tab.
6048-4 ch08.F
10/19/99
2:11 PM
Page 241
II
■ The Page tab options appear. › Click Use Specific Printer.
ˇ Click Printer.
CREATE TABLES, FORMS, AND REPORTS
How do I modify the settings for my chosen printer? You can modify the settings for your chosen printer by clicking the Properties button next to the printer list box. The Properties available depend on which printer you have selected.
How can I exit Page Setup without keeping any of the changes I’ve made? You can exit Page Setup without keeping any of your changes by clicking the Cancel button.
■ The Printer window appears.
Á Click the drop-down menu button next to the Name text box.
CONTINUED
241
6048-4 ch08.F
10/19/99
2:11 PM
8
Page 242
CHAPTER 8: PRINT
PICK A PRINTER CONTINUED
rinting a file on a particular printer requires the proper software so your computer can communicate with that printer. The software, called a driver, is often included with your Windows software. Printer manufacturers will also usually include the drivers for their printers on a disk in the printer packaging.
P
■ The list of available printers appears. ‡ Click the printer you want to use.
242
You can also usually download the latest drivers for printers over the Internet. Visit the manufacturer’s Web site and look for the drivers. Many corporate Web sites have an easy-to-locate download area or a search capability built in. You should always print a test page on any printer right after it is installed. Printing a test page
° Click Properties.
ensures you have configured your computer and the printer correctly. If the test page doesn’t look as it should, you might not have the correct driver, or you might need to adjust settings in the Properties dialog box.
■ The Properties window appears. Note: The Properties window will vary depending on the printer you choose.
· Make sure the options are set correctly for your document and printer, and then click OK.
6048-4 ch08.F
10/19/99
2:11 PM
Page 243
II
■ The Properties window closes.
‚ Click OK.
CREATE TABLES, FORMS, AND REPORTS
How do I know if the options in the Properties dialog box are set correctly? Some of the options, such as paper size and page orientation, can vary for each document, and merely depend on your own preferences. Others depend on your printer’s capabilities. See your printer documentation or system administrator for details.
How can I get help while I am in the Page Setup window? You can get help in the Page Setup window by clicking the Help button on the title bar of the window.
■ The Printer window closes.
Note: The Page Setup window closes.
— Click OK.
243
6048-4 ch08.F
10/19/99
2:11 PM
8
Page 244
CHAPTER 8: PRINT
PRINT INFORMATION ou can print out as little or as much of a particular database object’s contents as you like. If you need to include the first few records of a table in a written report, you can print the first page of your table with no trouble. You should print a database document any time a hard copy of the information would be
Y
PRINT AN ENTIRE OBJECT
⁄ Click File.
244
useful. Printed documents are easier to read than their electronic counterparts, can be carried on trips without fear of losing an expensive laptop, and can be photocopied for colleagues to use. Printed copies of database objects are also one way to archive important information. Although electronic backups,
¤ Click Print.
such as on a disk or tape, allow the information to be restored to a computer much more quickly, having a paper copy of the information filed away is a wise last line of defense against losing the data permanently.
■ The Print window appears.
‹ Click OK.
6048-4 ch08.F
10/19/99
2:11 PM
Page 245
II CREATE TABLES, FORMS, AND REPORTS
How do I print multiple copies of my document? You can enter the number of copies you want to have printed in the Number of Copies box, located on the right side of the Print window.
Is there a quick way to print out the whole document I have open? You can print a document quickly by clicking the Print button on the Access toolbar.
How do I collate my copies when I print more than one copy of my document? You can tell Access to collate your copies by clicking the Collate check box at the right side of the Print window.
PRINT A RANGE OF PAGES
⁄ Click File.
¤ Click Print.
■ The Print window appears.
› Type the first page to print here.
‹ Click the radio button next to Pages.
ˇ Type the last page to print here. Á Click OK.
245
6048-4 ch08.F
10/19/99
2:11 PM
8
Page 246
CHAPTER 8: PRINT
PRINT SELECTED RECORDS sing the Print toolbar button is an all-ornothing affair — either you print every bit of your object or none at all. While those two options will often be the only ones you need, you will probably want to print a subset of records from a form, report, or query. You can select which records you want to print in one of two
U
⁄ Select the records you want to print.
246
ways. First, you can select the records by clicking the row selectors of the first record and dragging the pointer to the last record you want to print. You can also select a range of records by clicking the first record and Shift-clicking the last record. One drawback to printing selected records is that you can’t remove records from a group.
¤ Click File.
That is, if you’ve selected three records, you can’t remove the middle one. If the records you do want to print have some features in common, you could sort or filter your table (as you learned to do in Chapter 5) or create a query (as you’ll learn to do in Chapters 9 and 10) to group the records in your datasheet.
■ The File menu appears.
‹ Click Print.
6048-4 ch08.F
10/19/99
2:11 PM
Page 247
II
■ The Print window appears.
› Click the Selected Record(s) radio button.
CREATE TABLES, FORMS, AND REPORTS
I only want to print certain columns from my table. How do I do that? You can eliminate certain columns from the print by hiding those columns. To hide a column, follow the steps in task “Hide a Field” in Chapter 4.
How do I print out all the records that have a value in common, like a customer’s name? You can print out similar records by sorting or filtering your table and printing the results.
■ The Selected Record(s) radio button changes from unclicked to clicked.
ˇ Click OK.
247
6048-4 ch08.F
10/19/99
2:11 PM
8
Page 248
CHAPTER 8: PRINT
PRINT MAILING LABELS
s you know, you can use Access to maintain mailing lists of all kinds, whether for friends, customers, suppliers, or distributors. But you can also print these addresses on labels and make your mailings easier to handle. Rather than limit you to printing out all of the fields in the table you base your mailing
A
⁄ Click the table to use as the data source for your mailing labels.
labels on, Access allows you to choose which of the fields will appear on your label, and in what order. You can also add text, such as commas, spaces, and carriage returns, to make your labels more readable. Access also gives you the ability to choose which font, style, color, and size your label text will be printed in. If you
¤ Click the drop-down menu button next to the New Object button on the Access toolbar. ‹ Click Report.
248
have a color printer, you could use it to make your mailing labels more appealing. Access provides you with a preview of how your labels will look when printed, giving you all the information you need to make your labels as readable and eyecatching as you desire.
■ The New Report window appears. › Click Label Wizard.
ˇ Click OK.
6048-4 ch08.F
10/19/99
2:11 PM
Page 249
II
■ The Label Wizard appears. Á Click the appropriate label type from the list in this area.
‡ Click Next.
CREATE TABLES, FORMS, AND REPORTS
I can’t find my label in the list provided. How do I describe my label’s dimensions to Access? You can define your own labels by clicking Customize in the label choice screen and clicking the New button in the screen that appears.
I chose the wrong table to use in making my mailing labels. How do I start over? You can restart the Label Wizard without saving any of your changes by clicking the Cancel button from any of the wizard’s screens.
■ The font and color screen appears.
■ A preview of your label text appears in this area.
° Click on the drop-down menu buttons to display menus of the available fonts, sizes, styles, and colors for your label text.
· Click Next.
CONTINUED
249
6048-4 ch08.F
10/19/99
2:11 PM
8
Page 250
CHAPTER 8: PRINT
PRINT MAILING LABELS CONTINUED
fter you specify which fields will be included in your mailing labels, the font, style, size, and color the text will be printed in, and how the labels will be formatted, Access will let you know if your chosen information will fit on the labels you’ve selected. If it doesn’t, Access gives you the opportunity to revise your choices.
A
■ The label design screen appears.
250
In addition to selecting the fields to appear on your mailing labels, the Label Wizard also lets you choose the field order. Simply add the fields you want Access to sort by, in the proper order, and the program will do the rest. For instance, if you want the labels to be printed out by last name and want to use the contents of the first name field to
break ties, you would enter the fields in that order. If your table is already sorted in the order you want the labels to be printed, you do not need to duplicate that sort in the Label Wizard.
‚ Click the first field you want to add.
■ The field appears on the prototype label.
— Click the Add Field button to add the field.
Note: You can add as many fields as you like. You can also add spaces and other text to the labels directly from the keyboard. Press the Enter key to move to the next line on the label.
± Click Next.
6048-4 ch08.F
10/19/99
2:11 PM
Page 251
II
■ The sort criteria screen appears. ¡ Click the first field to sort by.
™ Click the Add Field button.
CREATE TABLES, FORMS, AND REPORTS
How do I remove fields from the Sort By window? You can remove fields from the Sort By window by clicking the field you want to remove and clicking the Remove Field button.
Can I sort my labels on fields that will not be printed on the labels? You can sort your labels on any field in the table on which your labels are based.
■ The field appears in the Sort by pane. Note: You may sort by as many fields as you like. Access will sort your labels based on the first field, using the second and subsequent fields to break ties.
Note: If your table is already sorted in your preferred order, you do not need to enter that criteria here as well.
£ Click Next. CONTINUED
251
6048-4 ch08.F
10/19/99
2:11 PM
Page 252
8
CHAPTER 8: PRINT
PRINT MAILING LABELS CONTINUED t’s a good idea to preview your labels as they will appear when printed, so you can ensure all the information you need is included (especially postal codes) and easy to read. It’s easy to miss spaces between
I
■ The Checkered Flag screen appears. ¢ Type the name for your mailing label list here.
252
field names or even entire fields; previewing your labels will help you catch those errors with no wasted labels. When the wizard is finished, Access stores your mailing labels as a report based on the contents
∞ Click Finish. Note: It is a good idea to leave the radio button next to "See the labels as they will look printed" clicked.
of your table. You can learn more about reports and how they work in Chapter 12.
■ Your mailing label document opens.
§ Click File.
6048-4 ch08.F
10/19/99
2:11 PM
Page 253
II CREATE TABLES, FORMS, AND REPORTS
I want to revisit some of the choices I made in the wizard. How do I do that? You can step back through your choices in the Label Wizard by clicking the Back button. You can click Next to move to the end of the wizard or click Finish to create your labels automatically.
My labels don’t look the way I want them to. How do I modify the label design? You can modify your labels’ appearance by clicking the radio button next to “Modify the label design.”
253
6048-4 ch08.F
10/19/99
8
2:11 PM
Page 254
CHAPTER 8: PRINT
PRINT THE RELATIONSHIPS WINDOW
ne of the best new features of Access 2000 is the ability to print the contents of the Relationships window. In previous versions of the program, you had to copy the contents of the window, paste them into another program as a bitmap image, and print the new file.
O
⁄ Click Tools.
254
You can still copy the contents of the Relationship window to another program if you want. If you’re looking for a graphics package that can save the image you captured in a number of usable formats, you could paste the image into a blank Paint document. Paint is included in
¤ Click Relationships.
the standard Windows 95/98 distribution. Windows handles cut and paste operations consistently across programs, so it is very unlikely you would need to take any steps not mentioned here.
■ The Relationships window appears.
‹ Click File. › Click Print Relationships.
6048-4 ch08.F
10/19/99
2:11 PM
Page 255
II
■ The relationships in your database appear in a report. ˇ Click File.
Á Click Print.
CREATE TABLES, FORMS, AND REPORTS
How do I copy the contents of the Relationship window into another document? You can copy the contents of the Relationship window to the Clipboard by pressing Alt+PrintScreen. Paste the contents of the Clipboard into the destination program by pressing Ctrl+V.
Can I change the heading or add summary text to the Relationships report before I print it? You can customize the Relationships report just as you would any other report. See Chapter 13 for details.
■ The Print dialog box appears.
‡ Click OK. Note: When you try to close the report generated in this task, Access will ask you if you want to save it. To do so, click Yes and follow the instructions that appear.
255
6048-4 ch09.F
10/19/99
2:13 PM
9
Page 256
CHAPTER 9: CREATE QUERIES CREATE TABLES, FORMS,AND REPORTS
2 CHAPTER 9: CREATE QUERIES
CREATE QUERIES hen you use a simple query, you ask Access to find records that match a set of specified criteria. For instance, you might create a query that finds all the friends you owe a letter to. You can use fields from as many of your tables as you like in your query, so your queries can be as complex as you want to make them. And you can save queries, so you can run them again and again. Once you have established the basic parameters for your query, you can choose which fields will be
W
shown in the results, rearrange the order your fields will appear, and determine how the results will be sorted. The Simple Query Wizard makes it easy to create useful queries quickly. Besides simple queries, which pull desired records from your tables, there are also advanced queries, which perform calculations on the selected records. You’ll learn about advanced queries in Chapter 10.
Use the Simple Query Wizard–
Select Tables for Your Query–
Access allows you to create queries quickly and easily by using the Simple Query Wizard. The Simple Query Wizard steps you through the creation process, allowing you to make choices about your query in a logical series of steps. Using the Simple Query Wizard, you can add fields from multiple tables to your query. Adding fields from different tables lets you bring all the information relevant to your query into one easily viewed package. When you are done specifying the fields you want to include in your query, Access gives you the opportunity to open your query to view the information or to modify your query’s design.
? 256
You can also create your own queries from the ground up. You can decide which tables will be available for use in the query, which fields will be included in the results, and how the results will be presented. If there’s any possibility that you might use a field from a table, you should add that table to your query. Adding a table does not slow your query or take up significantly more memory, it only means that table’s fields can be used in your query. You can always remove unneeded tables from your queries after you have created the queries.
?
6048-4 ch09.F
10/19/99
2:13 PM
Page 257
Add Fields–
Sort Within a Query–
?
II CREATE TABLES, FORMS, AND REPORTS
Access allows you to add as many fields as you like to your query. Adding fields forms the basis of your query; once a field is added, you use it to select records in a table, determine a sort order, and project the results. When you run your query, Access uses any selection criteria you provide to determine which records to display. Rather than displaying the entire record, Access shows only those fields you have selected. It is possible to include a field in the query but not show it in the result.
Sorting a query’s results can give you an even clearer picture of your data. One use might be in a veterinarian’s database of pets and customers. Querying your table for records showing which pets are more than one month past due for an exam would let you know which owners should be contacted. Sorting the records in ascending order by due date would tell you which pets are the longest overdue. You can sort your query results based on the contents of more than one field. Access uses the field farthest to the left as the primary field for its sort.
?
A
Z
Able Boyd Cramer Douglas
Establish Criteria– Once you have added a field you want to include in your query, Access allows you to set criteria for selecting records based on the contents of that field. Your criteria can be as simple or as complex as you like. For instance, you might want to see which of your customers ordered the most expensive items you carry, which of your suppliers took the longest to ship products after you ordered them, and if any of your customers have gone more than a month without placing an order. In addition to looking for specific values, you can also use wildcards and mathematical expressions in your criteria. >12 Before noon
Design and Datasheet View– Access gives you two views to work with your queries: Design view and Datasheet view. Design view is, as the name implies, the better view for designing your query. You can use the tools in Design view to add fields to your queries from any table in your database, assign criteria for which records should be found, sort the results, and decide which fields should appear in the results. Datasheet view, on the other hand, displays the results of your query in a dynaset, or “dynamically generated set” of information. Access displays the dynaset in table form, allowing you to filter, sort, and manipulate the dynaset as you learned to do in Chapter 5.
Between 16 and 47
257
6048-4 ch09.F
10/19/99
2:13 PM
9
Page 258
CHAPTER 9: CREATE QUERIES
USE THE SIMPLE QUERY WIZARD
ccess wizards make creating database elements, including queries, a snap. The Simple Query Wizard is no exception. The Simple Query Wizard allows you to combine fields from any number of tables into a single query. Combining fields
A
⁄ Click the table on which your query will be based.
from more than one table allows you to bring together related information that happens to be stored in different areas. You’ll take advantage of this technique many times when you work with Access. Once you’ve created your query, the wizard lets you run
¤ Click the drop-down menu next to the New Object button. ‹ Click Query.
258
your query or open it in Design view. Opening a wizard-created query in Design view is a good way to learn about writing queries from scratch. For information on working with queries in Design view, see many of the tasks in this chapter.
■ The New Query window appears. › Click Simple Query Wizard.
ˇ Click OK.
6048-4 ch09.F
10/19/99
2:13 PM
Page 259
II
■ The Simple Query Wizard appears. Á Click the first field you want to include in your query.
‡ Click the Add Field button.
CREATE TABLES, FORMS, AND REPORTS
I picked the wrong table when I started the Simple Query Wizard. How do I change it from inside the wizard? You can pick fields from any table in the Simple Query Wizard. Simply click the Tables/Queries drop-down menu button in the first screen of the wizard.
How do I add all of the fields in a table to my query? You can add all of the fields in a table to your query by clicking the “Add all fields” button.
■ The field appears in the Selected Fields pane.
Note: You may add as many fields to your query as you like.
° Click Next.
CONTINUED
259
6048-4 ch09.F
10/19/99
2:13 PM
9
Page 260
CHAPTER 9: CREATE QUERIES
USE THE SIMPLE QUERY WIZARD CONTINUED ecause Windows 95 allows you to give your files and folders names up to 255 characters long, you can give your new query a descriptive name. Rather than puzzle over a name eight characters in length, you can let your users know precisely what your query does.
B
■ The Checkered Flag screen appears.
260
When you are done specifying the fields you want to include in your query, Access gives you the opportunity to open your query to view the information or to modify your query’s design. If you choose to view the information in your query, Access opens the query in
· Type the name of your query here.
Datasheet view. Datasheet view presents the results of the query as a table. For information about working on tables in Datasheet view, such as filtering and sorting table data, see Chapter 5.
■ Your new query's name appears.
‚ Click Finish.
6048-4 ch09.F
10/19/99
2:13 PM
Page 261
II
■ The results of your query appear.
— Click the Close box.
CREATE TABLES, FORMS, AND REPORTS
How do I quit the Simple Query Wizard without creating a query? You can quit the Simple Query Wizard by clicking the Cancel button, located at the bottom of every Simple Query Wizard screen.
How do I retrace my steps in the Simple Query Wizard? You can revisit any of the previous screens in the Simple Query Wizard by clicking the Back button.
■ The results of your query disappear.
■ Your query appears in the Queries pane of the database window.
261
6048-4 ch09.F
10/19/99
2:13 PM
9
Page 262
CHAPTER 9: CREATE QUERIES
CREATE A QUERY FROM SCRATCH: SELECT TABLES
he query wizards make it easy to combine information from the different tables into a single database object. If you like, you can create a query from scratch. You can choose the tables to pick
T
⁄ Click Queries.
262
fields from, add or delete fields from the design grid, and select the order in which the fields will appear. Adding tables to the query design grid doesn’t affect how your query performs, but they do
give you more options when you create and modify your query. If you’re certain you won’t be using fields from a table in your query, you can hide the table to give you more room to work in the query design grid.
■ Queries and query wizards associated with your database appear in the right pane of the database window.
¤ Double-click Create query in Design view.
6048-4 ch09.F
10/19/99
2:13 PM
Page 263
II
■ The Show Table window appears. ‹ Click the name of the table you want to access in your query.
› Click Add. Note: For this example, we added a second table to the Design window.
CREATE TABLES, FORMS, AND REPORTS
Can I run a query on another query’s results? Since queries produce results in the form of tables in Datasheet view, you can run a query on another query’s results. To see a list of all queries and tables available for inclusion in your new query, click the Both tab in the Show Table window.
How do I only show the queries that are available for use in my new query? To see a list of queries you can use in your new query, click the Queries tab in the Show Table window.
■ The table is added to the Query window.
Note: You may add as many tables as you like to the Query window.
ˇ Click Close.
263
6048-4 ch09.F
10/19/99
2:13 PM
9
Page 264
CHAPTER 9: CREATE QUERIES
CREATE A QUERY FROM SCRATCH: SELECT FIELDS hen you add fields to your query, you can use those fields to select records from the tables, sort the records in the query’s results, and use the contents of the fields in your query to perform calculations.
W
⁄ Click the drop-down menu button in the first column.
264
In addition to picking which fields you want to display in your query’s results, you can narrow your selection even further by setting criteria that select which records will appear in the query’s results.
It is possible to include a field in the query but not show it in the result. You can find out how to hide fields by taking a look at task “Hide a Field,” presented later in this chapter.
¤ Click the field you want to add to your query.
■ The field name appears in the Field cell.
‹ Click the Field cell in the second column.
Note: The menu lists the name of the table and then the name of the field. For example, the CustomerID field in the Customers table is listed as "Customers.CustomerID".
■ The name of the table you selected the field from appears in the Table cell.
› Click the drop-down menu button.
6048-4 ch09.F
10/19/99
2:14 PM
Page 265
II
■ The list of fields appears.
ˇ Click the field to add to your query.
CREATE TABLES, FORMS, AND REPORTS
Will adding a lot of fields to my query slow it down when it runs? Just adding a single field to your query will not slow the query noticeably, though adding several unnecessary fields might affect performance if the query is run on a large database.
What if I add a field, then decide I don’t want to use it? You can delete a field from a query at any time. See the task “Delete a Field,” later in this chapter.
■ The field name appears in the Field cell.
■ The name of the table you selected the field from appears in the Table cell.
265
6048-4 ch09.F
10/19/99
2:14 PM
9
Page 266
CHAPTER 9: CREATE QUERIES
CREATE A QUERY FROM SCRATCH: SET CRITERIA nce you have added a field you want to include in your query, Access allows you to set criteria for selecting records based on the contents of that field. Your criteria can include as many elements as you like. If you create a query to track orders
O
⁄ Click the Criteria cell in the column you want to set a criterion. ¤ Type the criterion for that column.
266
from a subset of your customers, you could choose customers from a certain city, customers who had placed an order within the past six months, or customers who ordered more than $10,000 of goods in a month. Access gives you the ability to use wildcards and mathematical
‹ Press Enter.
expressions in your criteria. For more information on creating criteria with mathematical expressions and wildcards, see the section entitled “Wildcards and Expression Operators” at the beginning of Chapter 5.
■ The criterion appears in the cell.
9
6048-4 ch09.F
10/19/99
2:14 PM
Page 267
9
CHAPTER 9: CREATE QUERIES
II CREATE TABLES, FORMS, AND REPORTS
CREATE A QUERY FROM SCRATCH: SORT WITHIN A QUERY hen you create your query, you can use criteria to pick which records you want to appear in the results. You can also sort the results of your query based on the contents of one or more fields.
W
⁄ Click in the Sort cell of the column you want to use to sort your query results.
You can sort your query’s results to arrange your records in the best order for you or your employees to work with the data. For instance, you could create a query to list the performance of your sales representatives. You could sort the records in
‹ Click the sort method you want to use.
descending order to display which of your representatives were most effective and which require more attention.
■ The sort method appears in the Sort cell.
¤ Click the drop-down menu button.
267
6048-4 ch09.F
10/19/99
2:14 PM
9
Page 268
CHAPTER 9: CREATE QUERIES
SELECT ALL FIELDS IN A TABLE ou can add every field from a table to a query, but it takes some time. If you want to include every field from a table in your query’s results, but don’t need the contents of any of those fields in your results, you can have Access automatically update your query by clicking the asterisk in the field list.
Y
⁄ Click in the first empty cell in the Field row. ¤ Click the drop-down menu button.
268
Clicking the asterisk, also known as the All Fields selector, puts all of your table’s fields into a single grid cell. If your table’s layout changes, Access will change the contents of the cell to reflect the changes. You can add all of your fields to your query by double-clicking the title bar of the list of fields, clicking one of the highlighted
‹ Click the list item with the name of the table followed by an asterisk. Note: To add every field in the Customers table, click "Customers.*".
field names, and dragging the group to the grid. Adding fields to your query this way puts each of your field names in a separate grid cell. If you change your table’s layout, you will need to update your query manually.
■ The table's fields appear in the cell.
9
6048-4 ch09.F
10/19/99
2:14 PM
Page 269
9
CHAPTER 9: CREATE QUERIES
II CREATE TABLES, FORMS, AND REPORTS
CLEAR THE GRID ou can modify your query by deleting individual columns, modifying criteria, and inserting columns where required, but there might be times when it would be easier
Y
⁄ Click Edit.
to start from scratch. Access lets you do just that by clearing the grid. Clearing the grid should be saved as a last resort. You can remove the contents of specific
¤ Click Clear Grid.
columns in your query or, if you’ve saved your work, revert to a working version of the query and modify it instead of starting over.
■ The grid resets.
Note: You can't undo a Clear Grid action, so use it with caution.
269
6048-4 ch09.F
10/19/99
2:14 PM
9
Page 270
CHAPTER 9: CREATE QUERIES
DELETE A FIELD t’s easy to get confused when you create a query from scratch, especially if you have fields with the same name in more than one table. If you do add a field you won’t actually use in your query, or if you
I
⁄ Click anywhere in the field you want to delete. ¤ Click Edit.
270
accidentally add the same field more than once, you can delete fields from the query design grid one at a time. Another way to modify your query is to leave the column in the grid but delete its contents.
‹ Click Delete Columns.
To do that, highlight a cell’s contents and press the Delete key. You can delete multiple fields at once as well; just select two columns’ worth of cells and press Delete.
■ The field disappears.
9
6048-4 ch09.F
10/19/99
2:14 PM
Page 271
9
CHAPTER 9: CREATE QUERIES
II CREATE TABLES, FORMS, AND REPORTS
INSERT A FIELD hen you create your query, the order you enter your fields into the grid establishes the order the fields will be displayed in the results. It’s easy to accidentally miss entering a field while you’re filling in the grid, so Access lets you insert blank fields to give
W
⁄ Click anywhere in the field to the right of where you want the new field to appear.
you room to enter your fields in the proper order. One quick way to move information to a new field is to insert the blank field where the information should go and copy the field name, table, sort order, and criteria to the new column one cell at a time. You can do
¤ Click Insert.
that using cut-and-paste techniques common to all Windows 95 applications. If you accidentally leave a field blank, Access won’t display an empty column in the query results, even if you have the check box in the Show row clicked.
■ The new column appears.
‹ Click Columns.
271
6048-4 ch09.F
10/19/99
2:14 PM
9
Page 272
CHAPTER 9: CREATE QUERIES
CHANGE FROM DESIGN VIEW TO DATASHEET VIEW ou can work with your queries in one of two views: Design view or Datasheet view. When you work with your query in Design view, you can change which fields are used in your query, determine (through criteria) which records
Y
⁄ Click View. ¤ Click Datasheet view.
272
will be used to derive the results, and assign fields to appear in the query’s results. Running a query produces a dynaset. As the name implies, a dynaset’s contents are dynamic. Every time you run a query, the results are recalculated to reflect
Note: SQL view will be discussed in Chapter 10.
updated information in your tables. As with your tables, the data can be presented in a datasheet. As with table datasheets, you can page through your data, filter the results, and sort the datasheet’s contents.
■ The view changes from Design view to Datasheet view.
9
6048-4 ch09.F
10/19/99
2:14 PM
Page 273
9
CHAPTER 9: CREATE QUERIES
II CREATE TABLES, FORMS, AND REPORTS
CHANGE FROM DATASHEET VIEW TO DESIGN VIEW hen you view your query in Datasheet view, you can view and manipulate your results as you could with table datasheets. Viewing your query results in Datasheet view makes it easier
W
⁄ Click View. ¤ Click Design view.
for you to get a feel for the data. If you sort your query’s results so that information from related records (such as those relating to the same company, all sales on a particular date, etc.) appear in one datasheet, you can page
Note: SQL view will be discussed in Chapter 10.
through and gain a better understanding of your results. You should switch from Datasheet view to Design view whenever you want to modify your query’s structure.
■ The view changes from Datasheet view to Design view.
273
6048-4 ch09.F
10/19/99
2:14 PM
9
Page 274
CHAPTER 9: CREATE QUERIES
HIDE A FIELD ou can base your query on as many fields as you like, but you may not always want or need all of the fields you use in your query to appear in the results. One instance where you could hide a field in your query results is if you perform a calculation
Y
⁄ Click the check box in the Show cell of the column you want to hide.
274
and don’t need to display the values used in the calculation — just the results. You’ll learn about performing calculations in queries in Chapter 10. A similar situation arises when you look for all the orders received on a particular day. Displaying the date of the order,
which will be the same for every record in the results, is not necessary. You can always change your mind and show the contents of a field in your query’s results with one click of the mouse.
■ The check box changes from checked to unchecked.
¤ Click View. ‹ Click Datasheet view.
6048-4 ch09.F
10/19/99
2:14 PM
Page 275
II
■ The Datasheet view of your query appears.
ˇ Click View. Á Click Design view.
CREATE TABLES, FORMS, AND REPORTS
How do I hide a field after I’ve run a query? You can hide a field at any time by switching to Design view and clicking the check box in the Show cell of the field. When you switch back to Datasheet view, the column will be gone.
Can I hide a field in Datasheet view? You can hide a field in Datasheet view by clicking in the field you want to hide, opening the Format menu, and clicking Hide Columns.
■ The Design view of your query appears.
› The field disappears.
275
6048-4 ch09.F
10/19/99
2:14 PM
9
Page 276
CHAPTER 9: CREATE QUERIES
REARRANGE FIELDS
ather than require you to enter your fields in the exact order they should appear in your query, Access allows you to rearrange your fields in the query grid. You might want to rearrange your fields in the query grid to change the order they appear in the query results. For instance, if you wanted to call all of your
R
⁄ Click the column selector of the column you want to move.
276
customers that ordered from you during a particular month, the most important fields in your query would be the company name, name of your contact at that company, and that person’s phone number. Additional information, such as the address of the company and the amount of the order, could appear later in the results.
Another time you should rearrange fields in the query grid is to change the sort order of your query’s results. The first field you sort on must be the leftmost of the sorted fields, and so on.
■ The column appears in reverse video. ¤ Click the column selector again, holding down the mouse button after you do.
■ The Field Icon appears below the mouse pointer.
6048-4 ch09.F
10/19/99
2:14 PM
Page 277
II
‹ Holding down the left mouse button, drag the pointer over the column to the right of where you want the column you are moving to appear.
■ The insertion point for the pasted column appears as a highlighted line.
CREATE TABLES, FORMS, AND REPORTS
Can I sort my query results based on a field not in my query? You can only sort your query results based on fields included in your query, but you can hide the field so it does not appear in the results. For information on how to hide a field, see task “Hide a Field” from earlier in this chapter.
Can I sort results after the query is run? Sort query results in Datasheet view just as you would sort any query. See Chapter 5 for details.
■ The column appears in its new position.
› Release the mouse button.
277
6048-4 ch09.F
10/19/99
2:14 PM
9
Page 278
CHAPTER 9: CREATE QUERIES
SHOW A FIELD f you’ve hidden a field, Access lets you change your mind and show the field at any time. Showing a field is a handy way to verify your query is working the way you want it to. For example, if you wanted to find all customer orders over $1,000 that were placed during a particular month, you would hide the Date
I
⁄ Click the check box in the Show cell of the column you want to show.
278
field because so long as the date fell in that month, the specific day is not important. In some cases the dollar amount of the order wouldn’t be important, either; as long as the total of the order is over $1,000, you want it to show up in the results. However, if you wanted to call the customers and thank them for their order, having the total
dollar amount of the order (and perhaps other details of the transaction) would be useful information. In such a case, you might show those fields in your results.
■ The check box changes from unchecked to checked.
¤ Click View. ‹ Click Datasheet view.
6048-4 ch09.F
10/19/99
2:14 PM
Page 279
II
■ The Datasheet view of your query appears.
ˇ Click View. Á Click Design view.
CREATE TABLES, FORMS, AND REPORTS
How do I show a field after I’ve run a query? You can show a field at any time by switching to Design view and clicking the check box in the Show cell of the field. When you switch back to Datasheet view, the column will appear.
Can I show a field in Datasheet view? You can show a field in Datasheet view by opening the Format menu, clicking Unhide Columns, and checking the box next to the column you want to show.
■ The Design view of your query appears.
› The field appears.
279
6048-4 ch09.F
10/19/99
9
2:14 PM
Page 280
9
CHAPTER 9: CREATE QUERIES
SAVE A QUERY orking in Access is easy, but you wouldn’t want to repeat any of your work unnecessarily. The best way to make sure you don’t lose any of your work is to save your queries frequently. A good rule of thumb is to save your work whenever you’ve done something you wouldn’t want to repeat. Saving
W
⁄ Click File.
once every five minutes is another good suggestion. Access will prompt you to name your query when you save it for the first time. You can choose any name up to 255 characters, including spaces. You should pick a name that is short enough to work with easily but long enough to distinguish this
¤ Click Save.
table from the other queries in the database. Access will warn you if you choose a name that has already been assigned to another query in your database. If you prefer to use the keyboard to save your queries, you can type Ctrl+S at any time to save your work.
■ The Save As dialog box appears. ‹ Type the name of your query in this space.
280
› Click OK.
6048-4 ch09.F
10/19/99
2:14 PM
Page 281
9
CHAPTER 9: CREATE QUERIES
II CREATE TABLES, FORMS, AND REPORTS
CLOSE A QUERY ccess lets you have as many queries open as your computer’s memory will allow, but it’s often a good idea to close any queries you’re not using.
A
⁄ Click File.
The more queries you have open, the more memory your computer devotes to keeping track of them and redrawing the screen when you move or switch between windows.
¤ Click Close.
Closing unneeded queries lets your computer redraw the screen and update your changes more quickly.
■ The Query window disappears.
281
6048-4 ch09.F
10/19/99
2:14 PM
9
Page 282
CHAPTER 9: CREATE QUERIES
OPEN A QUERY IN DESIGN VIEW hen you open your query, you need to decide whether to open it in Design view or Datasheet view. You can switch between the two views at any time, but you can save yourself some effort by choosing the proper view when you start. Design view is best suited for changing the structure of your
W
⁄ Click the query you want to open.
282
query. If your query’s results aren’t what you’re looking for, you can add or delete fields, modify your criteria to show different records in the results, and sort your results differently. For example, if you wanted to rank your organization’s sales representatives, you could sort the results in your query in descending order based on total
¤ Click Design.
sales. If you accidentally sorted the query’s results based on employees’ last names, you could open your query in Design view and make the changes you need.
■ The query appears in Design view.
9
6048-4 ch09.F
10/19/99
2:14 PM
Page 283
9
CHAPTER 9: CREATE QUERIES
II CREATE TABLES, FORMS, AND REPORTS
OPEN A QUERY IN DATASHEET VIEW hen you work with your queries, you need to decide in which view you want to open your query. Datasheet view and Design view have unique strengths, so the choice is often straightforward. You should open your query in Datasheet view whenever you
W
⁄ Click the query you want to open.
want to look at a snapshot of your table data. For instance, if you want to see the results from the last time you ran your query, you can open your query in Datasheet view. When you run your query again the previous results are erased, but you can copy the data to another datasheet or transform your
¤ Click Open.
query into a make-table query to preserve your results. You’ll learn about creating make-table queries in Chapter 10. You should open a query in Datasheet view any time you want to look at the query’s results.
■ The query appears in Datasheet view.
283
6048-4 ch09.F
10/19/99
2:14 PM
9
Page 284
9
CHAPTER 9: CREATE QUERIES
RENAME A QUERY y allowing query names up to 255 characters in length, Access gives you a lot of flexibility in working with your new query. You can rename your query at any time in the database window. Renaming a query is handy when you modify what a query
B
⁄ Click the query you want to rename. ¤ Click Edit.
284
does. For instance, if your original query only looked at orders during a particular year and you extended the time period to include the following year, you should add that information to the query’s name. You also might want to rename a query if you combine two
‹ Click Rename.
queries into one. Adding “Old”, a version number, or a date to a previous version of a query helps distinguish the older object from the working version and makes it easier to track your changes.
■ The name of your query is highlighted.
› Type the new name for your query.
6048-4 ch09.F
10/19/99
2:14 PM
Page 285
9
CHAPTER 9: CREATE QUERIES
II CREATE TABLES, FORMS, AND REPORTS
DELETE A QUERY
ccess gives you the ability to delete queries easily. Unless you instruct Access not to do so, you will be asked if you are sure you want to delete the query, so there is a built-in safety mechanism in case you press a wrong button.
A
⁄ Click the query you want to delete.
You should consider deleting a query whenever you or another user create another query that generates similar results more efficiently or completely. You might want to keep the older query around on a backup disk or tape, but keeping it on the
¤ Click Delete.
active system might cause you or another user to run it instead of the updated query.
■ The query disappears.
Note: If you are asked whether you are sure you want to delete the query, click Yes.
285
6048-4 ch10.F
10/19/99
2:16 PM
Page 286
10
CHAPTER 10: CREATE ADVANCED QUERIES
CREATE ADVANCED QUERIES n addition to using queries to look up records in your tables, as you learned to do in Chapter 9, Access also allows you to perform calculations based on the contents of those records. You can perform calculations on as many fields as you like. Simply add the tables containing the fields you need to the Query Builder using the Show Table dialog box, write a standard query to select which records will provide the data for your
I
Show Top and Bottom Values in a Field– Access gives you the ability to limit your view to the top or bottom few values of your table or query. You can enter the value as an absolute number (for example, the top ten records in your query) or a percentage of the records. Entering a percentage is useful when you don’t know how many records your query will find. Entering an absolute value is helpful in contests and in comparing periodic results, such as identifying the top sales representative for a month, quarter, or year. Crosstab Queries– The basic type of query selects records from a table according to user-defined criteria. These queries, called selection queries, are extremely useful and versatile. Another tool you can use to summarize your data quickly and easily is a spreadsheet. While Access is not a spreadsheet-based program, you can create queries to summarize your data in the form of a spreadsheet by using a crosstab query. Crosstab queries are based on three fields: the field containing the result’s column names,
286
calculation, and write the expression Access will use to give you the result you want. You can use all of the standard mathematical operations to develop your expression (addition, subtraction, multiplication, division), plus other operations. Calculations are just one type of advanced query. Additional advanced functions are described below.
the field containing the result’s row names, and the field with the values to be inserted in the body of the query.
Update Queries– It is not always desirable to enter user data directly into a table. Instead, you could have your users enter changes, such as new contact information for existing customers, into a working database. At the end of the day, the database administrator could take the working databases, check them for duplicates or other data entry errors, and update the main customer database in a single action. Running an update query on a table can also trigger cascaded updates, where Access automatically updates the values in related tables to reflect the changes in the table affected by the update query. You should test your update queries on sample tables (copies of your working tables are probably best
6048-4 ch10.F
10/19/99
2:16 PM
Page 287
11/18/98
11/19/98
? Append Queries– An append query adds new records to the end of a table. Adding new records rather than changing existing entries is what differentiates an append query from an update query. Make-Table Queries– When you run a query, Access presents its results in a datasheet. You can work with your query’s results in the same way you’d work with records from a table — you can filter the records, sort the records, and find values in the records. The difference between a query datasheet and a table datasheet is permanence. When you run a query, Access creates a dynaset, or dynamic set of data that matches your query criteria. Unlike a table, which you need to modify by adding, deleting, or updating records by hand (or by using the specialized
queries you’ll encounter elsewhere in this chapter), a dynaset is overwritten whenever you rerun your query. If you want your query results to be permanent, write them to a table with the make-table query.
II CREATE TABLES, FORMS, AND REPORTS
suited for the tests) before running them on your primary records.
Find Unmatched and Duplicate Records– Another reason to run a query is to find out if a record in one table is not referenced in another table. One instance when you could run a find unmatched records query is to identify which customers have not placed an order in a given period of time, such as the last two months. You could discover this information by locating all of the orders for the last two months, writing those results to a new table using a make-table query, and running the query against the newly formed table. In much the same way, Access uses find duplicate records queries to take the manual labor out of checking your tables for redundant information. 1741
1741 1742 1743
?
1741 1741 1743
287
6048-4 ch10.F
10/19/99
2:16 PM
Page 288
10
CHAPTER 10: CREATE ADVANCED QUERIES
USE QUERIES TO PERFORM CALCULATIONS
s you learned in Chapter 9, queries are useful for looking up records in your table. You can also perform many other useful tasks using queries — one of those tasks is to perform calculations. You write queries containing calculations in the same way you write normal select queries. You
A
⁄ Create a query as you learned in the Chapter 9 task “Create a Query from Scratch: Select Fields.”
288
add the tables you want to use to the query design grid, pick the fields with the values you want to use in your calculation (and the rest of the query), and establish a sort order for your results. At any point in the process you can create a new field in your query that calculates values based on the
¤ Click in the next Field cell.
contents of the records returned by your query. You can use any basic mathematical operator in your calculation. For instance, you could multiply two fields together, divide the result by the value in another field, and compare the result and the value in yet another field.
■ The cursor appears in the clicked Field cell. ‹ Type the name of the new field in this space, followed by a colon and a space.
› Type the expression to be used to calculate the field after the space. ˇ Press Enter.
6048-4 ch10.F
10/19/99
2:16 PM
Page 289
II
■ The cursor moves to the next Field cell.
‡ Click Datasheet view.
CREATE TABLES, FORMS, AND REPORTS
I want to use a field with a name that occurs in more than one table. How do I tell Access which field I want? You can specify a field in a specific table by writing the table name in square brackets, followed by an exclamation point, and the field name in brackets. For example, using the UnitPrice column in the Products table would be written [Products]![UnitPrice].
How do I make the cell’s contents larger so I can read my expression more easily? You can zoom into the cell by typing Shift+F2. Access will open a Zoom window for that cell, allowing you to see and read your expression much more easily.
■ Your query appears in Datasheet view.
■ The calculated field appears.
Á Click View.
289
6048-4 ch10.F
10/19/99
2:16 PM
Page 290
10
CHAPTER 10: CREATE ADVANCED QUERIES
SHOW THE TOP VALUES IN A FIELD hen you sort the records in a table or the results from a query, you arrange the entire table according to the values in one or more fields. The entire dataset is put out in front of you for your examination — a very handy feature.
W
⁄ Click the Sort cell of the field you want to find the top values for.
290
But in addition to sorting an entire table, you can also display just the top (or bottom) results in your query. You can specify the number of records you want to see (10, 25, 100, and so on) or the percentage of records you want Access to display (for example, 10 percent). You can
¤ Click the drop-down menu button.
change between percentages and absolute numbers freely. Using absolute values is particularly useful for “top ten” lists and performance measures.
■ The drop-down menu appears. ‹ Click Descending.
› Double-click in the Top Values box.
6048-4 ch10.F
10/19/99
2:16 PM
Page 291
II
ˇ Type the number of values you want to see displayed in your query.
Á Click View. ‡ Click Datasheet view.
CREATE TABLES, FORMS, AND REPORTS
Does Access have a list of values I can choose from? Access does give you a list of values to choose from, including All. To see the list, click on the drop-down menu button on the right side of the Top Values combo box.
How do I tell Access I want to see the top 33 percent (or 50 percent, or another value) of the values in a field? You can enter the percentage of the values you want to see in the Top Values box. Simply type a % after the number.
■ The number of top values in the field you chose appear.
291
6048-4 ch10.F
10/19/99
2:16 PM
Page 292
10
CHAPTER 10: CREATE ADVANCED QUERIES
SHOW THE BOTTOM VALUES IN A FIELD
howing the top few values in your tables or query results is useful, but you’ll almost certainly want to spend time looking at the bottom values as well. You can learn a lot by looking at the least expensive, least productive, and slowest elements in your data collection.
S
⁄ Click the Sort cell of the field you want to find the bottom values for.
292
As with displaying the top records in your query, you can have Access display a specific number of records or give you a percentage of the records. For instance, if you wanted to see the five items with the lowest sales over the past year, you could create a query to display sales
¤ Click the drop-down menu button.
data for every item in your inventory and use the techniques you’ll learn here to narrow the results to what you want. As always, you can switch between absolute numbers and percentages.
■ The drop-down menu appears. ‹ Click Ascending.
› Double-click in the Top Values box.
6048-4 ch10.F
10/19/99
2:16 PM
Page 293
II
ˇ Type the number of values you want to see displayed in your query.
Á Click View. ‡ Click Datasheet view.
CREATE TABLES, FORMS, AND REPORTS
How do I tell Access I want to see the bottom 33 percent (or 50 percent, or another value) of the values in a field? You can enter the percentage of the values you want to see in the Top Values box. Simply type a % after the number.
Does Access have a list of values I can choose from? Access does give you a list of values to choose from, including All. To see the list, click on the drop-down menu button on the right side of the Top Values combo box.
■ The number of bottom values in the field you chose appear.
293
6048-4 ch10.F
10/19/99
2:16 PM
Page 294
10
CHAPTER 10: CREATE ADVANCED QUERIES
CREATE A CROSSTAB QUERY he most common (and simplest) query type is the selection quer y. A selection query does what its name implies: it reaches into your tables and selects records that meet the criteria you programmed into the query. Selection queries often stand alone, but they also form the
T
⁄ Double-click “Create query in Design view.”
base for every other query. If you can’t find the records, after all, you can’t perform advanced actions on them. One of those advanced tools is the crosstab query. A crosstab query uses data based on three fields: one field contains the values to be inserted in the body of the query, whereas the other
two fields index the results data with row and column numbers, like a spreadsheet. Although crosstab queries are useful, they’re not spreadsheets. They are, however, very useful for displaying your data in an easily understood format.
■ The Show Table window appears.
¤ Add the tables containing the values you will use in your crosstab query, following the steps in task “Create a Query from Scratch: Select Tables” from Chapter 9. ‹ Click Close.
294
6048-4 ch10.F
10/19/99
2:16 PM
Page 295
II
■ The Show Table window disappears. › Add the fields you want to use in your crosstab query as you learned to do in the Chapter 9 task “Add a Field.”
Note: Remember that you need three fields: one for the column headings, another for the row headings, and a third containing the values in the body of the table.
CREATE TABLES, FORMS, AND REPORTS
When I run my crosstab query, Access prompts me to enter a value for a field that is part of a calculation.Why did that happen? If you forget to add the table containing a particular field to your query, Access will treat it like a parameter and prompt the user for the value to use. For more information on parameters, see task “Prompt User for Selection Criteria” later in this chapter.
How do I use values from fields that won’t be displayed to calculate the value that will be displayed? You can use the values from any field you like in your calculations. Simply add the tables with the fields containing the values you want to use in your calculations when you form your query, deselecting the fields you don’t want to display in the Show field.
■ The Total and Crosstab rows appear in the QBE grid.
‡ Click the Crosstab cell in the field containing the values for your column headings.
ˇ Click Query. Á Click Crosstab Query.
CONTINUED
295
6048-4 ch10.F
10/19/99
2:16 PM
Page 296
10
CHAPTER 10: CREATE ADVANCED QUERIES
CREATE A CROSSTAB QUERY
s with a standard spreadsheet, you can define the column and row headings for your crosstab query. The data for a particular pair of values, such as an employee’s sales (the first value) during a given month (the second value), can be found at the intersection of the column and row.
A
■ The drop-down menu button appears. ° Click the drop-down menu button.
296
You are free to use any of the statistical measures in the Total cell’s drop-down menu. Those measures include finding the number of nonblank cells in a field, the minimum and maximum value of a field, the average of all values in a field, and the sum of all the values in a field.
· Click Column Heading. ‚ Click the Crosstab cell in the field containing the values for your row headings.
CONTINUED Although Access does not include tools to work with crosstab query data as a spreadsheet, you can export it to a spreadsheet program like Microsoft Excel. To do so, follow the instructions in the Chapter 7 task “Export Tables to Text and Excel files.”
■ The drop-down menu button appears.
± Click Row Heading.
— Click the drop-down
the field containing your query's field values.
menu button.
¡ Click the Crosstab cell in
6048-4 ch10.F
10/19/99
2:16 PM
Page 297
II
■ The drop-down menu button appears.
£ Click Value.
™ Click the drop-down
column containing the values for your query.
menu button.
¢ Click the Total cell in the
CREATE TABLES, FORMS, AND REPORTS
Can I do the same thing with my column headings? Access only allows you to have one field supplying the names for your column headings. If you want to use more than one criterion in your column headings, consider switching your column and row headings.
How do I group my results by more than one criteria, such as “City and State” rather than one or the other? You can group your results by more than one criterion by choosing Row Heading in the Crosstab cell of more than one field.
■ The drop-down menu button appears. ∞ Click the drop-down menu button.
§ Click the type of summary you want Access to perform on your field values.
CONTINUED
297
6048-4 ch10.F
10/19/99
2:16 PM
Page 298
10
CHAPTER 10: CREATE ADVANCED QUERIES
CREATE A CROSSTAB QUERY CONTINUED
s with other types of queries and sorts, Access lets you set criteria for choosing which records from the table or query will be used in your summary. Your criteria may be as simple or as complex as you like. In addition, fields used to determine which records will be selected need not appear in the results.
A
298
Although the most common use for crosstab queries is to summarize the data contained in a specific table, you can also run a crosstab query on the results of another query. Access queries produce a dynaset, or a dynamic collection of data based on the contents of a table. At the most basic level, though, dynasets are dynamically
generated tables. This property of query results is best illustrated by the make-table query, discussed later in this chapter.
6048-4 ch10.F
10/19/99
2:16 PM
Page 299
II CREATE TABLES, FORMS, AND REPORTS
Is there a Crosstab Query Wizard? There is a Crosstab Query Wizard, but it is limited. If you are only working with data in one table, the Crosstab Query Wizard is the most straightforward way to create your query. However, you can also use the Crosstab Query Wizard on data in two tables, if you really want to. (See the next tip.)
Can I use the Crosstab Query Wizard and data from more than one table? Yes—just create a selection query that captures the data you want and save it. Open the Crosstab Query Wizard, tell Access you want to use both tables and queries as data sources, and select the query.
299
6048-4 ch10.F
10/19/99
2:16 PM
Page 300
10
CHAPTER 10: CREATE ADVANCED QUERIES
CREATE AN UPDATE QUERY ntering data by hand is a cumbersome and often inaccurate process. Not only can users make mistakes, but there may not be enough of them to keep up with the volume of data entering your databases. That’s where the update query is useful. An update query compares values to the contents of another table. If Access recognizes that the values in the tables are different, it substitutes the newer values for
E
⁄ Double-click “Create query in Design view.”
300
the older ones in the original table. Update queries are useful, but you do need to be careful when you run them. One example would be updating the LastName field when someone changes his or her name. Using the update query to change the old name (say, “Sherwood”) to the new name (“Forrest”) would change ever y Sherwood in your database. You could narrow the
Note: For this example, we created a table named Contacts that has the same structure and data as the Customers table.
query’s criteria to avoid this problem, but you can see how update queries can be dangerous. You should run your update queries as often as you need to in order to keep your databases upto-date. Some organizations will require hourly updates, others once a day, and still others once a week.
■ The Show Table window appears. ¤ Add the tables you want to use in your query as you learned in the Chapter 9 task “Create a Query from Scratch: Select Tables.”
‹ Click Close.
6048-4 ch10.F
10/19/99
2:16 PM
Page 301
II
■ The Show Table window disappears. › Add the fields you want to use in your update query as you learned to do in the Chapter 9 task “Add a Field.”
ˇ Click Query. Á Click Update Query.
CREATE TABLES, FORMS, AND REPORTS
If I double-click on an update query, it runs automatically. How do I protect my tables from being updated accidentally? You should protect your tables by ensuring the update query can only be run by authorized users and by running the query on a backup copy of a table first. To establish user-level permissions and user authorizations, see Chapter 22.
When I update one table, will the tables it is related to be updated as well? Yes, all related tables will be updated in a cascade effect, if you have followed the steps for enforcing referential integrity covered in Chapter 6.
■ The Update To row appears in the QBE grid.
° Press Enter.
‡ Type the expression Access will use to update the selected records in the Update To cell of the field to be updated. 301
6048-4 ch10.F
10/19/99
2:16 PM
Page 302
10
CHAPTER 10: CREATE ADVANCED QUERIES
CHECK AND RUN YOUR QUERY ne handy feature of Access’ query generation system is that you can switch to Datasheet view at any time while creating your query and check the dynaset to see which records are being found, what calculations were made on the cell contents, and how the results are ordered. Check your query whenever you change it significantly,
O
CHECK A QUERY
⁄ Click Query. ¤ Click Select Query.
302
whether during the initial creation process or modifying it later. Verifying the results of each of your changes can save you lots of time — since you know what change you made and what effect it had, you can identify which elements of your query may need to be modified to make it work properly. Once you are certain your query is performing correctly,
‹ Click Datasheet view.
you should run it every time you need to summarize the data in the underlying tables. Extremely busy stores should run their queries quite often, while video collectors, for example, could get away with running their summaries infrequently.
■ The Datasheet view of your query appears. Note: You should examine the results of your query to make sure it finds the records you want to update.
› Click the Design View button.
6048-4 ch10.F
10/19/99
2:16 PM
Page 303
II
RUN A QUERY
⁄ Click Run.
CREATE TABLES, FORMS, AND REPORTS
I want to keep a copy of an incomplete version of my query. How do I do that? Instead of saving your query normally, open the File menu and click Save As. Type in a new name for your query and press Enter.
Is there a way to run a query from the menus in Design view? You can run a query from the menus in Design view by opening the Query menu and clicking Run.
■ The Update Confirmation dialog box appears. Note: Remember, you can't undo most queries. You may want to run the query on a backup copy of a table first.
¤ Click Yes. Note: You can open your query in Datasheet view or run the query as a select query to see the results of your update.
303
6048-4 ch10.F
10/19/99
2:16 PM
Page 304
10
CHAPTER 10: CREATE ADVANCED QUERIES
CREATE AN APPEND QUERY
ppend queries add the records they find to the end of a table. One common use for append queries is to take the contents of a number of “working” files and add them to a central table. A database that tracks sales contacts is one example of a perfect use for the append query.
A
⁄ Double-click “Create query in Design view.”
Sales reps can create individual lists on the road, bring their tables back to the office (or send them to the office via electronic mail), and rely on the database administrator to add the contacts to the central file. When using the append query, you should always check any new data for both accuracy and
duplication. If you need to, don’t hesitate to write a questionable record to another table to append later. Then you can just add the confirmed data to the central file.
■ The Show Table window appears. ¤ Add the tables containing the records you want to append to another table as you learned in the Chapter 9 task “Create a Query from Scratch: Select Tables.”
304
‹ Click Close.
6048-4 ch10.F
10/19/99
2:16 PM
Page 305
II
■ The Show Table window disappears. › Add the fields you want to use as the data source for your append query as you learned to do in the Chapter 9 task “Add a Field.”
ˇ Click Query. Á Click Append Query.
CREATE TABLES, FORMS, AND REPORTS
My source table and target table have the same layout in terms of number of fields and data types of those fields, but the field names are different. Can I append records from my source table to the target table? Access checks to make sure the data types of the source and target fields match; if so, Access enters the data into the target field regardless of the field names.
My source and target tables have the same layout. Is there a quick way to have Access append all of the fields? If the source and target tables have the same layout, you can use the asterisk field identifier to add all of the source table’s fields at once.
■ The Append dialog box appears. ‡ Click the drop-down menu button. ° Click the name of the table to have the data appended to it.
Note: For this example, we created a new table named Contacts. This table has the same structure as the Customers table in the Northwind sample database.
· Click OK. CONTINUED
305
6048-4 ch10.F
10/19/99
2:16 PM
Page 306
10
CHAPTER 10: CREATE ADVANCED QUERIES
CREATE AN APPEND QUERY CONTINUED
ppend queries are a good way to merge two tables. If two organizations were to merge and want to maintain a central customer and contact list, appending one table to the end of the other, after checking for duplicate records, is the easiest way to do it.
A
■ The Append dialog box disappears. ■ The target table appears in the Append To cell.
306
When you tell Access you want to make an append query, it walks you through the required steps. You pick the tables containing the records you want to append, designate the target table, indicate which fields should be transferred, and Access will take care of the rest.
‚ Click Run.
It is important to remember that you can’t undo an append query. Once the records have been added to the target table, the only way to remove them is to delete them manually.
■ The Confirmation dialog box appears.
— Click Yes.
6048-4 ch10.F
10/19/99
2:16 PM
Page 307
II
■ The Confirmation dialog box disappears. ± Click the Close box to close your query.
Note: If Access asks you if you want to save your query, click Yes and follow the steps in the Chapter 9 task “Save a Query.”
CREATE TABLES, FORMS, AND REPORTS
My source table has fewer fields than my target table.What happens when I append those (shorter) records? Access fills in the fields with the values from your source table until it encounters an “end of record” mark in either of your tables. Once that mark is found, Access moves to the beginning of the next record in both tables.
My source table has more fields than my target table.What happens to the extra fields? The extra fields are ignored when you append the rows to the target table.
■ Your query appears in the Database window.
307
6048-4 ch10.F
10/19/99
2:16 PM
Page 308
10
CHAPTER 10: CREATE ADVANCED QUERIES
CREATE A MAKE-TABLE QUERY hen Access runs a query, it produces a dynaset, or a dynamic collection of information based on the tables and records you selected in your query. Just like a table, the dynaset can be sorted, filtered, and searched. Access takes this relationship between the dynaset and a table
W
⁄ Click “Create query in Design view.”
one step further by allowing you to create tables based on the results of a query. The table is created automatically and appears in your Database window, ready for use. Make-table queries are useful when you need to have your query’s results available in a readily portable form. Once the
results have been put in a table, you can copy the table over networks, carry it with you on a floppy disk or laptop computer, and refer to the table as a snapshot of the query’s results at a particular time.
■ The Show Table window appears. ¤ Add the tables containing the fields you want to write to a new table as you learned in the Chapter 9 task “Create a Query from Scratch: Select Tables.”
308
‹ Click Close.
6048-4 ch10.F
10/19/99
2:16 PM
Page 309
II
■ The Show Table window disappears.
› Add the fields you want to write to your new table as you learned to do in the Chapter 9 task “Add a Field.”
ˇ Click Query. Á Click Make-Table Query.
CREATE TABLES, FORMS, AND REPORTS
What happens the second time I run a make-table query? Is the table generated by the first run erased? When you run a make-table query for the second (and later) times, it will overwrite the previous table. Access will warn you that the previous table will be erased and give you the chance to cancel the query.
How do I make sure the first table is not erased? The easiest way to make sure the first table is not erased is to rename the table. To rename a table, follow the steps in the Chapter 3 task “Rename a Table.”
■ The Make Table dialog box appears.
° Click OK.
‡ Type the name for your new table in this space. CONTINUED
309
6048-4 ch10.F
10/19/99
2:16 PM
Page 310
10
CHAPTER 10: CREATE ADVANCED QUERIES
CREATE A MAKE-TABLE QUERY CONTINUED
he table you create using a make-table query will be made up of the results of your query, which can include all of the criteria, sorting, and field selections of any other query. When you tell Access you want to create a make-table query, it asks you for the name
T
of the table you want the results to be written to. You can give the target table any legal name (that is, up to 255 characters in length), but the name must be unique within your database. Make-Table queries record query results at a particular time. For instance, if you added
■ The Make Table dialog box disappears.
‚ Click the Close box to close your query.
· Click Run.
Note: If Access asks if you want to save your query, click Yes and follow the steps in the Chapter 9 task “Save a Query.”
310
records to a sales table every day, you could create a make-table query to write a table containing just the added records or to derive sales information that would allow you to track your customers’ buying patterns more effectively.
■ Your make-table query disappears.
— Double-click the icon for your new table.
6048-4 ch10.F
10/19/99
2:17 PM
Page 311
II
■ The table opens.
CREATE TABLES, FORMS, AND REPORTS
Can I give my table the same name as the query that generates it? Every item in your database must have a unique name. You should name the table generated by your make-table query something similar to the query’s name, but the two names cannot be identical.
If I run my make-table query again, will my old table be updated? No. An entirely new table will be created.
■ The table disappears.
± Click the Close box to close the table.
311
6048-4 ch10.F
10/19/99
2:17 PM
Page 312
10
CHAPTER 10: CREATE ADVANCED QUERIES
USE QUERIES TO SUMMARIZE DATA ou can use Access queries to find records that match certain criteria. If those records contain numerical data such as sales totals, times, or grades, you can have Access
Y
⁄ Double-click “Create query in Design view.”
summarize your data within the query. You can have Access summarize your data in several ways: finding the sum of the values in a field: identifying the
minimum, maximum, first, or last value in the field; calculating the variance or standard deviation of the values in the field; and so on.
■ The Show Table window appears. ¤ Add the tables containing the fields you want to write to a new table as you learned in the Chapter 9 task “Create a Query from Scratch: Select Tables.”
312
‹ Click Close.
6048-4 ch10.F
10/19/99
2:17 PM
Page 313
II CREATE TABLES, FORMS, AND REPORTS
Can I automatically update the values in a summary? A summary is a dynamically generated snapshot of your data, rather than a table, so it cannot be updated automatically. To update the values in your summary, run the query again.
■ The Show Table window disappears. › Add the fields containing the values you want to use in your summary, as you learned to do in the Chapter 9 task “Add a Field.”
ˇ Add the criteria to select the records you want to summarize.
■ The Total row appears in the QBE grid.
° Click the Total cell in the column you want to summarize.
Á Type the expression to summarize your data here.
‡ Click Totals.
CONTINUED
313
6048-4 ch10.F
10/19/99
2:17 PM
Page 314
10
CHAPTER 10: CREATE ADVANCED QUERIES
USE QUERIES TO SUMMARIZE DATA CONTINUED
reating complicated queries can take lots of time and effort, so you should take the time to check the records your query returns. Once you’ve found a combination that returns some or all of the records you want, you should save your work.
C
■ The drop-down menu button appears. · Click the drop-down menu button.
314
You should also take a look at your query’s results whenever you change it. Even the most basic changes can backfire if input improperly; it pays to take the time to check your work. Once your query works properly, you can run it as often as you need. If you wanted to track how
‚ Click the type of summary you want Access to perform on this field. Note: For this exercise, use Sum.
quickly your suppliers responded to your orders, you could create a field that calculated the number of days from the time you made your order until the goods arrived.
■ The drop-down menu disappears.
± Click the drop-down menu button.
— Click in the Total cell of the field containing the criteria to select the records to be summarized.
¡ Click Where.
6048-4 ch10.F
10/19/99
2:17 PM
Page 315
II CREATE TABLES, FORMS, AND REPORTS
Where can I get more information on summary operations in Access? You can get more information on Access’ summary operations by opening Access Help’s Answer Wizard and asking for help on “aggregate functions.”
■ “Where” appears in the cell. Note: You can read the contents of the Total cell and the Criteria cell as one statement. In this case: Select records where the date is like "2/*/97."
Note: Access can’t show the values in the Where field in your query’s results, so it automatically clears the Show check box for that field.
■ The drop-down menu button appears.
¢ Click Sum.
£ Click the drop-down
second field used in your summary calculation.
menu button.
∞ Click the Total cell in the
™ Click the Total cell in the first field used in your summary calculation.
CONTINUED
315
6048-4 ch10.F
10/19/99
2:17 PM
Page 316
10
CHAPTER 10: CREATE ADVANCED QUERIES
USE QUERIES TO SUMMARIZE DATA CONTINUED
s with other queries, you enter criteria to determine which records Access will use as the base for calculations. Once you’ve input the criteria you want to use, you can begin entering calculations and summaries for the query, and you
A
316
can specify which fields you want displayed in your query’s results. Most of the time, you’ll want to run a query that finds records in one of your tables, because tables are relatively permanent collections of data. But since
queries return data in a table-like format (a dynaset), you can also run summation queries on the results of other queries. (You can make a dynaset into a table by changing the query’s type to make-table.)
6048-4 ch10.F
10/19/99
2:17 PM
Page 317
II
■ The check marks in the boxes disappear.
º Click the Datasheet View button.
CREATE TABLES, FORMS, AND REPORTS
Can I use the values of calculated fields in my summary? Access requires you to use values contained in your table in your calculations. If you want to use the results of a calculated field in your summary, you will need to repeat the original expression in the new calculation.
Can I sort the summary results? You can sort the summary results like you would any dynaset or table. (See chapter 5 for details on sorting.)
■ The Datasheet view of your query appears.
317
6048-4 ch10.F
10/19/99
2:17 PM
Page 318
10
CHAPTER 10: CREATE ADVANCED QUERIES
FIND UNMATCHED RECORDS hen you run a query, you’re looking for information about specific objects in one or more tables. For instance, you could be looking for orders placed by a particular customer. That customer’s identification number would appear in both the Customers and Orders tables, making your search easy.
W
⁄ Click the down arrow next to the New Object button on the toolbar.
318
But it can also be useful to note which values don’t occur in certain tables. In the customer ordering example, for instance, you might want to see a list of all sales contacts who haven’t placed an order for a month. Once you’ve found that list of customers, you could check your contacts-tracking table to make sure your sales staff hadn’t forgotten about them.
¤ Click Query.
As with other queries, you can also run a find unmatched records query against another query’s output. If one of your queries generates a list of all orders placed in the last month, you could include those results in your find unmatched records query.
■ The New Query dialog box appears.
‹ Click Find Unmatched Query Wizard. › Click OK.
6048-4 ch10.F
10/19/99
2:17 PM
Page 319
II
■ The Find Unmatched Query Wizard appears. ˇ Click the table containing the records you want to appear in your results.
Á Click Next.
CREATE TABLES, FORMS, AND REPORTS
When would I want to run a find unmatched records query? If Access will not let you establish referential integrity between two tables, it might be because there are unmatched records in one of the tables. The find unmatched records query identifies those records for you.
Is it important which table I select first in the Wizard? Yes. The query will find records only in the first table that don’t have matching fields in the second table—not the other way around.
■ The next Find Unmatched Query Wizard screen appears.
‡ Click the name of the table with the related records. ° Click Next. CONTINUED
319
6048-4 ch10.F
10/19/99
2:17 PM
Page 320
10
CHAPTER 10: CREATE ADVANCED QUERIES
FIND UNMATCHED RECORDS CONTINUED hen you create a find unmatched records query, Access asks which fields you want displayed in the query’s results. In many cases, the best alternative is to include the entire record — not only will you be able to make decisions based on the
W
320
information at hand, you will often have enough information to take action as well. The find unmatched records query developed in the example illustrates this point nicely. Not only do the CustomerID’s of customers with no orders in the database appear in the results,
but also the company name, contact name, and contact information for the company. Based on this single query, your sales representatives could call the customers who had not placed orders within the last two months to check their status.
6048-4 ch10.F
10/19/99
2:17 PM
Page 321
II
■ The Checkered Flag screen appears. ™ Type the name of your query in this space.
£ Click Finish.
CREATE TABLES, FORMS, AND REPORTS
How do I remove all of the fields to start over? You can remove all of the fields from the Selected Fields pane by clicking the Remove All Fields button.
How do I remove a field from the selected fields pane? You can remove a field from the selected fields pane by clicking the back arrow.
■ Your results appear.
Note: For the purposes of this exercise, leave the radio button next to “View the results” clicked.
321
6048-4 ch10.F
10/19/99
2:17 PM
Page 322
10
CHAPTER 10: CREATE ADVANCED QUERIES
DISPLAY THE SQL VERSION OF A QUERY
ccess makes it easy to create queries to extract specific information from tables. What you don’t see, at least on the surface, are the rules and statements that make up your query. Access translates the field names, criteria, and sort instructions in the QBE grid to the Structured Query Language
A
⁄ Double-click the query you want to view.
(SQL). SQL is a standard language used by database programmers to define queries. Since SQL is a standardized language, you can move queries from one Access database to another and, assuming the databases had similar structures (including field and table names), run them successfully.
Taking a look at your queries in SQL view gives you a better idea of what is going on behind the scenes when your query is processed. And, since you know what your query is supposed to do, you can make sense of the SQL behind your query much more easily.
■ The query opens in Datasheet view. ¤ Click the drop-down menu button next to the View button on the toolbar.
322
‹ Click SQL view.
6048-4 ch10.F
10/19/99
2:17 PM
Page 323
II
■ Your query appears in SQL view.
› Click the Close box.
CREATE TABLES, FORMS, AND REPORTS
How do I copy the SQL for my query? You can copy the SQL behind your query by highlighting the text and typing Ctrl+C. To paste the query into another query or text document, type Ctrl+V.
Can I modify my query in SQL view? You can modify your query in SQL view, though you will need to become familiar with SQL to do so properly.
■ Your query disappears.
323
6048-4 ch10.F
10/19/99
2:17 PM
Page 324
10
CHAPTER 10: CREATE ADVANCED QUERIES
DETECT MINIMUM AND MAXIMUM VALUES hen you work with large data collections, it can be difficult to find the highest and lowest value in a field manually. Fortunately, you can have Access do the searching for you.
W
⁄ Follow steps 1–7 of task “Use Queries to Summarize Data,” presented earlier in this chapter. ■ The Total row appears.
324
You might want to find the minimum values for a field on some occasions. For example, say you wanted to identify the months when sales are their low point for the year. By locating the minimum and maximum values
¤ Click the Total cell in the column where you entered your selection criteria.
for each year, you could adjust inventory, staffing, and advertising expenses to plan for the rhythms of your business.
■ The drop-down menu button appears. ‹ Click the drop-down menu button.
› Click Where.
6048-4 ch10.F
10/19/99
2:17 PM
Page 325
II
■ Where appears in the cell. FIND THE MINIMUM VALUE
ˇ Click the first empty cell in the Field row. Á Type the expression for which you want to find the minimum value.
‡ Click the Total cell.
CREATE TABLES, FORMS, AND REPORTS
How do I display the top (or bottom) values in a field? You can display more than one top or bottom value in a field by creating a query using the instruction in tasks “Show the Top Values in a Query” and “Show the Bottom Values in a Query,” presented earlier in this chapter.
Can I run a maximum or minimum value query on a set of query results (a dynaset) in addition to a standard table? Yes, you can run this query on a dynaset.
■ A drop-down menu button appears.
· Click Min.
° Click the drop-down menu button. CONTINUED
325
6048-4 ch10.F
10/19/99
2:17 PM
Page 326
10
CHAPTER 10: CREATE ADVANCED QUERIES
DETECT MINIMUM AND MAXIMUM VALUES CONTINUED
inding the minimum and maximum values for a field allows you to learn quite a bit about the data in your database. For example, if you order goods from a supplier and suspected that your supplier was able to fulfill your order more quickly at certain times of the month, you could detect the
F
326
minimum and maximum supplier response times. If the longest and shortest delays took place at different times of the month (or year), you could run a broader query to determine if the pattern held true for every order, not just the extreme cases. Remember that you can find the minimum and maximum
values in calculated fields as well. If you wanted to find out if the average response time from a supplier changed from month to month, you could perform that calculation in your query and detect the minimum and maximum average values.
6048-4 ch10.F
10/19/99
2:17 PM
Page 327
II CREATE TABLES, FORMS, AND REPORTS
How do I show the minimum and maximum values of a calculated field? You can show the minimum and maximum values of a calculated field by creating the calculation and choosing Min or Max in the Total cell for that field.
■ Max appears in the cell.
£ Click the Datasheet View
■ Your query results appear.
button.
327
6048-4 ch10.F
10/19/99
2:17 PM
Page 328
10
CHAPTER 10: CREATE ADVANCED QUERIES
FIND DUPLICATE RECORDS ne benefit of having access to your tables in Datasheet view is that you can visually inspect the tables to check the data’s integrity, ensure there are no data entry errors, and, if the tables are small enough, check for duplicate records. Once a table grows beyond a few dozen records, however,
O
⁄ Click the New Object drop-down menu button.
checking for duplicate records can become a tedious and mistake-prone task. Fortunately, Access allows you to create find duplicate records queries, which take the manual labor out of checking tables for redundant information. Creating a find duplicate records query is simple. Access includes the Find Duplicate
¤ Click Query.
Records Query Wizard, which steps you through the process of creating the query. You can pick the table you want to check for duplicates, tell Access which fields in the table might contain duplicate values, and include other fields in the query’s results so you can work with output without referring to the original table.
■ The New Query window appears. ‹ Click Find Duplicates Query Wizard.
328
› Click OK.
6048-4 ch10.F
10/19/99
2:17 PM
Page 329
II
■ The next screen of the Find Duplicates Query Wizard appears. ˇ Click the name of the table you want to check for duplicate field values.
Á Click Next.
CREATE TABLES, FORMS, AND REPORTS
How do I remove a field from the Duplicate-Value Fields pane? You can remove a field from the DuplicateValue Fields pane by clicking the back arrow.
How do I remove all of the fields and start over? You can remove all of the fields from the Duplicate-Value Fields pane by clicking the Remove All Fields button.
■ The next screen of the Find Duplicates Query Wizard appears.
° Click the forward arrow to add the value to the Duplicate-Value Fields pane.
‡ Click the first field you want to check for duplicate values. CONTINUED
329
6048-4 ch10.F
10/19/99
2:17 PM
Page 330
10
CHAPTER 10: CREATE ADVANCED QUERIES
FIND DUPLICATE RECORDS CONTINUED eyond checking data integrity, a find duplicate records query is a good way to find all the records in a table with values that occur in one or more other records. For instance, if you wanted to find
B
■ The selected field appears in the DuplicateValue Fields pane. Note: Repeat steps 7–8 to add other fields you want to check for duplicate values.
330
which cities were home to more than one of your customers, a find duplicate records query could get you that information. Although the most common use for a find duplicate records query is to check tables for
· Click Next.
duplicate values, you can also run this type of query on the results of another query.
■ The next screen of the Find Duplicates Query Wizard appears. Note: Repeat steps 7–8 to add fields you want Access to display in the query results. For this exercise, consider adding Company Name.
‚ Click Next.
6048-4 ch10.F
10/19/99
2:17 PM
Page 331
II
■ The Checkered Flag screen appears. — Type a name for your query here.
Note: For the purposes of this exercise, leave the radio button next to “View the results” clicked.
CREATE TABLES, FORMS, AND REPORTS
How many fields can I check for duplicate values? Access allows you to designate up to ten fields for it to check in your find duplicate records query.
I’ve made a few mistakes while using the wizard. How do I get out of it without saving my changes? You can exit the wizard without saving any of your changes by clicking the Cancel button.
■ The results of your query appear.
± Click Finish.
331
6048-4 ch11.F
10/19/99
11
2:19 PM
Page 332
CHAPTER 11: CREATE FORMS CREATE TABLES, FORMS,AND RECORDS
2 CHAPTER 11: CREATE FORMS
CREATE FORMS n Chapter 4, you learned how to enter and work with data using an Access datasheet. In this chapter, you’ll learn how to create tools that make entering and working with data much easier. These tools, called forms, make it easy for you to enter and edit data. Forms present the contents of
I
Create a Form Using an AutoForm– When you create a table and populate it with data, Access allows you to work with your table data through a datasheet. Although datasheets present the information in your tables in a compact, usable form, the simple design and tightly packed presentation can make it hard to read individual records. You can make it easier to read your data by creating forms based on your tables and queries. The quickest way to create forms based on your tables or the results of your queries is to use an AutoForm. The most basic AutoForm dispenses with formatting, colors, and background designs, presenting your information in a straightforward manner that includes every field in your table or query. You can create this simple AutoForm in a few seconds with a few clicks of the mouse. Once you’ve created your AutoForm, you can page through your table or query results one record at a time, move to the beginning or
332
your tables in a visually appealing manner, including room for you to add instructions for users to follow when entering data. The exercises in this chapter were performed on a copy of the Northwind sample database titled Northwind2.
end of the table or query, or jump to a particular record within the table.
Create a Tabular AutoForm– A tabular form arranges your information in a horizontal pattern, presenting an entire record or query result on a single line of the report. Since many of your records are presented next to each other, you can verify information among records with similar values, visually inspect the data for errors or omissions, and page rapidly through your data.
6048-4 ch11.F
10/19/99
2:19 PM
Page 333
Create a Columnar AutoForm–
II CREATE TABLES, FORMS, AND REPORTS
Name
A columnar AutoForm places each of your source table or query’s records on a page by itself, allowing you to inspect the data, ensure it is internally consistent, and modify it if necessary. You can page through the form using the controls at the bottom of the page. Those controls allow you to move to the next or previous record, the first or last record, or to a specific record by entering its number. Move Through Records–
Create a Datasheet Form– A datasheet AutoForm places each of your source table or query’s records in a datasheet of the type you saw in Chapter 4. You can work with your data as with a standard datasheet, moving from record to record, comparing your data visually, sorting and filtering the results, and paging through the data.
Access gives you a number of ways to move among the records in your table. You can step up and down one record at a time to compare records, make sure there are no duplications, and ensure the data has been entered properly. You can move within your table using controls at the bottom of the screen, which resemble those of a videocassette recorder, or by using the keyboard. Access displays the active record in Form view; the cursor appears in the cell containing the information that will be modified if you were to enter data from the keyboard.
*
Create a Justified Form– When you create a justified AutoForm, you create a form that displays all of the fields in your table or query in the most compact format possible. Justified AutoForms are the best choice for when you need all of your information displayed in a small space, like when your form will share the screen with other forms or tables. As with other forms, you can page through your table or query results by using the controls at the bottom of the page. Those controls allow you to move to the next or previous record, the first or last record, or to a specific record by entering its number. 333
6048-4 ch11.F
10/19/99
2:19 PM
11
Page 334
CHAPTER 11: CREATE FORMS
CREATE A FORM USING AN AUTOFORM
ccess stores your data in tables you create using a wizard or from scratch. Entering data into tables directly is possible when you open tables in Datasheet view, as is reading the records in your tables, though there are several limitations. The first limitation is that the datasheet interface is limited to a
A
⁄ Click the table to supply the structure and data for your AutoForm.
334
grid. You can change the color and appearance of the grid, but the basic presentation never changes. Another significant limitation is in printing records. You can choose which records you want to print, but the result is a direct reflection of what you see on the screen. Instead of a grid filled with information on the screen, you get a grid filled
¤ Click the New Object drop-down menu button. ‹ Click AutoForm.
with information on a piece of paper. Forms allow you to go beyond the grid-based datasheets and create interfaces that are easier to enter data into, read data from, and print. The quickest way to create a form is to use an AutoForm.
■ Your form appears.
› Click the Close box.
6048-4 ch11.F
10/19/99
2:19 PM
Page 335
II
■ The Save Changes dialog box appears.
ˇ Click Yes.
CREATE TABLES, FORMS, AND REPORTS
How do I close my AutoForm without saving it? You can close your AutoForm without saving it by clicking the Cancel button in the Save Changes dialog box.
Can I modify the AutoForm once it’s created? Yes, you can modify the AutoForm the same way you would any other form. (See Chapter 13 for details.)
■ The Save As dialog box appears.
Á Type the name of your new form in this space. ‡ Click OK.
335
6048-4 ch11.F
10/19/99
2:19 PM
11
Page 336
CHAPTER 11: CREATE FORMS
CREATE A TABULAR AUTOFORM USING THE FORM WIZARD
ccess allows you to create several types of AutoForms to view and edit the information in your tables or generated by your queries. One of those types of forms is the tabular form. Tabular AutoForms have much in common with datasheets — both objects
A
⁄ Click the table to supply the structure and data for your form.
display a complete record on a single line, though tabular AutoForms present information in a much more user-friendly format than datasheets. Tabular AutoForms don’t usually display as many records on the screen at a time as a datasheet, but the results are much easier to read.
Access guides you through the AutoForm creation process with the AutoForm Wizard, which allows you to pick the queries and tables containing the information you want to display in your form.
¤ Click the New Object drop-down menu button.
■ The New Form window appears.
‹ Click Form.
› Click AutoForm: Tabular.
■ The table or query your form is based on appears here. ˇ Click OK.
336
6048-4 ch11.F
10/19/99
2:19 PM
Page 337
II
■ Your form appears. Á Click File.
‡ Click Save.
CREATE TABLES, FORMS, AND REPORTS
I clicked the wrong table to use in my form. How do I change it from within the wizard? You can change the table to use in your form by clicking the drop-down menu button next to the space where your table name appears and choosing a new table.
How do I get help on using the AutoForm Wizard from within the wizard? You can get help using the AutoForm Wizard by clicking the Help button on the title bar of the Wizard window.
■ The Save As dialog box appears.
° Type the name of your new form in this space. · Click OK.
337
6048-4 ch11.F
10/19/99
2:19 PM
11
Page 338
CHAPTER 11: CREATE FORMS
CREATE A COLUMNAR FORM USING AN AUTOFORM
ccess allows you to create several types of AutoForms to view the information in your tables or generated by your queries. One of those types of reports is the columnar AutoForm. Columnar AutoForms focus on the contents of each record. Rather than display as many
A
⁄ Click the table to supply the structure and data for your form.
338
records as possible on a page, columnar AutoForms emphasize the contents of each record by displaying the contents of a table or query, one record per page. As with other forms, you can move from record to record using the buttons on the navigation bar at the bottom of the form.
You create AutoForms using the AutoForm Wizard, which allows you to pick the table and query fields you want to display in your form.
¤ Click the New Object drop-down menu button.
■ The New Form window appears.
‹ Click Form.
› Click AutoForm: Columnar.
■ The table or query your form is based on appears here. ˇ Click OK.
6048-4 ch11.F
10/19/99
2:19 PM
Page 339
II
■ Your form appears. Á Click File.
‡ Click Save.
CREATE TABLES, FORMS, AND REPORTS
How do I change the background and theme used in my form? You can change the background used in your form by opening your form in Design view and choosing a new style, as you will learn in the Chapter 13 task “Select a Style.”
If I decide not to save the form, what happens to my table data? Nothing. The form is just a way of presenting the table data. You can add or delete as many forms as you like; the data remains the same.
■ The Save As dialog box appears.
° Type the name of your new form in this space. · Click OK.
339
6048-4 ch11.F
10/19/99
2:19 PM
11
Page 340
CHAPTER 11: CREATE FORMS
CREATE A DATASHEET FORM USING AN AUTOFORM reating a datasheet AutoForm is your best choice when you want users to work with your datasheets but don’t want them to work with the tables. The main difference between working with a datasheet AutoForm and a table
C
⁄ Click the table to supply the structure and data for your form.
340
in Datasheet view is that your users can’t change the layout of your tables from the Form view of a datasheet AutoForm. As with the other wizards, Access walks you through the form creation process step by step. You can create the form
using the wizard’s default choices, revisit your choices using the Back button, and cancel the job at any time without saving your work.
¤ Click the New Object drop-down menu button.
■ The New Form window appears.
‹ Click Form.
› Click AutoForm: Datasheet.
■ The table or query your form is based on appears here. ˇ Click OK.
6048-4 ch11.F
10/19/99
2:19 PM
Page 341
II
■ Your form appears.
Á Click File. ‡ Click Save.
CREATE TABLES, FORMS, AND REPORTS
Can I change the appearance of my datasheet form? You can change the appearance of your datasheet form as with a normal datasheet. For specific instructions, refer to the appropriate tasks in Chapter 4.
Can I filter and sort the contents of my datasheet form? You can filter and sort the contents of your datasheet form by following the instructions in Chapter 5.
■ The Save As dialog box appears.
° Type the name of your new form in this space. · Click OK.
341
6048-4 ch11.F
10/19/99
2:19 PM
11
Page 342
CHAPTER 11: CREATE FORMS
CREATE A JUSTIFIED FORM USING THE FORM WIZARD
J
ustified AutoForms combine important properties of datasheet AutoForms and columnar AutoForms. One of the datasheet AutoForm’s major strengths is that it displays your data in the least possible space, although that compactness (and the presence of more than one record on a page) does make the
⁄ Click the table to supply the structure and data for your form.
data less readable. A columnar AutoForm, by contrast, presents one record per page, trading space for readability. A justified AutoForm compromises by displaying one record per page while arranging the fields in your form to occupy the least possible space.
The AutoForm Wizard walks you through the process of creating your justified AutoForm. You can change your mind at any time during the creation process and revisit your choices.
¤ Click the New Object drop-down menu button.
■ The New Form window appears.
‹ Click Form.
› Click Form Wizard.
■ The table or query your form is based on appears here. ˇ Click OK.
342
6048-4 ch11.F
10/19/99
2:19 PM
Page 343
II
■ The first Form Wizard screen appears.
CREATE TABLES, FORMS, AND REPORTS
How do I remove a field from the selected field list? You can remove a field from the selected field list by clicking the Remove Field button.
Can I remove all of the fields at one time? You can remove all of the fields from the selected field list by clicking the Remove All Fields button.
Á Click the Add All Fields button to include all of the fields from the selected table in the form.
■ The next Form Wizard screen appears.
° Click Justified. · Click Next.
‡ Click Next. CONTINUED
343
6048-4 ch11.F
10/19/99
2:19 PM
11
Page 344
CHAPTER 11: CREATE FORMS
CREATE A JUSTIFIED FORM USING THE FORM WIZARD CONTINUED
s with other forms, you can page through your table or query results by using the controls at the bottom of the page. These controls allow you to move to the next or previous record, to the first or last record, or to a specific record by entering its number.
A
■ The next Form Wizard screen appears. Note: You can choose a style for your form by clicking its name in the list. Your choice will be previewed in the left pane of the window.
344
In addition, Access allows you to define a sort order for the data in your form. You can use sorts to arrange your form information based on one or more fields. Sorts can be in either ascending or descending order. You might want to sort your form’s data in ascending order in
‚ Click Next.
a table with a Date field, such as a health club membership record. You could sort the table in ascending order to see which members joined the earliest and to track club membership growth over time.
■ The Checkered Flag screen appears.
— Type the name of your form in this space. ± Click Finish.
6048-4 ch11.F
10/19/99
2:19 PM
Page 345
II
■ Your form appears.
Á
Click the Close box to close your form.
CREATE TABLES, FORMS, AND REPORTS
When should I create a justified form? You should create a justified form when you need your form to fit in a limited area on the screen.
How do I change the appearance of my form? You can change the appearance of your form by following the instructions in Chapter 13.
■ Your form disappears.
345
6048-4 ch11.F
10/19/99
2:19 PM
11
Page 346
CHAPTER 11: CREATE FORMS
OPEN A FORM IN FORM VIEW ou can usually view your forms in Datasheet view, Design view, or Form view. The advantage of opening a form in Form view is that you can use the navigation bar at the bottom of the page to move
Y
⁄ Double-click the form you want to open.
346
through your records one record at a time or one page at a time, jump to the beginning or end of your table, or enter the number of a specific record and jump to it. You can also enter data into your table while in Form view.
Click the New Record button to tell Access you want to enter more records into your table.
■ Your form appears in Form view.
1
6048-4 ch11.F
10/19/99
2:19 PM
Page 347
11
CHAPTER 11: CREATE FORMS
II CREATE TABLES, FORMS, AND REPORTS
OPEN A FORM IN DESIGN VIEW hen you open a form, you can choose from Form view, Datasheet view, or Design view. Each view has its own set of advantages, though you can perform many of the same tasks in every view. Access’ Design view allows you to change your form’s appearance
W
⁄ Click the form you want to open.
and structure. For instance, you can change the position of objects on your form, change your form’s color scheme, or rearrange the fields in your form. You’ll learn more about working with forms in Chapter 13. You should view a form in Design view whenever you want
¤ Click Design.
to change that form’s underlying design. You can also open forms created by other users to determine how they achieved certain effects, and to learn new techniques.
■ Your form appears in Design view.
347
6048-4 ch11.F
10/19/99
2:19 PM
11
Page 348
CHAPTER 11: CREATE FORMS
CHANGE THE VIEW OF A FORM ou’re not limited to working with your forms in one view. Datasheet view, Design view, and Form view each have their own strengths, and you can switch between them at will. When you want to modify your form’s appearance, you should open your form in Design
Y
CHANGE TO DESIGN VIEW
⁄ Click the View drop-down menu button.
348
view. While you have your form open in Design view, you can change the appearance of the form by assigning it a theme, change the location of objects on your form, and add text to give data entry instructions or to add headlines to different sections of the form.
¤ Click Design view.
In Datasheet view, by contrast, you can work with your data using the techniques you learned in Chapter 4. For instance, you can move from record to record using the navigation bar, move rapidly through your data using the scroll bars, and sort or filter your form’s results.
■ The form appears in Design view.
6048-4 ch11.F
10/19/99
2:19 PM
Page 349
II
CHANGE TO DATASHEET VIEW
⁄ Click the View drop-down
¤ Click Datasheet view.
CREATE TABLES, FORMS, AND REPORTS
When should I work with my form in Form view? You should work with your form in Form view when you want to enter your data in something other than a bare-bones datasheet. For instance, you could put comments and instructions next to a field to make data entry easier.
When should I view my form in Datasheet view? You should work in Datasheet view when you need nothing more than a simple dataentry interface or would like to see more than one record on the screen at a time.
■ The form appears in Datasheet view.
menu button.
CONTINUED
349
6048-4 ch11.F
10/19/99
2:19 PM
11
Page 350
CHAPTER 11: CREATE FORMS
CHANGE THE VIEW OF A FORM CONTINUED hanging to Form view allows you to examine your records one at a time (in the case of a columnar form) or as a series of records on a page (in the case of tabular and datasheet forms). If you need to, you can create more than one
C
CHANGE TO FORM VIEW
⁄ Click the View drop-down menu button.
350
type of form based on the same collection of records. You can also enter data into your table while in Form view. You can click the New Record button to tell Access you want to enter more records into your table.
¤ Click Form view.
Change the view any time you want to look at your form from a different perspective or work with your form in a way that is easier (or possible) than in another view.
■ The form appears in Form view.
1
6048-4 ch11.F
10/19/99
2:19 PM
Page 351
11
CHAPTER 11: CREATE FORMS
II CREATE TABLES, FORMS, AND REPORTS
CLOSE A FORM f you’re done working with a form, you should close it to conserve your computer’s memory. Most systems won’t have any trouble keeping track of your information, but if you’re running more than one program
I
⁄ Click the Close box.
at a time (or have a lot of database objects open), you could run into memory problems. Also, when you close unneeded forms, Windows can redraw your screen more quickly
Note: If Access asks you if you want to save the form, click Yes and follow the instructions in task “Save a Form,” presented elsewhere in this chapter.
when you make changes. Rather than needing to redraw more than one program window to update your screen, Windows can simply redraw a single window and move on to other tasks.
■ The form disappears.
351
6048-4 ch11.F
10/19/99
2:19 PM
11
Page 352
CHAPTER 11: CREATE FORMS
MOVE FORWARD OR BACK ONE RECORD hen you open a form, you can move through your records one at a time or page by page. Stepping through your records one at a time allows you to examine the data visually for duplications, mistakes, and consistency.
W
MOVE FORWARD ONE RECORD
⁄ Click the Forward button.
352
Access lets you use a variety of methods to move within your tables. You can use the navigation bar at the bottom of the window, use the mouse to activate controls or place your insertion point, or use the keyboard to move from control to control.
When you display your form in Form view, the active record appears on the screen and the insertion point (represented by a blinking cursor) indicates where data entry will take place.
■ The next record appears.
6048-4 ch11.F
10/19/99
2:19 PM
Page 353
II
MOVE BACK ONE RECORD
⁄ Click the Back button.
CREATE TABLES, FORMS, AND REPORTS
Is there a keyboard shortcut for moving back one field? You can use the key combination Shift+Tab to move to back one field in your table.
How do I scroll up and down my list of records? You can use the PgUp and PgDn keys to scroll through your records one page at a time.
■ The previous record appears.
353
6048-4 ch11.F
10/19/99
2:19 PM
11
Page 354
CHAPTER 11: CREATE FORMS
MOVE TO THE FIRST OR LAST RECORD
t’s easy to move up or down one record at a time in your database, but Access also makes it simple for you to move to the first or last record of your table with a single click of the mouse.
I
MOVE TO THE FIRST RECORD
⁄ Click the First Record button.
354
One quick way to move to the first or last record in your table is to use the controls at the bottom of the active window. The controls there include buttons that will move you to the next record, the previous record, or
the first or last record in the table. You can also add a new record at any time by clicking the New Record button on the navigation bar.
■ The first record appears.
6048-4 ch11.F
10/19/99
2:19 PM
Page 355
II CREATE TABLES, FORMS, AND REPORTS
Is there a keyboard shortcut for moving to the first field of the first record? You can move to the first field of the first record by pressing Ctrl+Home.
How do I move to the last field of the last record? You can move to the last field of the last record by pressing Ctrl+End.
MOVE TO THE LAST RECORD
⁄ Click the Last Record button.
■ The last record appears.
355
6048-4 ch11.F
10/19/99
2:19 PM
11
Page 356
CHAPTER 11: CREATE FORMS
MOVE TO A SPECIFIC RECORD
ccess allows you to move to specific records in your table. If you know the number of the record you want to move to, you can type it in the text area on the control bar at the bottom of the form and press Enter.
A
⁄ Type the number of the record you want to display in this space.
356
You can find out the number of a particular record in several ways. One way is to print out the contents of the form’s records and use the information from the printout to find the record you want to view. You could also derive the number of a record if
¤ Press Enter.
your records are identified by an AutoNumber key field. The value in the AutoNumber field, if numbering is begun from 1, will correspond to the number of the record in the table.
■ The record you requested appears.
1
6048-4 ch11.F
10/19/99
2:19 PM
Page 357
II CREATE TABLES, FORMS, AND REPORTS
11
CHAPTER 11: CREATE FORMS
ADD A RECORD ne of the most commonly used functions in Access is data entry. You can enter new data into the table supplying data for your form when you have your form open in either Datasheet or Form view.
O
⁄ Click the New Record button.
You can have Access provide you a blank record to enter data into by clicking the New Record button on the navigation bar at the bottom of the active window, or by positioning the insertion point in the last field of the last
record in the form and pressing either the Tab or Enter key. When you move to the next field from the last field of the last record in your form, Access automatically creates a new record.
■ A blank record appears.
¤ Type your information, as you will learn in task “Edit Data,” presented later in this chapter.
357
6048-4 ch11.F
10/19/99
2:19 PM
11
Page 358
CHAPTER 11: CREATE FORMS
DELETE A RECORD
ccess makes it easy for you to delete unneeded records from your table. You can delete records in a Datasheet form by selecting the entire row and pressing the Delete key. You can also use the Backspace key.
A
⁄ Display the record you want to delete.
358
If you like, you can also delete a record by clicking the Edit menu. Once the Edit menu is open, click Delete Record. You should delete a record from your table any time the item the record refers to is no longer needed in your table. Retaining
¤ Click Delete Record.
information about unneeded objects takes up unnecessary space and could slow performance. It is a good idea to back up your tables before deleting a large number of records, however, so you can recall that information if needed.
■ The Confirmation dialog box appears.
‹ Click Yes.
6048-4 ch11.F
10/19/99
2:20 PM
Page 359
II
■ The record disappears.
› Click the Close box.
CREATE TABLES, FORMS, AND REPORTS
Is there a keyboard shortcut for moving to the first field of the first record? You can move to the first field of the first record by pressing Ctrl+Home.
How do I move to the last field of the last record? You can move to the last field of the last record by pressing Ctrl+End.
■ The form disappears.
359
6048-4 ch11.F
10/19/99
2:20 PM
11
Page 360
1
CHAPTER 11: CREATE FORMS
ENTER DATA INTO AN EMPTY CELL
ccess gives you the ability to edit data anywhere in your form while viewing it in either Datasheet or Form view. You can click directly into a cell to edit the data using standard keyboard techniques. You can use all of the dataand text-editing techniques that
A
⁄ Click the cell you want to enter your data into.
360
are possible in other Windows applications. For instance, you can highlight a bit of text and press the Delete key to erase the text. You can also highlight a selection of text and begin typing your replacement text. Access will substitute the text you type for the text you had highlighted.
You can also correct spelling and insert words by clicking at the end of or within a text string and typing the text you want to add.
■ The insertion point appears in the cell.
¤ Type your data in the cell.
6048-4 ch11.F
10/19/99
2:20 PM
Page 361
II CREATE TABLES, FORMS, AND REPORTS
11
CHAPTER 11: CREATE FORMS
REPLACE CELL DATA
ccess allows you to work with the data in your form, regardless of whether you are working with the form in Datasheet or Form view. As with other Windows applications, you can use the standard editing techniques to work with your data. For
A
⁄ Select the data you want to replace.
instance, you can select data you want to move from one record to another, open the Edit menu, click Cut, position the insertion point in the field where you want the data to appear, open the Edit menu, and click Paste. You can often undo your change by clicking the Edit menu
and selecting Undo Typing. By clicking Undo Typing, Access will reverse your changes and replace your new data with the original information.
■ The cell’s contents appear in reverse video. ¤ Type the new information.
Note: When you begin typing, the highlighted text will disappear and be replaced by your new information.
361
6048-4 ch11.F
10/19/99
2:20 PM
11
Page 362
CHAPTER 11: CREATE FORMS
ENTER DATA IN A LOOKUP FIELD
ccess allows you to include a list of values users may choose from when entering data in a field. Establishing a lookup column is another way to make data entry easier and reduce spelling mistakes.
A
⁄ Click the drop-down menu button in the cell with the lookup field.
362
You can have Access draw the values for your lookup column from an existing field or you can enter them yourself. To enter data in a lookup field, you click the drop-down menu button in the field. The possible values for the field appear in a
¤ Click the value you want to enter in the field.
drop-down menu. You can enter your own values into the field, but entering data with a lookup field is the easiest option for hard-to-remember data elements such as state abbreviations, product codes, or departments.
■ The value appears in the field.
1
6048-4 ch11.F
10/19/99
2:20 PM
Page 363
II CREATE TABLES, FORMS, AND REPORTS
11
CHAPTER 11: CREATE FORMS
MOVE TO THE NEXT FIELD oving between fields is simple. One easy way to move to the next field in a form is to click the mouse pointer in the field. The cursor will appear in the field you selected.
M
⁄ Press Tab.
You can also move from field to field using the keyboard. To move to the next field in a form, press the Tab key. The contents of the next field are highlighted; when you start entering your new information, the former
contents of the field are replaced immediately. If you want to move to the next record in your table while in Form view, you should press the PgDn key.
■ The next field activates.
363
6048-4 ch11.F
10/19/99
2:20 PM
11
Page 364
CHAPTER 11: CREATE FORMS
MOVE TO THE PREVIOUS FIELD hen you enter data into forms, you won’t always enter the data into the fields in the order they appear on the form. Fortunately, moving from field to field is quite simple. You can use the keyboard to move to the next field in your
W
⁄ Press Shift + Tab.
364
form by pressing Tab. To move to the previous field, press Shift+Tab. When you move to the next (or previous) field using the keyboard, Access automatically highlights the data in the field you moved to. While viewing your form in Form view, you can move to the previous record by pressing the
PgUp key. If the insertion point is in the first field in your record, pressing Shift+Tab will also display the previous record.
■ The previous field activates.
1
6048-4 ch11.F
10/19/99
Page 365
CHAPTER 11: CREATE FORMS
II CREATE TABLES, FORMS, AND REPORTS
11
2:20 PM
SAVE A FORM hen you create a form, you should make sure you save your work frequently. Whenever you make a change you wouldn’t want to make again, save your work. If you’re not sure if the change you made should be permanent, you can always save your form under another name so you have two versions of it . . . one with the
W
⁄ Click File.
change and one without. You can name your form as you would any other Access object. The form name can be up to 255 characters long and can include spaces. Remember that you can include information about the form in its name, though you shouldn’t go overboard. Shorter names are easier to understand.
¤ Click Save.
One restriction in naming your forms is that the name must be unique in your database. If you have a query saved under the name you want to use, for instance, you’ll need to pick a new name for either the form or the query.
■ Access writes your form to disk.
365
6048-4 ch11.F
10/19/99
2:20 PM
11
Page 366
CHAPTER 11: CREATE FORMS
RENAME A FORM very object in your database must have a unique name. If you want to save an object under a name you’ve already used, you’ll need to change the older object’s name. Name conflicts aren’t the only time you could rename your forms. If you create a form based on a table and the structure of
E
⁄ Right-click the form you want to rename.
366
that table changes, you should save the form based on the old structure under a different name (for example, if you change the structure of a table named “Customers,” you could rename the old form “Customers Old”). Another time you could rename a form is if you combine more than one form into a single object. For instance, if you
¤ Click Rename.
created an Employees form and a Sales form, you could combine the two into a single form and rename the old ones. If you were certain you weren’t going to use those forms in your active database, you could back up your files and delete the old forms from the working database.
■ The form's name appears in reverse video.
‹ Type the new name of your form.
1
6048-4 ch11.F
10/19/99
2:20 PM
Page 367
11
CHAPTER 11: CREATE FORMS
II CREATE TABLES, FORMS, AND REPORTS
DELETE A FORM nce you’re certain you don’t need a form in your active database, you can delete it. Access makes certain you want to delete the form before erasing your object permanently, so you will have a
O
⁄ Click the form you want to delete.
chance to change your mind before your object disappears forever. Keep in mind that you should always back up your work, and you should delete any database objects you aren’t actively using
¤ Click Delete.
in your database. Older versions of forms, forms based on tables that don’t exist any more, and forms based on tables that have been changed are all candidates for deletion.
■ The form disappears.
Note: If Access asks if you are sure you want to delete the form, click Yes.
367
6048-4 ch12.F
10/19/99
2:22 PM
Page 368
12
CHAPTER 12: CREATE REPORTS CREATE TABLES, FORMS,AND REPORTS
2 CHAPTER 12: CREATE REPORTS
CREATE REPORTS
ccess gives you the ability to display the contents of your tables or queries in an easy-to-read, customizable format. These formats, called reports, show the information in your table or query in a manner you describe. The easiest way to create a report is to use one of the report wizards. These wizards step you
A
through the report creation process, allowing you to choose the type of report you want to create, the layout for the report, and any data summaries you’d like to include in your report. You can also create reports from scratch. For information on how to create reports from scratch, see Chapter 13.
Create an AutoReport–
Create a Tabular AutoReport–
When you settle on the table or query results you want to present in a report, you can make the report as complex or simple as you like. Before you create a custom report, however, it might be worth the time to create a simple report to get an idea of how the information fits together on a page. The quickest way to create a simple report is with the AutoReport Wizard. Once you’ve studied your AutoReport and have moved through your data using the report’s navigation controls, you can modify the AutoReport or create an entirely new report from scratch or by using the Report Wizard.
368
Like its cousin the tabular AutoForm, a tabular AutoReport presents table data or query results in a compact, horizontally oriented format. While tabular AutoReports aren’t as compact as datasheets, they do present data on a single line and fit more than one record on a page. Tabular AutoReports are easier to read than datasheets, so the extra space is put to good use. As with other Access database objects, you use a wizard to create a tabular AutoReport. You can pick the query and table fields to include in your report and have Access generate the AutoReport automatically.
6048-4 ch12.F
10/19/99
2:22 PM
Page 369
Create a Columnar AutoReport–
Create a Report Using the Report Wizard– If you want to use a wizard to create a report but don’t want to create one of the AutoReports, you can create a basic report using the Report Wizard. The Report Wizard places your fields on the page in the order you set inside the wizard. Once the fields are on the page, you can reposition, resize, and delete them as necessary. For more information on customizing your reports, see Chapter 13. As with the other Access wizards, you can pick the sources for your information, choose a format for the report from the numerous AutoFormats available, and sort the records in your report based on the values in one or more fields.
A
II CREATE TABLES, FORMS, AND REPORTS
If you’d rather emphasize the data in each record of your table or query results, you can create a columnar AutoReport to display your data. Unlike a tabular AutoReport, which is horizontally oriented and presents more than one record per page, columnar AutoReports display exactly one record per page and are vertically oriented, just like the columnar form. The report has two columns: one for the field names and the other for the field data.
Change from Design View to Print Preview– You can open your reports in a variety of views. When you create a report, you get the option to preview your report’s output or change your report’s design. When you open your report in Design view, you can change your report’s layout, captions, fields, and other elements. When you preview your report’s results, Access opens your report in Print Preview mode. While in Print Preview, you can view your report in a variety of ways. You can zoom in on specific parts of your report, zoom out to see how your report’s layout works as a whole, and print your report. You might want to preview what your information will look like when it is printed for a number of reasons. One good reason is to make sure your information fits neatly on the page, rather than spilling one or two columns onto another page. Another is to ensure that your columns are wide enough so that your records print properly, rather than wrapping text awkwardly or hiding some text beyond a cell’s border.
or
35 40 60 42 22 35
Z 39
369
6048-4 ch12.F
10/19/99
2:22 PM
Page 370
12
CHAPTER 12: CREATE REPORTS
CREATE AN AUTOREPORT
ccess databases can consist of objects that make it easy to store, edit, find, and display the data they contain. Access uses reports to display your data — the simplest reports, which you can create with a few mouse clicks and some typing, are called AutoReports.
A
⁄ Click the table your report will be based on.
You can use AutoReports to quickly display the contents of your tables or the results of your queries. The basic AutoReport appears without a background, uses the standard colors for objects on your system, and uses plain formatting to communicate your information.
¤ Click the New Object drop-down menu button on the toolbar. ‹ Click AutoReport.
370
You can move around in your AutoReport like any other Access report. The navigation bar at the bottom of the report’s pages allows you to page through your records, jump to the beginning or end of the report, or display a specific record.
■ Your AutoReport appears in Print Preview mode.
› Click Close.
6048-4 ch12.F
10/19/99
2:22 PM
Page 371
II
■ The Design view of your AutoReport appears. ˇ Click the Close box to close your AutoReport.
Note: If Access asks if you want to save your report, click Yes and follow the directions in task “Save a Report,” presented later in this chapter.
CREATE TABLES, FORMS, AND REPORTS
How do I zoom in on a specific part of my report in Print Preview mode? You can tell Access you want to zoom in on a specific part of your report by clicking the Magnifying Glass icon on the toolbar and clicking on the part of the report you want to see in more detail.
Can I print my report directly from Print Preview mode? You can print your report in Print Preview mode by clicking the Print icon on the toolbar.
■ Your report disappears.
371
1
6048-4 ch12.F
10/19/99
2:22 PM
Page 372
12
CHAPTER 12: CREATE REPORTS
CREATE A TABULAR AUTOREPORT
utoReports (preformatted reports generated by wizards) are handy tools for presenting your table data and query results efficiently. Tabular AutoReports, as the name implies, are structured very much like tables — they present your information as a set of records on a page. You can look
A
⁄ Click the table your report will be based on.
at quite a few of your records simultaneously to compare values. If you sorted or filtered the records in the table used to create the AutoReport, the records in your report will appear next to related records. Just as when you create most other database objects, Access walks you through creating an
¤ Click the New Object drop-down menu button on the toolbar. ‹ Click Report.
372
AutoReport with the AutoReport Wizard. You can pick the source for your report, determine which fields you want to appear from the query or table you use as the base, and choose how to display the information in your AutoReport.
■ The New Report window appears. › Click AutoReport: Tabular.
■ The table your AutoReport will be based on appears here. ˇ Click OK.
6048-4 ch12.F
10/19/99
2:23 PM
Page 373
II
■ Your AutoReport appears in Print Preview mode. Á Click the Close box to close your report.
Note: If Access asks if you want to save your report, click Yes and follow the directions in task “Save a Report,” presented later in this chapter.
CREATE TABLES, FORMS, AND REPORTS
I clicked the wrong table to use in my report. How do I change it from within the wizard? You can change the table to use in your report by clicking the drop-down menu button next to the space where your table name appears and choosing a new table.
How do I get help on using the AutoReport Wizard from within the wizard? You can get help using the AutoReport Wizard by clicking the question mark on the title bar of the Wizard window.
■ Your report disappears.
373
1
6048-4 ch12.F
10/19/99
2:23 PM
Page 374
12
CHAPTER 12: CREATE REPORTS
CREATE A COLUMNAR AUTOREPORT ou can choose from a number of report styles when you create an AutoReport. The tabular AutoReport presents your data in table form, with multiple records on the same page. Columnar AutoReports, by contrast, present every record on a separate page. Whereas tabular AutoReports emphasize presenting as much
Y
⁄ Click the table your report will be based on.
information as concisely as possible, columnar AutoReports display the contents of each record without worrying about conserving space. Whereas tabular AutoReports require the user to move through the cells to see the entire contents of a field, columnar AutoReports display each field’s contents in their entirety.
¤ Click the New Object drop-down menu button on the toolbar. ‹ Click Report.
374
Creating a columnar AutoReport is simple — the AutoReport Wizard walks you through the process step by step. You can choose the tables or queries to draw information from and establish the order of the fields in the report.
■ The New Report window appears. › Click AutoReport: Columnar.
■ The table your AutoReport will be based on appears here. ˇ Click OK.
6048-4 ch12.F
10/19/99
2:23 PM
Page 375
II
■ Your AutoReport appears in Print Preview mode. Á Click the Close box to close your report.
Note: If Access asks if you want to save your report, click Yes and follow the directions in “task Save a Report,” presented later in this chapter.
CREATE TABLES, FORMS, AND REPORTS
Can I change the background and theme used in my AutoReport? You can change the background used in your report by opening your report in Design view and following the instructions in the Chapter 13 task “Select a Style.”
How do I exit the wizard without saving my AutoReport? You can exit the wizard without saving your work at any time by clicking the Cancel button.
■ Your report disappears.
375
6048-4 ch12.F
10/19/99
2:23 PM
Page 376
12
CHAPTER 12: CREATE REPORTS
CREATE A REPORT USING THE REPORT WIZARD
utoReports are quick and easy ways to present the information in your tables and query results, but they may not always be appropriate for your needs. For instance, you might want to include a theme or background image or change how Access groups the records in your report. Access allows you to create more complicated reports using
A
⁄ Click the table that will supply the data for your report.
the Report Wizard. The Report Wizard steps you through the report creation process, allowing you to pick the tables and queries to draw information from, set the order those fields will appear in, and choose how Access will group information in the report. A real strength of the Report Wizard is that it allows you to create reports based on
information from more than one table or query at a time. Once you’ve created your report with the Report Wizard, you can customize it by adding or changing grouping levels, adding graphics, and modifying the color scheme. To learn how to customize your report, see Chapter 13.
¤ Click the New Object drop-down menu button.
■ The New Report window appears.
‹ Click Report.
› Click Report Wizard.
■ The name of the table or query you selected appears here. ˇ Click OK.
376
6048-4 ch12.F
10/19/99
2:23 PM
Page 377
II
■ The next screen of the Report Wizard appears. Á Click the name of the first field you want to add to your report.
‡ Click the Add button to add the field.
CREATE TABLES, FORMS, AND REPORTS
How do I choose which table or query I want to pick fields from for my report? You can choose which table or query to pick fields from by clicking the drop-down menu button in the Tables/Queries text area.
How do I add all of the fields from a table or query to my report? To add all of the fields from a table or query, click the Add all Fields button.
■ The field appears in the Selected Fields pane.
Note: Repeat steps 6 and 7 to add any other fields you want to appear in your report.
° Click Next. CONTINUED
377
6048-4 ch12.F
10/19/99
2:23 PM
Page 378
12
CHAPTER 12: CREATE REPORTS
CREATE A REPORT USING THE REPORT WIZARD CONTINUED hen you create your report, you can tell Access how you want to group the information. Much like the grouping functions in a query, covered in Chapter 10, you can choose which field will supply the values that Access will use to organize your results.
W
■ The next Report Wizard screen appears. · Click the field you want to use as your primary grouping field.
378
You can organize your report information by multiple criteria, making it easier to read your reports. By grouping the information, you can highlight the elements you want to stand out. Access illustrates how your report will look by giving you a
‚ Click the Add button to add the field.
visual representation of the groupings you choose. Access takes the field names you want to use to group your information and arranges them in a dynamic outline that you can change at any time.
■ The field appears as a grouping field in the right pane.
— Click Grouping Options.
6048-4 ch12.F
10/19/99
2:23 PM
Page 379
II
■ The Grouping Options screen appears.
¡ Click the grouping option
± Click the drop-down menu button.
Note: The menu that Access displays depends on the data type of the field used to group data in your report.
you want for your field.
™ Click OK.
CREATE TABLES, FORMS, AND REPORTS
How do I change the priority level of a grouping field? You can change the priority level of a grouping field by clicking the field and clicking the up arrow or the down arrow.
How do I remove a field from the grouping window? You can remove a field from the Grouping window by clicking the Remove Field button.
■ The Grouping Options window disappears.
£ Click Next.
CONTINUED
379
6048-4 ch12.F
10/19/99
2:23 PM
Page 380
12
CHAPTER 12: CREATE REPORTS
CREATE A REPORT USING THE REPORT WIZARD CONTINUED ou can use sorts to arrange your report information based on one or more fields. Sorts can be in either ascending or descending order. You might want to sort data in ascending order in a table with a Date field, such as a
Y
health club membership record. You could sort the table in ascending order to see which members joined the earliest and to track club membership growth over time. Sorting in descending order might be used for similar
■ The next Report Wizard screen appears.
Click the field you want to use as your primary sort key.
Click the drop-down menu button.
Note: You can repeat steps 16 and 17 to assign other sort keys.
¢
380
° Click Summary Options.
purposes. You could track which members visit a club by noting when each member attends the club. By sorting the Date field in descending order, you could get a feel for how recent attendance has fluctuated.
■ The Summary Options window appears.
¤
Click a check box to set the summary option for a field.
¦ Click OK.
6048-4 ch12.F
10/19/99
2:23 PM
Page 381
II
■ The Summary Options window disappears.
¥ Click Next.
CREATE TABLES, FORMS, AND REPORTS
How can I get progressive sums for the values in a field? You can have Access display the progressive sum of for the values in a field by clicking the “Calculate percent of total for sums” check box.
Can I use more than one summary option for a field? You can select one, some, or all of the summary options available in the Summary Options window.
■ The next Report Wizard screen appears.
»
Click a radio button in this area to choose a Layout. Note: Your choice will be reflected in the left pane.
¼
Click a radio button in this area to choose Landscape or Portrait orientation for the page.
Ð Click Next.
CONTINUED
381
6048-4 ch12.F
10/19/99
2:23 PM
Page 382
12
CHAPTER 12: CREATE REPORTS
CREATE A REPORT USING THE REPORT WIZARD CONTINUED n addition to using reports to display the data in your tables and queries, Access also allows you to summarize the values contained in particular fields. You can include as many summary fields as you like.
I
■ The next Report Window appears.
Access is able to summarize your data in several ways, including finding the sum of the values in a field; identifying the minimum, maximum, first, or last value in the field; or calculating the variance or
Note: Your choice will be reflected in the left pane.
Click a style from this list. Ô Click Next.
382
standard deviation of the values in the field. Each of these functions is explained in the introduction to this chapter.
■ The Checkered Flag screen appears. Type a name for your report in this space.
Click Finish.
6048-4 ch12.F
10/19/99
2:23 PM
Page 383
II
■ Your report appears.
Click the Close box to close your report.
CREATE TABLES, FORMS, AND REPORTS
How do I exit the Report Wizard without saving any of my changes? You can exit the Report Wizard and not save any of your work by clicking the Cancel button on the bottom of any of the wizard’s screens.
How do I accept the default values for my report and have Access create it right away? You can have Access create your report at any time by clicking the Finish button at the bottom of any of the wizard’s screens.
■ Your report disappears.
383
6048-4 ch12.F
10/19/99
2:23 PM
Page 384
12
CHAPTER 12: CREATE REPORTS
CHANGE FROM DESIGN VIEW TO PRINT PREVIEW
s with the other objects in your database, Access allows you to view your information in a variety of ways. When you create a report, you can view it in Design or Print Preview mode. Opening a report in Design view gives you the same abilities as when you open other database objects in Design view. You can
A
⁄ Click View.
384
add or delete fields, change how your report’s fields are arranged, add captions, include graphics, and pick (or modify) your report’s theme or background image. Print Preview mode, by comparison, lets you see how your report will look when you print it. Opening your report in Print Preview mode lets you
¤ Click Print Preview.
make sure your information appears neatly on the page, without one or two lines per record running over to the next page and wasting space (and paper). You can also see if you need to enlarge the text boxes that display your report’s contents so the field’s entire contents will be displayed, rather than being cut off on the page.
■ Your report opens in Print Preview.
1
6048-4 ch12.F
10/19/99
2:23 PM
Page 385
II CREATE TABLES, FORMS, AND REPORTS
12
CHAPTER 12: CREATE REPORTS
CHANGE FROM PRINT PREVIEW TO DESIGN VIEW ne of Access’ strengths is how the differing views available for each object type complement each other. In Design view, you’re able to change the structure and appearance of your report. You can change the arrangement of your fields, assign a background
O
⁄ Click View.
for the report, and create labels to take the place of your field names. You’ll learn more about working with your reports in Design view in Chapter 13. Once you’ve made your changes in Design view, you will probably want to see how the modified report will look when
¤ Click Design view.
you print it. The easiest way to do that is to open your report in Print Preview mode. It’s easy to switch between views once you’ve opened your report. You can use the menu system or click the View toolbar button to change among the views available to you.
■ Your report opens in Design view.
385
6048-4 ch12.F
10/19/99
2:23 PM
Page 386
12
1
CHAPTER 12: CREATE REPORTS
SAVE A REPORT
here is one universal truth in working on a computer: whenever you’ve done something you’d hate to do again, save your document. Most tasks are best done once, so you should save your work frequently. Saving every five minutes is one rule of thumb, but you can’t go wrong saving every time you
T
⁄ Click File.
pause to think about what to do next. Reports are subject to the same naming conventions as other objects in your database. Each report’s name can be up to 255 characters in length, can include spaces, and cannot have the same name as your database or any object within it. If you try
¤ Click Save.
to give your report a name that already exists in your database, Access will display a dialog box informing you of the error and require you to enter another name. If you prefer to use the keyboard to save your reports, you can type Ctrl-S at any time to save your work.
■ The Save As dialog box appears.
‹ Type the name of your report here. › Click OK. Note: Access saves your report.
386
6048-4 ch12.F
10/19/99
2:23 PM
Page 387
II CREATE TABLES, FORMS, AND REPORTS
12
CHAPTER 12: CREATE REPORTS
SAVE A REPORT UNDER ANOTHER NAME ometimes you may want to create two reports that are almost alike, but different in some important respects. Rather than duplicate your efforts and create a second report
S
⁄ Click File.
from scratch, you can re-use your work on the first report. The first report becomes a template you use to create the second one.
¤ Click Save As.
Just like in most other Windows program, you save a file under a different name by using the Save As command in the File menu.
■ The Save As dialog box appears.
‹ Type the new name for your report in this space. › Click OK.
387
6048-4 ch12.F
10/19/99
2:23 PM
Page 388
12
CHAPTER 12: CREATE REPORTS
OPEN A REPORT hen you want to work with a report, you can choose to open it in Design view or Print Preview. As you learned earlier in this chapter, you can switch between the views whenever you want.
W
⁄ Click the report you want to open.
388
Depending on your computer system’s memory, you can have as many reports (and other database objects) open at a time as you need. If you want to use the same design in your forms and reports and have already created a form of
¤ Click Preview. Note: To open a report in Design view, click the Design button on the Access toolbar.
the style you want, you can open the form and the report in Design view simultaneously, copy graphics from one window to another, and arrange the windows (as you learned to do in Chapter 1) so you can see both windows clearly.
■ The report opens.
1
6048-4 ch12.F
10/19/99
2:23 PM
Page 389
II CREATE TABLES, FORMS, AND REPORTS
12
CHAPTER 12: CREATE REPORTS
CLOSE A REPORT hen you work with printed documents, it’s a good idea to file (or reshelve) the ones you’re not using to keep the clutter on your desk to a minimum. The same
W
⁄ Click the Close box.
principle applies to files on your computer desktop. Having more reports open than you need can make it harder for you to find the object you want to work with. Closing
unneeded reports also frees up system resources, allowing your computer to redraw your screen, save your work, and print more quickly.
■ Your report disappears.
389
6048-4 ch12.F
10/19/99
2:23 PM
Page 390
12
CHAPTER 12: CREATE REPORTS
RENAME A REPORT
s you update your database, you’ll modify your objects fairly often. When you modify the table or query supplying the data for a report, it makes sense to change the name of the table or query as well as the name of the report. If you created a report to track sales to a particular customer
A
⁄ Right-click on the report you would like to rename.
390
and that customer changed their company’s name, it would probably be a good idea to change the name of the objects associated with that company. You might want to keep the original objects on hand for a while, but they should eventually be deleted.
¤ Click Rename.
You could also rename a report to add more information to its title. If you kept more than one version of a report and wanted to identify the version a particular user was to work with, you could add that user’s name or user ID to the report’s name.
‹ Type the new name for your report in this space.
1
6048-4 ch12.F
10/19/99
2:23 PM
Page 391
II CREATE TABLES, FORMS, AND REPORTS
12
CHAPTER 12: CREATE REPORTS
DELETE A REPORT eleting reports in Access is a straightforward process — you simply click the report you want to delete and click the Delete toolbar button. Access displays a dialog box asking if you’re sure
D
⁄ Click the report you would like to delete. ¤ Click Delete.
you want to delete the report, so you will have a chance to change your mind. Sometimes deleting a report won’t be the best option. Instead of getting rid of the report permanently, you might consider
Note: If Access asks you if you are sure you want to delete the report, click Yes.
renaming it so you’ll have a copy in the database while guarding against users mistakenly using it instead of the current version.
■ The report disappears.
391
6048-4 ch13.F
10/19/99
2:25 PM
Page 392
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS CREATE TABLES, FORMS,AND REPORTS
2
CUSTOMIZE FORMS AND REPORTS
O
nce you’ve created your form or report, you can change its look and functionality in a wide variety of ways. This chapter covers
Use an Autoformat–
many of the tools you can use to modify your document’s appearance and allow the user to get the most out of your data. Create List and Combo Boxes–
Creating a unique look for your forms and reports is easy to do, but if you want to change more than one form in your database, applying your designs to each control on your forms can take quite a bit of time. Rather than require you to create and apply your formats by hand, Access comes with a variety of prefabricated autoformats you can use. The autoformats included with Access offer a variety of looks, from designs favoring maroon and other reddish colors to more muted designs that include grays and light yellows. You can change your mind as often as you like and assign a new autoformat to a form or report at any time. If you’ve come up with a design of your own that you like and want to apply to objects in your database, you can save the design of your form or report as an autoformat and automatically apply it to other forms and reports.
Data entry is a time-consuming business, especially when your users need to enter lots of data at one time. Your forms should make that task as easy as possible. List boxes and combo boxes are two key tools at your disposal that help facilitate data entry. A list box presents your users with a list of values from one or more fields in one of your database’s tables or queries. Rather than enter the values by hand, you can reduce spelling errors, ensure values entered come from a predetermined group, and make sure your users don’t have to refer to documents outside your database by presenting them with a fixed list of choices. A combo box is a bit more flexible than a list box; it presents users with a list of values but doesn’t require them to enter values from that list. The combo box is a great choice if the values for a field will usually, but not exclusively, come from a certain range.
Form
Alberta New York Oregon Virginia
392
6048-4 ch13.F
10/19/99
2:25 PM
Page 393
Create an Option Group–
II CREATE TABLES, FORMS, AND REPORTS
Sometimes, when your users are entering data, you want them to make one choice from a group of options; for example, if they are fulltime, temporary, or part-time employees. That’s where the option group comes in. With an option group, each item in the group has a check box in front of it, but the user can only select the check box for one item at a time. Like most of the other controls you can add to a form, option groups can be created with the help of a wizard. The wizard lets you choose the type of control you want for your option group (check box, toggle button, or option button), name each of the options in the group, and pick a look for the controls.
Image frames (the control that contains the image) can also be used to display images stored in your tables. For instance, if you maintain an inventory of auto parts and need to display the parts so your clerks and repair personnel can verify they have ordered and installed the proper item, you can include a digital image of each part on your form. Sales 1995 $1 mil 1996 $3 mil 1997 $5 mil
Create a Tab Control–
Contractor Temporary Salaried
Insert Images and Other Objects– When you create a form or report, you can use a wide variety of text styles, fonts, and sizes to make it more appealing, easier to read, and simpler to use. You can also add images to your forms and reports for identification purposes, such as including your company or departmental logo at the top or bottom of every page in the form or report.
You first encountered tab controls in the “Getting Help” tasks of Chapter 1. Tab controls contain pages of information that you can get at by clicking the appropriate tab at the top of the control. Like cards in an index file separated by alphabetical or topic dividers, the pages displayed by clicking those tabs contain information related to the tab. In the case of a sales tracking database, you might create separate tab pages containing queries, forms, and reports relating to employees, sales, and database administration. Tab controls are extremely useful items; rather than forcing you to use a lot of space on your form to fit a number of controls on a single page, you can divide the controls among a number of pages and keep your form’s design uncluttered.
CONTINUED
393
6048-4 ch13.F
10/19/99
2:25 PM
Page 394
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CUSTOMIZE FORMS AND REPORTS CONTINUED
Once you’ve created your form, you can change the order of its pages, add pictures to the tabs themselves or to the pages, and change the control’s appearance. Print
Save
Copy
Print
For example, if you wanted to set off an area of your form where only certain users would be able to enter information (as an equivalent to the “For Official Use Only” sections on paper forms), you could put those controls in front of a gray background with a text label noting which users were responsible for entering data into those controls.
To
Pages
Contacts OK
Cancel
Name Company
Add Lines and Rectangles to Your Forms and Reports–
Address Phone
Images can make a big difference in making your forms and reports more attractive and in providing lots of information to your users. You’re not limited to using premade images, however — you can add your own lines and boxes to your forms.
394
Notes
6048-4 ch13.F
10/19/99
2:25 PM
Page 395
Align Controls–
II CREATE TABLES, FORMS, AND REPORTS
While you’re working with your report in Design view, you can use the vertical and horizontal rulers Access displays to make sure your controls are evenly spaced and lined up along the appropriate edge. You can use features such as displaying the grid (and Snap to Grid) to make your job easier. If you’d rather not align your controls by hand, you can have Access automatically align any controls you want. All you need to do is select the controls you want to align and choose which edge you’d like to align them along.
You can also have Access space your controls evenly on the form, whether horizontally or vertically. If the spacing isn’t to your liking, you can increase it or decrease it by choosing the appropriate menu item.
395
6048-4 ch13.F
10/19/99
2:25 PM
Page 396
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
SELECT AN AUTOFORMAT hen you create a form using a wizard, you can choose from a number of predetermined formats to enhance your document’s appearance. If you didn’t choose an autoformat when you created your form, or if you want to change the one it uses, you can do so while you have your form or report open in Design view.
W
⁄ Open the form you want to apply an autoformat to in Design view, as you learned to do in the Chapter 11 task “Open a Form in Design View.” Note: In this case, we opened the Products form.
396
The default autoformats present a number of different images, from the standard Access (and Windows) screens (blue title bars, gray backgrounds, and black text on a white background) to more eye-catching schemes with brighter colors. You don’t have to accept an autoformat as a whole, though. If you want, you can pick which elements of the autoformat
¤ Click Format. ‹ Click AutoFormat.
you want to apply to your form or report. Alternatively, if you’ve come up with a design you want to add to your list of autoformats, you can do so. Your autoformat defines how the fonts, colors, and borders in your documents apply. Creating an autoformat based on your corporate or personal logo would be a great way to make your documents stand out.
■ The AutoFormat Wizard appears. › Click the name of the autoformat you want to preview.
Note: For this example, we clicked Industrial.
6048-4 ch13.F
10/19/99
2:25 PM
Page 397
II
How do I create a new autoformat? Create a new autoformat by clicking the Customize button and clicking the radio button next to “Create an AutoFormat based on the form.”
■ A preview of the selected autoformat appears in this space.
ˇ Click OK.
CREATE TABLES, FORMS, AND REPORTS
How do I select which elements of the autoformat I want to use? You can pick which parts of an autoformat you want to use by clicking the Options button in the AutoFormat dialog box. An area appears at the bottom of the window with check boxes for the font, color, and border attributes of the autoformat. Clear the check boxes for any attribute you don’t want to apply.
How do I modify an autoformat? If you want to change an autoformat, you can open the form or report with the style you want, open the AutoFormat dialog box, and click the Customize button and then the Update radio button. How do I delete an autoformat? To delete an autoformat, open the AutoFormat dialog box, select the autoformat you want to delete, click Customize, and click the Delete radio button.
■ Your form reappears with the AutoForm settings.
397
6048-4 ch13.F
10/19/99
2:25 PM
Page 398
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
DISPLAY THE TOOLBOX hen you build your forms and reports, you’ll find that having a selection of controls and other tools within easy reach on the screen will save you quite a bit of time and effort. Access gives you exactly that facility with its Toolbox. The Toolbox contains the most commonly used controls, such as
W
⁄ Click Toolbox.
398
text boxes, labels, check boxes, command buttons, radio buttons, and list boxes. You can add the items to your form or report and configure them by hand, or you can have Access launch a wizard that steps you through the process of creating each type of control. All of the tasks in this chapter assume you have clicked the Control Wizards button.
If you want to add more advanced controls, such as ActiveX components, sounds, or movies, you can click the More Controls button at the lower right of the Toolbox to display a list of the available controls.
■ The Toolbox appears.
1
6048-4 ch13.F
10/19/99
2:25 PM
Page 399
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
HIDE THE TOOLBOX
s handy as the Toolbox is, there may be times when you just want it to go away. It takes up space on your desktop and, if space is at a premium because of the number of objects on your screen or the size of your monitor, you may not want it around. You can hide the Toolbox by clicking the Toolbox button on
A
⁄ Click Toolbox.
the Form Design toolbar, which is usually displayed at the top of the screen when you have a form or report open in Design view. You can also click the Close box at the top right of the Toolbox title bar to make the Toolbox disappear. You do have other options. The Toolbox is a type of Access database object called a toolbar,
which you can move around the active window, dock along the edges of the screen, or modify based on which buttons and controls you think it should have. For instructions on how to work with toolbars, turn to Chapter 20.
■ The Toolbox disappears.
399
6048-4 ch13.F
10/19/99
2:25 PM
Page 400
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A LABEL hen you create a form object or control, such as a radio button or a text box, Access automatically creates a label to go along with it. The label identifies the object to the user, often reflecting the contents of the field or object it identifies. You’re not limited to creating labels that directly reflect the
W
⁄ Click Toolbox.
400
contents or functions of your form or report objects. You can use labels to set off important parts of your documents, to offer data entry instructions to users who may need guidance on which of several areas on a form would be the most appropriate for the data they’re entering, and to make your document more
¤ Click the Label button in the Toolbox.
attractive by adding titles or headings. If you’ve created a database object and somehow deleted the label that was created along with it, you can create a new label and attach it to the object.
■ Your mouse pointer appears as a crossbar with a letter.
‹ Click the spot where you want the upper-left corner of the label to appear.
6048-4 ch13.F
10/19/99
2:25 PM
Page 401
II
■ The label appears. › Type the text you want to appear in your label.
ˇ Press Enter.
CREATE TABLES, FORMS, AND REPORTS
How do I attach a label to a control or object? You can choose a label to attach to a control or object by clicking the label, opening the Edit menu, and clicking Cut. To attach the label to another object, click the target object, open the Edit menu, and click Paste.
How do I display a list of objects on a form or report? You can see a list of objects on a form or report by clicking the drop-down menu button in the Object list box, located at the far left of the Formatting (Form/Report) toolbar.
■ Your label appears as a highlighted object.
401
6048-4 ch13.F
10/19/99
2:25 PM
Page 402
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A TEXT BOX any of the controls you can add to a form or report allow users to make choices among a number of predetermined options. That approach is appropriate when the range of information a user could enter is always clearly defined. But what if you can’t predict what a user might enter? Text boxes allow users to type information that doesn’t fit into the preprogrammed options. A good example of when text boxes
M
⁄ Click Toolbox.
would be useful is in the area of customer service. Whenever a customer calls your company, your representatives can type their notes on the call directly into the database. For instance, if your employees were providing technical support on a software package, they could use list and combo boxes (discussed later in this chapter) to identify the user’s computer system (processor speed, memory, hard
¤ Click Text Box.
disk space, etc.) and enter the specific problem or suggestion into a text box. You can make a text box any size you want. If the user enters more text than the box can display, it will scroll to allow more input. Text boxes can hold up to 255 characters, so if you expect long comments you might want to include more than one text box on your form.
■ Your mouse pointer changes to a crossbar with a box. ‹ Click where you want one corner of the text box to be located.
402
› Holding down the left mouse button, drag the cursor until the text box is the proper size. ˇ Release the left mouse button.
6048-4 ch13.F
10/19/99
2:25 PM
Page 403
II
■ The text box appears.
Á Click any blank spot on your form.
CREATE TABLES, FORMS, AND REPORTS
How do I add scroll bars to a text box? You can add scroll bars to your text box by right-clicking the box, then clicking Properties from the menu that pops up. When the Properties dialog box appears, click the Format tab and type Vertical in the Scroll Bars field.
How do I have a text box resize to fit its contents? You can have a text box resize to fit its contents by clicking the box, opening the Format menu, clicking Size, and clicking To Fit.
■ Your text box deactivates.
403
6048-4 ch13.F
10/19/99
2:25 PM
Page 404
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A TOGGLE BUTTON
he Toolbox contains three controls you can use to solicit “yes or no” input from your users: the toggle button, the option button, and the check box. All three control types function similarly, though the nature of the question and your design philosophy will determine which of the controls you use. When you’re designing your form, you should consider using
T
⁄ Click Toolbox.
a toggle button whenever you want to give your user an “on or off” choice. When you click a toggle button, it changes from its normal state to a “recessed” state. Since toggle buttons look quite a bit like light switches, they’re ideal for signaling whether an option has been activated or not. Access uses toggle buttons in precisely that manner. Take the Toolbox button, which you
¤ Click Toggle Button.
encountered in tasks “Show the Toolbox” and “Hide the Toolbox” earlier in this chapter. When the Toolbox is hidden, the toolbar button is “flat,” or at the same level as the rest of the toolbar. When the button is clicked and the Toolbox displayed, though, the button is recessed.
■ Your mouse pointer changes to a crossbar with a button. ‹ Click the spot where you want your toggle button to appear.
404
Note: The toggle button appears on the form. (Right now, nothing happens when you click it, however. You will learn how to create an action for the button to launch in Chapter 16.)
1
6048-4 ch13.F
10/19/99
2:25 PM
Page 405
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
CREATE AN OPTION BUTTON
he second type of “yes or no” control is the option button. Option buttons, which are also called “radio” buttons, are most often used when you want the user to pick one option out of a group. You’ll learn more about
T
⁄ Click Toolbox.
setting up an option group in the task “Create an Option Group.” You can also use option buttons to prompt your user to turn an option on or off. It can be difficult to determine whether a toggle button is clicked, especially if the contrast on the
¤ Click Option Button.
monitor is low or you glance at the screen quickly. Option buttons are much easier to take in quickly — you can usually tell if an option button is clicked with little more than a glance.
■ Your mouse pointer changes to a crossbar with a button. ‹ Click the spot where you want your option button to appear.
Note: Your option button appears on the form. (Right now, the button doesn’t do anything when you click it. You’ll learn how to attach an action to the button in Chapter 16.)
405
6048-4 ch13.F
10/19/99
2:25 PM
Page 406
13
1
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A CHECK BOX
he third “yes or no” control is the check box. Outside the database design world, check boxes are used to represent steps in a process or agreement. An example would be if you want
T
⁄ Click Toolbox.
406
your users to choose items from a list, such as completing a weekly series of reports or picking ingredients for a pizza. Check boxes can also be used in the same way as option buttons. Take the Office
¤ Click Check Box.
Assistant Settings dialog box we looked at in Chapter 2 as an example — in that dialog box, you use check boxes to tell Access which behaviors you want the Office Assistant to follow.
■ Your mouse pointer changes to a crossbar with a box.
‹ Click the spot you want your check box to appear. Note: The check box appears on your form. Learn how to create an action for the button in Chapter 16.
6048-4 ch13.F
10/19/99
2:25 PM
Page 407
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
INSERT A PAGE BREAK reating a form or report without restricting the page size is the easiest way to go, but if a large number of records are to be displayed it can take a long time to draw the page. You can use page breaks to make sure each page on your form or report contains the
C
⁄ Click Toolbox.
proper data and is the right size. When you insert a page break in a form or report, a short dotted line appears beside the vertical ruler as a visual reference. You should make sure the page break doesn’t occur in the middle of a control, especially if the lowestplaced control on the page is a text box. If you do accidentally
¤ Click Page Break.
cut through a control, its contents will be split on either side of the page break. You can get a preview of how your page break affects your form’s appearance by switching to Form view or clicking the Print Preview toolbar button.
■ Your mouse pointer changes to a crossbar with a page.
‹ Click where you want to place your page break. Note: Your page break appears on your form.
407
6048-4 ch13.F
10/19/99
2:25 PM
Page 408
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE AN OPTION GROUP arlier in this chapter you learned how to create individual controls that gave users a “yes or no” choice: toggle buttons, option buttons, and check boxes. Since each control was independent from the others, a user could select “yes” or “no” for as many of the controls as they liked. Option groups are different — users can only choose one option from those presented.
E
⁄ Click Toolbox. ¤ Click Option Group. Note: Your mouse pointer changes to a crossbar with a box.
‹ Click where you want one corner of your option group to appear. 408
The classic example of an option group is a question on a multiple choice test. In most tests of that kind, you make only one choice from the possible answers. You can use a similar strategy to make users choose among a number of fixed categories, such as whether they are part-time, full-time, or temporary employees; if they were for, against, or undecided on an issue; or which sport they
› Holding down the left mouse button, drag the pointer until the frame is the desired size for the option group. ˇ Release the left mouse button.
prefer among a number of choices. When you tell Access you want to create an option group, the program launches the Option Group Wizard, which walks you through the process. The wizard lets you pick the type of controls to use in your group, define the options, and assign a default choice.
■ The Option Group Wizard appears. Á Type the label for the first option in this space.
‡ Press Tab.
6048-4 ch13.F
10/19/99
2:25 PM
Page 409
II
■ The cursor moves to the next row.
° Click Next when you have entered all of the desired options.
CREATE TABLES, FORMS, AND REPORTS
How do I tell Access not to set a default value for my option group? To have Access not set a default value for your option group, click the option button next to “No, I don’t want a default” in the second Option Group Wizard screen.
Is there a character limit for button labels? Label names can’t exceed the field size in the Wizard, but you should try to keep the names shorter than that. Long button names can be difficult to fit on a form.
■ The next Option Group Wizard screen appears. · Click the Default Choice drop-down menu button.
‚ Click the option you want as the default choice for this option group. — Click Next. CONTINUED
409
6048-4 ch13.F
10/19/99
2:25 PM
Page 410
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE AN OPTION GROUP hen you create an option group, you can choose from the three basic “yes or no” controls in the Toolbox: toggle buttons, check boxes, and option buttons. Access itself almost always uses option buttons as the control of choice in its option groups, something you probably noticed as you stepped through the wizards to create databases and other objects.
W
■ The next Option Group Wizard screen appears. Note: You will learn about working with the value from this and other controls in Chapter 18.
410
The wizard also asks you to type a caption for your option group. You should make sure your caption accurately describes the group, though labels are the better choice for any lengthy data entry instructions or reminders. You can find out about labels in task “Create a Label,” presented earlier in this chapter. You should use an option group whenever you want users
± Click Next.
CONTINUED to choose among a small number of exclusive items or categories. If the list of possible answers includes more than four or five items, or if the user might need to type in a value not in the list, you should consider using a list box or a combo box.
■ The next Option Group Wizard screen appears. ¡ Click the type of control you want to appear in your option group from among these choices.
™ Click the style you want for your option group from among these choices. Note: A preview of your selection appears in this space.
£ Click Next.
6048-4 ch13.F
10/19/99
2:25 PM
Page 411
II
■ The Checkered Flag screen appears.
¢ Type a caption for your option group in this space.
CREATE TABLES, FORMS, AND REPORTS
How do I specify the appearance of the controls in my option group? You can specify the appearance of the controls in your group in the same screen where you pick the type of control you want in your option group. You can pick from options that make your control look flat, raised, sunken, raised, shadowed, and chiseled.
How do I set different output values for the options in my option group? You can change the outputs for any option in your group in the third Option Group Wizard screen. Just click in the Value cell next to the Label Name you want to generate the output.
■ Your option group appears on your form.
∞ Click Finish.
411
6048-4 ch13.F
10/19/99
2:26 PM
Page 412
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A COMBO BOX ne goal of a database administrator’ should be to make the database as flexible and easy to use as possible. Normally, those two goals work against each other. Ease of use implies simplicity in form and function; flexibility usually implies significant effort when you plan and execute your database, not to mention a potentially complex interface.
O
⁄ Click Toolbox.
412
Combo boxes help solve the simplicity versus flexibility dilemma. By combining the features of text boxes and list boxes, combo boxes let users pick from an established list of choices or, if they need to, enter an original value. One potential use for a combo box would be in a survey that determines if participants qualify for a free subscription to an industry magazine. Although
¤ Click Combo Box.
most questions could be answered through list boxes or option groups, one tricky category is “Job Title.” Your combo box should contain entries for the common titles (Project Manager, System Administrator, Technical Staff, etc.) while giving participants room to enter unusual titles.
■ Your mouse pointer changes to a crossbar with a miniature menu.
‹ Click the spot you want your combo box to appear.
6048-4 ch13.F
10/19/99
2:26 PM
Page 413
II
■ The Combo Box Wizard appears. › Click the radio button next to the source for the values to appear in your combo box.
Note: In this case, we told Access to get the values from an existing table.
ˇ Click Next.
CREATE TABLES, FORMS, AND REPORTS
How do I enter a custom list of values to appear in my combo box? You can enter a custom list of values for your combo box by clicking the option button next to “I will type in the values I want” in the first screen of the Combo Box Wizard.
How do I display my queries when I choose a value source for my combo box? You can display your queries by clicking the Queries option button in the second Combo Box Wizard screen. To display both your tables and queries, click Both.
■ The next Combo Box Wizard screen appears.
Note: In this case, we clicked Products.
Á Click the name of the table or query that contains the values for your combo box.
‡ Click Next.
CONTINUED
413
6048-4 ch13.F
10/19/99
2:26 PM
Page 414
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A COMBO BOX hen you create your combo box, Access launches a wizard to guide you through the process. The first item of business is to pick where you want Access to get the values to include in the combo box.
W
CONTINUED
If you want, you can enter the values for your combo box by hand. If the values are available in one or more fields from a table or query in your database, you should have Access draw the values from those sources.
As with many of the other Access wizards, if you want to use data from more than one table or query at a time you will need to write a custom query that combines the information into a single object.
■ The next Combo Box Wizard screen appears.
■ The field name appears in the Selected Fields pane.
■ The next Combo Box Wizard screen appears.
° Click the name of the first field containing the values for your combo box.
Note: For this example, we clicked ProductName.
— Adjust the width of the combo box field by dragging the right edge of the column to the desired width.
· Click the right arrow button.
414
‚ Click Next when you are done adding fields.
± Click Next.
6048-4 ch13.F
10/19/99
2:26 PM
Page 415
II CREATE TABLES, FORMS, AND REPORTS
How do I have Access automatically set the width of the data column displayed by my combo box? You can have Access set your combo box’s width by double-clicking the right edge of the column.
Can I customize the combo box after the Wizard creates it? Yes. For help doing so, click the checkbox on the Checkered Flag screen.
■ The next wizard screen
™ Click the drop-down
appears.
menu button.
■ The Checkered Flag screen appears.
¡ Click “Store that value in
£ Click the field where you
∞ Type a label for your
this field.”
want to store the value.
combo box in this space.
Note: To keep the value and use it later instead of writing it to a table, click "Remember the value for later use."
Note: In this case, we clicked ProductName.
§ Click Finish. Note: Your combo box appears on the form.
¢ Click Next. 415
6048-4 ch13.F
10/19/99
2:26 PM
Page 416
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A LIST BOX hen you create a form for your database, you need to make data entry as simple as possible. Not only does automation speed up data entry, it also reduces spelling errors and ensures the data entry personnel don’t enter invalid information. Access lets you create list boxes, controls with a drop-down
W
⁄ Click Toolbox.
menu button users can click to display the possible values for a field. When the user clicks a value from the list, other Access objects, macros, and Visual Basic code modules can use that value in their procedures. You should use a list box whenever you want users to choose among a number of exclusive items or definitive
¤ Click List Box.
categories. If the list of possible answers only includes four or five items, however, you should consider using an option group instead. If your form is crowded, you can save space by replacing option groups with list boxes.
■ Your mouse pointer changes to a crossbar with a tiny list.
416
‹ Click the spot where you want your list box to appear.
6048-4 ch13.F
10/19/99
2:26 PM
Page 417
II
■ The List Box Wizard appears. › Click the radio button next to the source for the values in the list to appear in your list box.
Note: In this case, we told Access to get the values from an existing table.
ˇ Click Next.
CREATE TABLES, FORMS, AND REPORTS
How do I enter a custom list of values to appear in my list box? You can enter a custom list of values for your list box by clicking the option button next to “I will type in the values I want” in the first screen of the List Box Wizard.
How do I display my queries when I choose a value source for my list box? You can display your queries by clicking the Queries option button in the second List Box Wizard screen. To display both your tables and queries, click Both.
■ The next List Box Wizard screen appears.
‡ Click Next.
Á Click the name of the table that contains the values for your list box. Note: In this case, we clicked Products.
CONTINUED
417
6048-4 ch13.F
10/19/99
2:26 PM
Page 418
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A LIST BOX hen you create your list box, Access launches a wizard to guide you through the process. The first item of business is to pick where you want Access to get the values to include in the list box.
W
■ The next List Box Wizard screen appears. ° Click the name of the first field containing the values for your list box. Note: For this example, we clicked ProductName.
418
CONTINUED
If you want, you can enter the values for your list box by hand. If the values are available in one or more fields from a table or query in your database, you should have Access draw the values from those sources.
· Click the right arrow. ‚ Click Next when you are done adding fields.
As with many of the other Access wizards, if you want to use data from more than one table or query at a time you will need to write a custom query that combines the information into a single object.
■ The next List Box Wizard screen appears. — Adjust the width of the list box field by dragging the right edge of the column head to the desired width.
± Click Next.
6048-4 ch13.F
10/19/99
2:26 PM
Page 419
II CREATE TABLES, FORMS, AND REPORTS
How do I have Access set my list box’s width automatically? You can have Access set your list box’s width automatically by double-clicking the right edge of the column head.
Can I customize the list box after the wizard creates it Yes. To get help doing so, clock the checkbox on the Checkered Flag screen.
¡ Click “Store that value in
™ Click the drop-down
this field.”
menu button.
■ The Checkered Flag screen appears.
Note: If you want Access to remember the value and use it later instead of writing it to a table, click "Remember the value for later use."
£ Click the field you want to
∞ Type a label for your list
store the value.
box in this space.
§ Click Finish. Note: Your list box appears on the form.
Note: In this case, we clicked ProductName.
¢ Click Next. 419
6048-4 ch13.F
10/19/99
2:26 PM
Page 420
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A COMMAND BUTTON p to now we’ve concentrated on the controls you can use to make data entry easier for you and your users. However, users may need to verify information in a separate database object or file elsewhere on your computer during data entry. Fortunately, Access comes with a wide variety of prewritten macros and procedures you can
U
⁄ Click Toolbox.
420
use to expand your application’s functionality. For instance, you can have Access launch another program (such as MS Word or MS Excel), run a macro or procedure, or open a table. You’ll learn how to use command buttons to launch macros and procedures in Chapter 16. When you tell Access you want to create a command button, it starts a wizard that
¤ Click Command Button.
walks you through the creation process step by step. As you go through the wizard, you can assign the procedure that will run when the button is clicked, determine what the button will look like, and assign the button a name in the database’s list of objects.
■ The mouse pointer changes to a crossbar with a rectangle.
‹ Click where you want the command button to appear.
6048-4 ch13.F
10/19/99
2:26 PM
Page 421
II CREATE TABLES, FORMS, AND REPORTS
Can I use a command button to allow a user to quit Access? You can allow a user to quit Access while using your form by including a control that runs the Quit Application action, found under the Application category.
■ The Command Button Wizard appears. › Click the category containing the action you want to associate with your command button.
Note: In this case, we clicked Application.
■ The list of available actions in the Application category appears in this pane. ˇ Click the action you want to associate with your command button.
Note: In this case, we clicked Run MS Word.
■ The button associated with the action you chose appears in this space. Á Click Next.
CONTINUED
421
6048-4 ch13.F
10/19/99
2:26 PM
Page 422
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A COMMAND BUTTON CONTINUED
he capability to trigger a custom macro or procedure from a control is an important method of extending Access’ usefulness to you and your organization. For instance, you could allow your users to run a query from a form. Tying the contents of another database object to the results of
T
■ The next Command Button Wizard screen appears. ‡ Click the radio button indicating whether you want Access to display text or a graphic on the command button.
422
the query would enable your users to refresh the data they’re working with, increasing their accuracy. You can also take steps to ensure your button fits in with the rest of your design. Access allows you to choose a picture or text to be displayed on the button’s face. You’re not limited
Note: For this example, we clicked Text.
° Type the text you want to appear on your button in this space. · Click Next.
to the samples included in the standard Access installation — you can use pictures saved in most any popular graphics format. So, if your organization has a particular graphic or logo they’d like you to use on your buttons, you can add it with no trouble.
■ The next Command Button Wizard screen appears.
‚ Type a name for your button in this space. — Click Finish.
6048-4 ch13.F
10/19/99
2:26 PM
Page 423
II CREATE TABLES, FORMS, AND REPORTS
How do I tell Access to use a picture on my button’s face? You can have Access use a picture on your button’s face by clicking the Picture option button and clicking Browse. You can use the navigation tool that appears to select the picture you want.
■ Your command button appears on the form.
¡ Click Form view.
■ Your form appears in Form view.
± Click View.
423
6048-4 ch13.F
10/19/99
2:26 PM
Page 424
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
INSERT AN IMAGE
he most common example of adding an image to a form or report is pasting organization’s logo at the top of a page. Another good reason to add an image to a form is if your users might need a visual aid to
T
⁄ Click Toolbox.
help them with their data entry. For instance, if you were the database administrator for a computer repair shop, you could include images of computer components that could be brought in for service. A visual
¤ Click Image.
reference would make it easier for your nontechnical personnel to communicate via email or phone with the technical staff.
■ The mouse pointer changes to a crossbar with a little mountain landscape. ‹ Click where you want one corner of the image to be located.
424
› Holding down the left mouse button, drag the mouse pointer until the frame is the desired size. ˇ Release the left mouse button.
6048-4 ch13.F
10/19/99
2:26 PM
Page 425
II
■ The Insert Picture screen appears. Á Click the name of the image file you want to add to your form.
Note: You can pick an image from anywhere on your computer (or on a connected computer) using the screen's controls.
CREATE TABLES, FORMS, AND REPORTS
I want to use the same picture more than once in my form. Do I need to insert it into the form every time? After you’ve inserted the image the first time, you can save disk space by opening the image’s Properties box, clicking the PictureType property drop-down menu button, and choosing Linked from the list. Do the same for every instance you use the image. Linking to the image means you only store it once.
What kinds of graphics formats can I use? Access recognizes JPEG, GIF, BMP, and other popular image formats.
■ The image appears in your form.
‡ Click OK.
425
6048-4 ch13.F
10/19/99
2:26 PM
Page 426
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
INSERT AND RESIZE AN UNBOUND OBJECT nserting images, as you learned how to do in the previous task, is a useful way to spice up your designs and, in some cases, help your users properly identify database items. You can go well beyond adding simple images, though. Access lets you insert objects from outside your database into
I
⁄ Click Toolbox.
your forms and reports using the Unbound Object control. Here, Unbound means the control isn’t directly linked to an item in your database. Rather, you can include objects from any OLE-compliant program on your computer. The specific list of objects you can include in your form or report depends on the software
¤ Click Unbound Object Frame.
installed on your machine. If you have the full Microsoft Office suite installed on your computer, you’ll see MS Word, MS Excel, MS PowerPoint, and some of the helper applications.
■ The mouse pointer changes to a crossbar with a tiny desert scene. ‹ Click where you want one corner of the image to be located.
426
› Holding down the left mouse button, drag the mouse pointer until the frame is the desired size. ˇ Release the left mouse button.
6048-4 ch13.F
10/19/99
2:26 PM
Page 427
II
■ The Insert Object window appears. Á Click the type of object you want to add to your form.
‡ Click OK. Note: In this case, we selected a Microsoft Clip Gallery file.
CREATE TABLES, FORMS, AND REPORTS
Can I edit unbound objects once they’re inserted? Yes. If you’re in Design view and you double-click an unbound object, the program that created it opens, and you can edit the object.
Nothing happens when I double-click my unbound object.What’s wrong? If nothing happens when you double-click your unbound object, it means you’re probably not in Design view.
■ Microsoft Clip Gallery appears.
Note: In this case, we selected Animals.
° Click the category of image you want to add. CONTINUED
427
6048-4 ch13.F
10/19/99
2:26 PM
Page 428
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
INSERT AND RESIZE AN UNBOUND OBJECT CONTINUED hen you insert an unbound object into your form, you are literally inserting a document from the application you click. If you select Microsoft Word Document from the list, for instance, Access embeds an MS Word document in your form. You can edit your unbound object in Design view; not only can you resize the object, but you
W
■ The images in the Animals category appear. · Click the image you want to add.
can add data to and set formulas in Microsoft Excel spreadsheets, produce powerful PowerPoint presentations, and create or edit graphics in any OLE-compliant painting or drawing program on your system. You can resize the unbound object frame by following the steps in task “Resize a Control,” presented in this chapter. You also have the ability to change
■ A pop-up menu appears. ‚ Click Insert Clip.
how images fit in the frame. For instance, you can have the image stretch to fill the entire frame. Another alternative is to resize the image so it fits within the frame while retaining its original proportions.
■ The image appears in your form. RESIZE THE IMAGE SO IT FITS IN THE FRAME
⁄ Click the image.
428
¤ Click Properties.
6048-4 ch13.F
10/19/99
2:26 PM
Page 429
II
■ The Object Properties box appears.
› Click the drop-down menu button.
Note: If the Format tab is not clicked, click it now.
ˇ Click Stretch.
CREATE TABLES, FORMS, AND REPORTS
How do I add images and files from other programs? You can add images and files from other programs by choosing a different source for your object from the drop-down list of available programs that appears in the wizard.
How do I resize my image without changing its proportions? You can resize your image without changing its proportions by choosing the Zoom option from the Size Mode property’s drop-down menu.
■ The image is redrawn in proportion to the dimensions of the frame.
Á Click the Close box.
‹ Click the text area next to Size Mode.
429
6048-4 ch13.F
10/19/99
2:26 PM
Page 430
13
1
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A TAB CONTROL
he tab control is one of the most versatile controls in the Toolbox. Not only does it give the user an index of their contents, it also saves quite a bit of space on your form or report. You can add other controls (like command buttons) to your tab controls using the
T
⁄ Click Toolbox.
skills you’ve learned in this chapter. In essence, tab controls are like forms within forms. Tab controls also make a great starting point for creating custom switchboards and dialog boxes for your databases. Since Access doesn’t create a switchboard for databases created from scratch
¤ Click Tab Control.
(that is, without using one of the built-in wizards), you may need to create your own. To learn more about creating a switchboard from scratch, see the Chapter 19 task “Create a Custom Switchboard.”
Note: The mouse pointer changes to a crossbar with a rectangle that has a tabbed corner.
‹ Click where you want one corner of the tab control to appear.
› Holding down the left mouse button, drag the mouse pointer until the frame is the desired size. ˇ Release the left mouse button. Note: The tab control appears.
430
6048-4 ch13.F
10/19/99
2:26 PM
Page 431
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
CREATE A TAB CONTROL: MOVE TO A PAGE
ccess makes it easy to tell which page contains the information you want. Each page tab can be customized with the label of your choice, allowing you to identify the contents of your pages to your users. Moving between pages in a tab control is a frequently used skill
A
⁄ Click the tab representing the page to which you want to move.
when creating and working with Access databases. Many of the options screens are based on tab controls, with the best example being the Properties dialog box. You can move from one category of property to another by clicking the tabs at the top of the control, or display the entire list by clicking the All tab.
One of the more powerful uses of tab controls is as the base for custom switchboards for your databases. As you’ll learn in Chapter 18, creating a central control can make using a database much easier.
■ The new page appears.
431
6048-4 ch13.F
10/19/99
2:26 PM
Page 432
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A TAB CONTROL ADD A PAGE hen you create a tab control, you are establishing a mechanism that enables users to move around your database objects easily. Furthermore, you’re saving quite a bit of space on your forms by using the same real estate several times. The only serious questions about
W
⁄ Right-click the tab control.
432
designing tab controls are how large to make the control and how many tabs (or pages) to create. You should add a page to your tab control whenever you want to add a new subset of information. If you use a tab control to give data entry operators information about your company’s products,
¤ Click Insert Page.
you should add a page whenever you introduce a new line of products. Your new page could contain the names of the products, their prices, and a control button that could run a query based on a product name to determine if that product was in stock.
■ The new page appears.
1
6048-4 ch13.F
10/19/99
2:26 PM
Page 433
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
CREATE A TAB CONTROL: DELETE A PAGE eleting pages in a tab control is simple to do, though deciding when a page should be removed is not always as straightforward. You should consider deleting a page whenever the information or functions on the page are no longer needed. For instance, if
D
⁄ Right-click the page you want to delete.
one page of your tab control contains information and queries related to a product line that has been discontinued, you can remove the page from an order entry database. You should, however, consider keeping the page around in the inventory database so your operators can
¤ Click Delete Page.
refer to it if your customers have any questions about past orders. Another reason to remove a page in a tab control is if you want to limit the controls available to users of a particular copy of your database.
■ The page disappears.
433
6048-4 ch13.F
10/19/99
2:26 PM
Page 434
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A TAB CONTROL: NAME A PAGE hat you name a page on your tab controls is very important. The text that appears on the tab communicates the tab’s purpose and the type of controls the users can expect to find when they click the tab.
W
⁄ Right-click the page you want to rename.
You can assign a name to a page on a tab control by opening the Properties box for the page and entering a name in the Caption area. If you were designing a tab control to walk operators through the process of taking an order over the
¤ Click Properties.
telephone, for example, you might name your tabs Contact Information, Credit Card Information, Order History (generated through a query based on the customer’s last name and postal code), and Comments.
■ The Properties box appears. Note: If the Format tab isn't clicked, click it now.
434
‹ Click the Caption text area.
6048-4 ch13.F
10/19/99
2:26 PM
Page 435
II
■ A cursor appears in the text area.
ˇ Click the Close box.
CREATE TABLES, FORMS, AND REPORTS
I don’t see the Caption property under the Format tab.Why not? If you clicked the tab control as a whole and not the specific page you wanted to name, you will open the Properties dialog box for the entire object. Make sure you click the tab for the page you want to name before you click Properties.
How long should I make my captions? Try to make tab captions as concise as possible. Too much text on a tab looks awkward and becomes more difficult to understand, rather than clarifying matters.
■ The name appears on the tab.
› Type a name for the page.
435
6048-4 ch13.F
10/19/99
2:26 PM
Page 436
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A TAB CONTROL: CHANGE PAGE ORDER nce you’ve created your tab control, you can change the order of the pages to best fit your needs. Access provides a simple dialog box that lets you move pages up or down the list to change the order in which the pages appear on the control. You should consider modifying the order of your
O
⁄ Right-click the tab control.
pages whenever you think a new arrangement would better meet your users’ needs. If one set of functions becomes more popular than the others, you could move the page with those functions to the top of the list and have them appear at the front when the form is opened.
¤ Click Page Order.
You could also change your page order when you add new pages to your control. Depending on whether the new features will be used more commonly than one or more existing pages, you can choose the best spot for your additions and use the dialog box to put them there.
■ The Page Order box appears.
MOVE A PAGE DOWN
‹ Click the page you want to move. › Click Move Down.
436
6048-4 ch13.F
10/19/99
2:26 PM
Page 437
II
■ The page moves down one spot.
Is there a limit to the number of tabs I can have? No, but lots of tabs can overwhelm your users and make your form difficult to work with. If you find yourself using many tabs, consider other design elements or even multiple forms.
⁄ Right-click the tab
■ The Page Order box appears.
control.
‹ Click the Page you want
¤ Click Page Order.
to move up.
MOVE A PAGE UP
CREATE TABLES, FORMS, AND REPORTS
I want to add a lot of tabs to my control. Can I have Access display them in more than one row? You can have Access use more than one row of tabs by opening the control’s Properties dialog box and setting the MultiRow property to Yes.
› Click Move Up. Note: The page changes position.
ˇ Click OK to close the Page Order box.
437
6048-4 ch13.F
10/19/99
2:26 PM
Page 438
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CREATE A SUBFORM OR SUBREPORT
subform, as the name implies, is a form that appears within another form. The primary form and subform combine to create a “parent/child” relationship. That is, the primary form contains the subform and dictates its contents. The most common use for subforms and subreports is to illustrate the “many” side of a
A
⁄ Click the Toolbox button if the Toolbox is not already displayed. Note: You will need to work with a form other than Products to follow this example.
438
one-to-many relationship in a database. As you learned in Chapter 6, a one-to-many relationship between two entities means that the records on the “many” side are instances of categories on the “one” side. Within the Northwind sample database, for instance, you can see a one-to-many relationship between items in the Categories and Products tables.
¤ Click Subform/Subreport.
When you enter data into a subform, Access automatically saves the record in the main form as well. This way, Access can ensure there is a record related to the subform in the table supplying data for the main form.
Note: The mouse pointer changes to a crossbar with a little form.
‹ Click where you want one corner of the subform/ subreport to appear.
› Holding down the left mouse button, drag the mouse pointer until the frame is the desired size. ˇ Release the left mouse button.
6048-4 ch13.F
10/19/99
2:27 PM
Page 439
II
Can I create a subform within a subform? Access allows you to create up to ten levels of subforms.
■ The SubForm Wizard appears.
‡ Click the form you want to use as your subform.
■ The Checkered Flag screen appears.
Á Click the radio button
Note: In this case, we clicked Products.
· Type a name for your
next to the preferred source for the subform.
CREATE TABLES, FORMS, AND REPORTS
Does Access allow me to have more than one subform in a form? You can add as many subforms as you like to a parent form, but bear in mind the subform should be related to the primary form, preferably by a key value.
‚ Click Finish. Note: Your subform or subreport appears in the main document.
subform here.
° Click Next.
Note: In this example, we chose Use an Form.
439
6048-4 ch13.F
10/19/99
2:27 PM
Page 440
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
ADD A LINE
n addition to letting you create text boxes and other controls for you and your users to enter and look up data, Access also allows you to add graphic elements to your forms and reports. Properly used, graphic elements like lines and boxes can
I
⁄ Click Toolbox. ¤ Click Line. Note: Your mouse pointer changes to a crossbar with a diagonal line.
‹ Click where you want one end of the line to appear. 440
make your forms easier to read, highlight required areas, and make them more attractive. They can also be used to make your online forms look like your paper forms. You can choose from a variety of line styles and thicknesses. To change the thickness of your line,
› Holding down the left mouse button, drag the pointer until the line is the desired length. ˇ Release the left mouse button.
click the Thickness button on the Formatting (Form/Report) task button. To change the line’s style (solid, dashes, dots, etc.), click the line, click the Properties button, and chose the style you want from the BorderStyle property’s drop-down menu.
■ The line appears on your form.
1
6048-4 ch13.F
10/19/99
2:27 PM
Page 441
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
ADD A RECTANGLE
s you learned in the previous task, adding lines to your forms and reports can make them much more visually appealing. The same holds true for rectangles, or “boxes.” When you add a box to a form or report, you set the enclosed area off from the rest of the document, drawing your user’s
A
⁄ Click Toolbox. ¤ Click Rectangle. Note: Your pointer changes.
‹ Click where you want one corner of the rectangle to appear.
attention to it. If you fill the box with a color or pattern (as you will learn to do in the task “Change the Fill Color of a Rectangle,” presented later in this chapter), you can make the effect quite dramatic. For instance, you could use a red background with white letters to create an instruction with the same color scheme as a
› Holding down the left mouse button, drag the pointer until the rectangle is the desired size.
stop sign. The natural association between the design and the road sign would help users know they should at least slow down and read the message before they proceed.
■ The rectangle appears on your form.
ˇ Release the left mouse button.
441
6048-4 ch13.F
10/19/99
2:27 PM
Page 442
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CHANGE THE COLOR OF A LINE n addition to being able to change the pattern of lines in Access, it’s also easy to change the line’s color. Access gives you a palette of 40 colors to pick from. You should be able to find a color that meets your needs. If not, you can click the
I
⁄ Click the line. ¤ Click the Line/Border Color drop-down menu button.
442
line, click the Properties button on the toolbar, click BorderColor, and click the Build button that appears. After you click Build, the Color window appears. You’ll see a palette of 48 colors and the Define Custom Colors button.
‹ Click the color you want to make your line.
Clicking the Define Custom Colors button displays a color field with a range of colors and brightness levels. You can pick a color and brightness level, click OK, and close the Properties box to apply the color to your line.
■ Your line appears in the new color.
1
6048-4 ch13.F
10/19/99
2:27 PM
Page 443
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
ust as Access lets you change the color of lines on your forms and reports, you can change the fill color of an object. Consider changing the fill color of a rectangle when you want to make the contents of the rectangle stand out from the background. One possibility is to mimic the colors and designs of highway signs, using red backgrounds for instructions that must be followed, yellow
J
⁄ Click the rectangle you want to assign a new fill color to.
backgrounds for cautions, blue backgrounds for informational signs and, if appropriate, green for mileage and brown for national parks and other landmarks. To check whether or not a particular object’s fill color can be changed, click the object and verify that the Fill/Back Color toolbar button is active. To get at the Color dialog box open the Properties dialog box for your rectangle and click the
‹ Click the color you want to assign to your rectangle.
CREATE TABLES, FORMS, AND REPORTS
CHANGE THE FILL/BACK COLOR OF AN OBJECT
II
Back Color property’s Build button. You can make your object’s background transparent, which would allow any background pattern you’d defined for your form to show through. By setting an object’s fill and border to Transparent, the text and controls in the foreground would appear as if they were directly on the background and not a separate control.
■ Your rectangle appears with the new fill color.
¤ Click the Fill/Back Color drop-down menu button.
443
6048-4 ch13.F
10/19/99
2:27 PM
Page 444
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CHANGE THE BORDER COLOR OF AN OBJECT
J
ust as you can change the color of lines on your forms and reports, you can also change the color of an object’s border. Every control on a form or report, with the exception of lines and page breaks, has a border you can change. Another option you have when choosing a color for a border is to make the border transparent.
⁄ Click the object you want to assign a new border color to. ¤ Click the Line/Border Color drop-down menu button.
444
When you click the Line/Border Color drop-down menu button, the word “Transparent” appears at the top of the palette. Click it and the background will show through; your object will appear not to have a border at all. By setting the border and fill colors to Transparent, you can make your control’s foreground objects (like text and option buttons)
‹ Click the color you want to assign to your border.
appear to be directly on the background and not part of a separate object. To get at the Color dialog box to change an object’s border color, open the Properties box and click the Border Color’s Build button.
■ Your rectangle's border takes on the new color.
1
6048-4 ch13.F
10/19/99
2:27 PM
Page 445
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
CHANGE THE SPECIAL EFFECT OF AN OBJECT hen you decide on the best look for each object on your forms, you have more to choose from than color and size. You can also choose whether an object is drawn “flat” with the background of the form or has another effect applied. You can choose from several effects: flat, shadowed, raised, sunken, etched, and chiseled. You can find several of the styles
W
⁄ Click the object you want to change.
in use around the standard Access window. For instance, unclicked toolbar buttons are rendered with a “flat” effect; when clicked, they change to “raised.” Some special effects preclude some types of color changes; you will need to experiment with the changes to ensure your color changes take effect. You should try a number of different styles for each type of
¤ Click Properties.
object on your form. Once you’ve hit upon a design you like, you can apply it to all of the forms in your database. You don’t want to be foolishly consistent in applying the design to your forms and reports, but it’s usually a good idea to apply the same effect to a class of objects throughout your collection.
■ The Properties dialog box appears.
ˇ Click the special effect for your object.
Note: If the Format tab isn't in the front, click it now.
Note: In this case, we clicked Chiseled.
‹ Click Special Effect.
Á Click the Close box.
› Click the drop-down menu button.
Note: The object will appear drawn in the style you chose.
445
6048-4 ch13.F
10/19/99
2:27 PM
Page 446
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
EDIT TEXT
t’s a rare occasion when you get something just right the first time. So, Access gives you the ability to edit any text you’ve entered into your labels. To edit the text in a label, click the label, wait a second, and click the label again when your mouse pointer turns into a cursor. (You’ll need to keep the
I
⁄ Click the object containing the text you want to edit. Note: After you click the object, your mouse pointer will change to a cursor when it is over the object.
446
mouse pointer positioned over the label after the first click for the change to occur.) When you click the label the second time, a cursor will appear in the label’s text box. Once there, you can use the keyboard and mouse to edit the text normally. When you’re done, press Enter to signal
¤ Click the object again.
Access you’ve completed the change. If you want to assign a default value to a text box, you can click the text box, click Properties, and type the value you want to appear in the box automatically in the Default Value property.
■ The cursor appears in the text area. You can edit the text using the keyboard and mouse.
1
6048-4 ch13.F
10/19/99
2:27 PM
Page 447
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
CHANGE THE COLOR OF TEXT
ccess gives you a lot of flexibility in changing the standard color scheme of gray backgrounds, white fills, and dark blue title bars. Since Access’ title bar is dark blue, any text that appears on it must be rendered in white (or
A
⁄ Click the object containing the text you want to change.
another light color) to be legible. The same consideration is true for objects on your forms. If you pick a background or fill color that obscures the standard black text, you’ll need to choose a foreground color (which is also
¤ Click the Font/Fore Color drop-down menu.
the Font color) that stands out from the background color. To get at the Color dialog box to change some text’s color, open the Properties box, click the Fore Color property name, and click the Build button that appears.
■ The text takes on the new color.
‹ Click the color you want to assign to the text.
447
6048-4 ch13.F
10/19/99
2:27 PM
Page 448
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
CHANGE THE FONT OF A TEXT SELECTION olor plays a very important part in the design of your form, along with the physical arrangement of your controls and other graphical elements on the form. Yet another design consideration when you’re putting together your form is what font, or typeface, will be
C
⁄ Click the text object you want to change. ¤ Click the Font drop-down menu button.
448
used for different elements of the document. Windows comes with a set of fonts, though you can also purchase a seemingly infinite variety of fonts from vendors, including quite a few that offer their products over the Internet. If you want to duplicate a paper form in Access and don’t have
‹ Click the font you want the text to be displayed in.
the proper fonts on hand, check with the printer to determine the name and potential sources for the typeface you need. You can also use the Bold, Italic, and Underline buttons on the Formatting (Form/Report) toolbar to change the appearance of your text.
■ The text appears in the selected font.
1
6048-4 ch13.F
10/19/99
2:27 PM
Page 449
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
CHANGE THE SIZE OF SELECTED TEXT
hanging the typeface and color of a text selection does quite a bit to make the text stand out from other elements of your forms. You can make your text even more distinct by changing its size. At its simplest, changing the size of a text element can signal
C
⁄ Click the text object you want to change.
its place in an outline. In a newspaper, headlines are always significantly larger than the surrounding text, and some headlines are larger than others. You can increase the size of your section labels to set them off in relation to “lower level” labels, instructions, or other explanatory text.
‹ Click the size you want the text to be displayed in.
Each font has its own characteristics — some look better in small and medium sizes, others look better when they’re large. You should experiment with different type sizes for the different textual elements on your forms to see which combination yields the best results.
■ The text appears in the selected size.
¤ Click the Font Size dropdown menu button.
449
6048-4 ch13.F
10/19/99
2:27 PM
Page 450
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
RESIZE A CONTROL f you click on a control button in the Toolbox and click on the form where you want the control to appear, Access creates a control of a default size. That default is different for each control type, but odds are it won’t be the size you want.
I
RESIZE A CONTROL HORIZONTALLY
⁄ Click the control you want to resize. ¤ Click the black square in the center of the edge you want to move. 450
Fortunately, there are ways to correct fate. When you click a control, black squares called “handles” appear along the control’s outline. You can grab any of the handles and drag the control’s outline until it’s the size you want. To resize more than one object at a time, click the
Note: Your pointer changes shape when it is in position.
‹ Holding down the left mouse button, drag the edge until its outline is in the desired position. › Release the left mouse button.
objects you want to resize while holding down the Ctrl key, grab the appropriate handle on any of the objects you’ve selected and drag it until the object connected to the handle you’ve picked is the size you want.
■ The control resizes.
6048-4 ch13.F
10/19/99
2:27 PM
Page 451
II CREATE TABLES, FORMS, AND REPORTS
How do I resize a control diagonally — that is, both horizontally and vertically at the same time? You can resize a control diagonally by grabbing one of the black boxes (handles) at the corner you want to use to resize the control.
My control moved instead of resizing. What happened? You probably clicked on the control itself rather than the frame. Open the Edit menu and click Undo to put the control back and try again, remembering that the cursor needs to be a double-headed arrow to resize a control.
How do I assign precise values to a control’s width and height? You can assign precise values to a control’s width and height by opening the Properties box, clicking the Format tab, and setting the Width and Height properties to the desired values.
RESIZE A CONTROL VERTICALLY
⁄ Click the control you want to resize. ¤ Click the black square in the center of the edge you want to move.
Note: Your pointer changes shape when it is in position.
■ The control resizes.
‹ Holding down the left mouse button, drag the edge until its outline is in the desired position. › Release the left mouse button. 451
6048-4 ch13.F
10/19/99
2:27 PM
Page 452
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
MOVE A CONTROL ust as it’s difficult to get the textual elements of your form perfect on the first attempts, it’s also almost impossible to put every control and graphic element in the right place on your form the first time through. Fortunately, Access makes it easy for you to change your controls’ locations.
J
⁄ Click the control you want to move. ¤ Move the mouse pointer over the object until it changes into a hand picture.
To move a control, simply click it and, holding down the left mouse button, drag it to the desired spot on your form. If you’ve turned on the Snap to Grid option, described later in this chapter, your object will move along the form at regular intervals (usually one-eighth or one-quarter of an inch). If you’ve turned Snap
‹ When the mouse pointer changes, click the object and, holding down the left mouse button, drag it to the desired location. › Release the left mouse button.
452
to Grid off, your object will move freely and not stay tied to the grid. You can move more than one object at a time by clicking the objects you want to move while holding down the Ctrl key, clicking one object in the group, and dragging it to the desired location.
■ The control appears in the new location.
1
6048-4 ch13.F
10/19/99
2:27 PM
Page 453
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
DUPLICATE A CONTROL any of the tasks in this chapter tell you how to modify your control’s appearance or function. When you’ve finally got everything perfect, you certainly might want to use your work again. Maybe the control should go in several places on one form (on different tabs, for example). Or maybe you want the same look for a
M
⁄ Click the control you want to duplicate.
control with a different function, such as launching a different macro from the other control. If you want to duplicate a control (copying its exact form and function) for use on the same form, you can do so very quickly from the Edit menu. If you just want to copy the look of a control, you can use the Format Painter.
¤ Click Edit. ‹ Click Duplicate.
To use the Format Painter, click the object that has the format you want to copy. Then, click the Format Painter button on the toolbar and click the target object. Access copies the format from the first object and transfers it to the target.
■ The duplicate control appears.
Note: The control will be highlighted.
453
6048-4 ch13.F
10/19/99
2:27 PM
Page 454
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
DELETE A CONTROL ou should delete a control if a function it launches has been removed from your database. For instance, if you delete a macro or Visual Basic code module, you should delete the control that launches the code. You can also delete controls if you want to replace one type of
Y
⁄ Click the control you want to delete.
454
control with another type, though it may be possible for you to change your control into another type. To see if you can change your control to another type, select the control, open the Format menu, and click Change To. Every compatible control type will be highlighted in the list.
¤ Press Delete.
If there’s any possibility you would want to reuse a control, either on the current form or another, you should create a form “graveyard,” where you keep a copy of every control you delete from forms in your database.
■ The control disappears.
1
6048-4 ch13.F
10/19/99
2:27 PM
Page 455
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
PASTE A CONTROL hen you copy or delete a control, Access writes the control to the Clipboard, making it available to every application with the ability to use objects from the Clipboard.
W
⁄ Click Edit.
You can paste a control from the Clipboard as many times as you like, so if you create a control that has the basic configuration you like, you can paste it on the form multiple times and modify the individual
¤ Click Paste.
instances into their final versions. If you prefer to use keyboard shortcuts to paste items into your forms, you can type Ctrl+V.
■ The control appears.
455
6048-4 ch13.F
10/19/99
2:27 PM
Page 456
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
USE THE RULERS AND GRID: SELECT ALL OBJECTS BETWEEN TWO POINTS ON A RULER ou can select objects on your form by clicking the objects one at a time while holding down the Shift key or clicking the mouse and dragging it to “lasso” the objects in the loop. You can also use the rulers to select all of the objects in an area
Y
⁄ Move the mouse pointer over a ruler.
of the form — by clicking a spot on the ruler, holding down the left mouse button, and dragging the mouse to the end of the range. Once you’ve selected the objects using the ruler, you can remove objects from your selection by holding down the
Ctrl key and clicking the objects you want to remove. You can reselect any objects you remove by holding down the Ctrl key and clicking them again.
■ The mouse pointer changes to a down-pointing arrow. ¤ Click the ruler at one edge of the range you want to select.
456
‹ Holding down the left mouse button, drag the pointer until it is at the far edge of the range you want to select.
6048-4 ch13.F
10/19/99
2:27 PM
Page 457
II
■ Every item in the range highlights.
› Click any blank spot on the form.
CREATE TABLES, FORMS, AND REPORTS
How do I remove an item from the selection? You can remove an item from your selection by holding down the Ctrl key and clicking the object you don’t want in your selection.
How do I add an item to the selection? Surprise—you add an item just like you remove one. Hold down the Ctrl key and click the item to add.
■ The items deactivate.
Note: Any item even partially in the area will be selected.
457
6048-4 ch13.F
10/19/99
2:27 PM
Page 458
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
USE THE RULERS AND GRID:TURNING SNAP TO GRID ON AND OFF hen you move objects around your forms and reports, you can choose to have them move at regular intervals by turning on the Snap to Grid option. The grid appears in the background of your forms. The default number of dots per inch
W
TURN SNAP TO GRID ON
⁄ Click Format.
458
is 24, though you can change that value if you like. To do so, open the form’s Properties box and enter a value in the GridX or GridY property. GridX represents the number of dots per inch horizontally on the form, while GridY represents the number of dots per inch vertically. The
¤ Click Snap to Grid.
higher the value you enter, the shorter the distance between dots. If you are using a metric ruler rather than an English ruler, the default value for the grid is ten dots per centimeter.
■ The Format menu disappears.
Note: If you reopen the Format menu while Snap to Grid is turned on, the Snap to Grid menu item will have a check next to it.
6048-4 ch13.F
10/19/99
2:27 PM
Page 459
II
TURN SNAP TO GRID OFF
⁄ Click Format.
¤ Click Snap to Grid.
CREATE TABLES, FORMS, AND REPORTS
If I’ve already placed objects before I turned the grid on, can I have them snap to the grid automatically? Yes, you can align objects to the grid automatically. See the task “Align Controls by an Edge,” later in this chapter.
How do I show and hide the grid? You can show and hide the grid by opening the View menu and clicking the Grid item.
■ The Format menu disappears.
Note: If you reopen the Format menu while Snap to Grid is turned off, the check next to the Snap to Grid menu item will have disappeared.
459
6048-4 ch13.F
10/19/99
2:27 PM
Page 460
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
GROUP AND UNGROUP CONTROLS
ccess makes it easy for you to work with more than one object at a time. To group controls, all you need to do is select the controls you want to include in your group, open the Format menu, and click Group. Once you’ve grouped a set of controls, Access treats the
A
objects as a single unit. When you click the group, a single outline appears around the items. You can move the group as a unit, using the grid if you have Snap to Grid turned on. It’s just as easy to remove a grouping as it is to create one. You can do so by clicking the group, opening the Format menu,
GROUP CONTROLS
¤ Click Format.
⁄ Select the controls you
‹ Click Group.
want to group.
460
and choosing Ungroup. After you click Ungroup, all of the objects in the group will still be selected. You can work with individual objects by clicking outside the group, which unselects the objects, and then clicking the object you want to modify or move.
■ The objects are grouped.
6048-4 ch13.F
10/19/99
2:27 PM
Page 461
II
UNGROUP CONTROLS
¤ Click Format.
⁄ Click the grouped objects.
‹ Click Ungroup.
CREATE TABLES, FORMS, AND REPORTS
Can I hold down the Ctrl key and click on an item in the group to deselect it, like I can with a normal group selection? No. When you group a set of controls, you tell Access to treat them all like one item. You can’t disable the group temporarily; you need to use the Ungroup command to dismantle the group.
How do I format all of the controls in a group at the same time? You can format all of the controls in a group at one time by clicking the group and choosing the Back/Fill, Fore/Font, or Line/Border colors you want to assign them.
■ The objects are ungrouped.
Note: Each ungrouped object appears within its own frame.
461
6048-4 ch13.F
10/19/99
2:27 PM
Page 462
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
ALIGN CONTROLS:ALIGN CONTROLS BY AN EDGE hen you create a form or report, you can place your objects wherever you like. Even if you’re not the world’s neatest person, you should probably pay some attention to making related objects, such as a series of check
W
⁄ Select the controls you want to align with each other. ¤ Click Format.
462
boxes or option buttons, line up along one edge. You can use the Snap to Grid feature to place a series of controls in a line by hand, but there is an easier way. To have Access align a set of controls along one edge, select the items
‹ Click Align. › Click Left.
you want to align (you can also group them, as described in task “Group and Ungroup Objects”), open the Format menu, click Align, and choose the edge you want to align the objects along. If you choose To Grid, the objects align to the nearest grid point.
■ Access aligns the controls by the chosen edge.
1
6048-4 ch13.F
10/19/99
2:27 PM
Page 463
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
ALIGN CONTROLS: SPACE CONTROLS EVENLY hen you add controls to your forms and reports, you should make sure they’re aligned along one edge. Presenting the controls as an orderly group makes it easier for your users to identify and use them properly. You should also pay attention to how a group of related objects
W
⁄ Select the controls you want to distribute evenly.
is spaced on your form. When you’re working with objects by hand it’s hard to make sure everything is spaced evenly, even if you have the Snap to Grid feature turned on. Like proper alignment, spacing your objects evenly makes the group look neater and the individual elements easier to read.
‹ Click Vertical Spacing. › Click Make Equal.
You can also space groups of items evenly. Using the skills you learned in task “Group and Ungroup Objects,” you can create several groups, click the groups as separate items, and space the groups evenly along a horizontal or vertical axis.
■ Access spaces the controls evenly.
¤ Click Format.
463
6048-4 ch13.F
10/19/99
2:27 PM
Page 464
13
1
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
ALIGN CONTROLS: INCREASE SPACING
fter you’ve aligned a set of controls and spaced them evenly on your form, you still may not be pleased with the results. In some cases, the items may not be spaced far enough apart to make the labels of the objects legible. You can increase the spacing between your objects by
A
⁄ Select the controls you want to realign. ¤ Click Format.
464
selecting the objects, opening the Format menu, clicking Vertical (or Horizontal) Spacing, and clicking Increase. Access instantly increases the space between your objects. You can increase the spacing between groups as well. Simply define the groups, select them,
‹ Click Vertical Spacing. › Click Increase.
and follow the instructions in this task. In this example, we increased the objects’ spacing twice to shamelessly dramatize the effect that increasing the space between objects can have.
■ The space between the controls is increased.
Note: To increase the horizontal space between two or more objects, choose Horizontal Spacing under the Format menu.
6048-4 ch13.F
10/19/99
2:27 PM
Page 465
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
ALIGN CONTROLS: DECREASE SPACING nce you’ve aligned a set of controls and spaced them evenly on your form, you may need to tweak the results. Some sets of controls can start quite far apart; when that occurs, Access allows you to decrease the spacing between controls. You can decrease the spacing between your objects by
O
⁄ Select the controls you want to realign. ¤ Click Format.
selecting the objects, opening the Format menu, clicking Vertical (or Horizontal) Spacing, and clicking Decrease. Access instantly brings your objects closer together. You can decrease the spacing between groups as well. Simply define the groups, select them, and follow the instructions in this task.
‹ Click Vertical Spacing. › Click Decrease.
In this example, we decreased the objects’ spacing twice to shamelessly dramatize the effect of decreasing the space between objects.
■ The space between the controls is decreased.
Note: To decrease the horizontal space between two or more objects, choose Horizontal Spacing under the Format menu.
465
6048-4 ch13.F
10/19/99
2:28 PM
Page 466
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
ADD HEADERS AND FOOTERS: ADD A PAGE HEADER AND FOOTER
he bulk of the information imparted by a form or report usually resides in the document’s body, or detail section. You can use labels and graphic elements to let users know how different elements of the form should be used and which sections represent which data sets in your tables and queries.
T
⁄ Click View.
466
You can make your documents even easier to read by adding a header and footer to each page of your form or report. The header can include information like the report’s title, the number of the current page, the date and time, and any other header information you might want to add to your document.
¤ Click Page Header/Footer.
Footers can be used in much the same way, though some common information included in page footers are copyright notices and company contact information.
■ The Page Header and Footer appear.
1
6048-4 ch13.F
10/19/99
2:28 PM
Page 467
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
ADD A FORM HEADER AND FOOTER uch like page headers and footers, form headers and footers can be used to impart information about the form or report that doesn’t necessarily fit with the data in the detail section. For instance, you could use a form header and footer to note
M
⁄ Click View.
that a particular printing (or electronic copy) of a report is a draft and should not be used for making business decisions or be distributed beyond the working group responsible for the database. You’re not limited to putting text elements like dates and
¤ Click Form Header/Footer.
contact information in your headers and footers. You could, if you wanted, include a chart giving a high-level overview of your report’s contents and a page break forcing the body of the report to start on the next page.
■ The Form Header and Footer appear.
467
6048-4 ch13.F
10/19/99
2:28 PM
Page 468
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
NAME A CONTROL hen you work with a lot of controls on a form, it can be hard to find the exact one you’re looking for. Fortunately, Access makes it easy to identify your controls by giving them individual names. Names make it easier for the designer to locate the objects he or she wants to work with — users never see them. As with the names of other components of an Access database, you can assign your
W
⁄ Click the control you want to name.
controls any name of up to 64 characters. Those character can include letters, numbers, spaces, and special characters except a period, an exclamation point, an accent grave (`), and brackets. The name for each control must also be unique — you can’t duplicate the name of another object in the database. Distinct names also help you when you use the Documenter to summarize the objects. It’s much easier to make sense of an object
¤ Click Properties.
named “Discontinued Check Box” than one named “CheckBox1.” You should note that object names and object labels are distinct items. Labels, although associated with database controls, are not considered part of the control. A control’s name is a property of the control.
■ The Properties box appears. Note: If the Other tab isn't clicked, click it now.
468
‹ Type the name for your control in the Name text area. › Click the Close box.
1
6048-4 ch13.F
10/19/99
2:28 PM
Page 469
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
SELECT A CONTROL FROM THE OBJECT COMBO BOX hen you’re working on a crowded form, it can take some time to locate the control you want to work on and more than a little accuracy with the mouse to click on it accurately. You can avoid these hassles by giving your controls distinctive names.
W
⁄ Click the Object combo box drop-down menu button.
Access lets you select controls by name through the Object combo box, located at the far left of the Form Design toolbar. When you click the drop-down menu button, the box displays a list of controls in your form or report. If you like, you can also type in the name of an object in
¤ Click the name of the object you want to select.
your document and press Enter. Access will highlight the control for you. Fields that are inserted in a form or report by a wizard are automatically given the same name as the field in the table or query; their labels are given the name “FieldName Label.”
■ The object you selected activates.
Note: In this case, we selected the object (Form Detail Label) we named in the previous task.
469
6048-4 ch13.F
10/19/99
2:28 PM
Page 470
13
1
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
INSERT THE DATE AND TIME atabases are heavily timedependent entities. In other words, it’s often important to know when a database was printed out so you know if the copy in your hands is too far out of date. You can pick the format you want to use for your date and time. The three date formats are
D
⁄ Click Insert.
the day and date (for example, Monday, January 4, 1999), European (for example, 4-Jan99), and brief (for example, 1/4/99). The available formats for the time are Long (for example, 10:55:33 PM), Short (for example, 10:53 PM), and 24Hour (for example, 22:53).
¤ Click Date and Time.
You can include the date, the time, or both in your form or report. When you make your selections in the Date and Time dialog box, Access previews what your current choices will look like when included in your document.
■ The Date and Time dialog box appears. ‹ Click the Include Date check box to include the date. › Click the option button with the format you want.
470
ˇ Click the Include Time check box if you want to include the time. Á Click the option button with the time format you want. ‡ Click OK.
6048-4 ch13.F
10/19/99
2:28 PM
Page 471
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
II CREATE TABLES, FORMS, AND REPORTS
INSERT PAGE NUMBERS n addition to displaying the current date and time in your forms and report, Access allows you to include page numbers. You can specify the format, location, and alignment of your page numbers. Page numbers are useful in forms and reports, especially
I
⁄ Click Insert. ¤ Click Page Numbers. Note: The Page Numbers dialog box appears.
those that span more than a few pages. Take the report the Access Database Documenter produces as an example. Even a mid-sized database could have tables with numerous fields, forms with many controls, macros, and queries to detail in the Documenter’s report. Numbering each page would help
‹ Click the radio button next to the Format you want for your page numbers.
you, your backup administrators, and successors to ensure they have a complete copy of the database’s documentation—not to mention that they would have an easier time finding items in a document in a predictable order.
■ The Page Number object appears in your form.
› Click the radio button next to the Position you want for your page numbers. ˇ Click OK. 471
6048-4 ch13.F
10/19/99
2:28 PM
Page 472
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
MOVE AN OBJECT TO THE FRONT OR BACK
ccess makes it easy for you to add graphic elements to your forms and reports. If you like, you can open the Toolbox and create boxes, lines, controls, and frames to hold pictures or other objects. Combining these elements can make your database more enjoyable to look at and easier to use, but to get the most out of your designs you need to move
A
MOVE AN OBJECT TO THE FRONT
⁄ Click the object you want to move to the front.
472
objects in front of or behind their fellows. Consider a simple background for a title you place in a form’s header. You can use the skills you’ve learned in this chapter to create the label you want by choosing the font, size, and color of the type for your title, but you can do more. Sure, you could change the label’s Back/Fill property, but you won’t get a
¤ Click Format. ‹ Click Bring to Front.
background that extends beyond the edges of the label. Instead, you can draw a rectangle, fill it with the color you want for your background, and move it to the back of your document. From there you can move the label in front of the rectangle and, almost before you know it, your background’s in place.
■ The object appears in front of the other objects.
6048-4 ch13.F
10/19/99
2:28 PM
Page 473
II
MOVE AN OBJECT TO THE BACK
⁄ Click the object to send to
¤ Click Format. ‹ Click Send to Back.
CREATE TABLES, FORMS, AND REPORTS
How do I keep two objects on the same level? You can keep two objects together (that is, on the same level) by grouping them. To learn how to group objects, see task “Group and Ungroup Objects,” presented elsewhere in this chapter.
Can I layer more than two objects—say, a background color, graphic, and text? Yes, but you only have the Front and Back commands to set the layers. So you might need to experiment with your objects to find the effect you want.
■ The object moves behind the other objects.
the back.
473
6048-4 ch13.F
10/19/99
2:28 PM
Page 474
13
CHAPTER 13: CUSTOMIZE FORMS AND REPORTS
INSERT A HYPERLINK ne of the more flexible controls you can use in your Access database is the hyperlink, or link to other objects in your database, files on your computer, and documents reachable via the World Wide Web. One advantage of hyperlinks over other methods to open documents is that the hyperlinks are very fast. For instance, it’s
O
⁄ Click Insert.
474
much quicker to use a hyperlink than a macro to open another database document. Access follows the hyperlink to the target document, and tells Windows to see if it has the program it needs to open the file. If it does, it opens it immediately. If not, it prompts you for a program to use to open the file. You can also use hyperlinks to link to documents on the World
¤ Click Hyperlink.
Wide Web or your Hypertext Transport Protocol (HTTP)compliant intranet. One great way to use hyperlinks is to link to a Web page offering help on how to use a feature in your database. You can also link to data access pages (see Chapter 23) containing fresh data from your database’s tables and queries.
■ The Insert Hyperlink dialog box appears.
‹ Click File.
6048-4 ch13.F
10/19/99
2:28 PM
Page 475
II
How do I link the hyperlink to another object in the database? You can set up a hyperlink to another object in your database by clicking the Object in This Database icon in the Link to pane, at the left edge of the dialog box.
■ The Link to File dialog box appears. › Click the file you want to link to.
Note: In this case, we clicked the Products.doc MS Word document.
ˇ Click OK.
CREATE TABLES, FORMS, AND REPORTS
How do I browse for a Web page to link to? You can browse for a Web page to link to by clicking the Web Page button, located on the right edge of the dialog box under “Browse for”.
How do I set up a link that lets a user send an e-mail message? You can use a hyperlink to create a mail message to the person of your choice by clicking the E-mail Address icon in the Link to pane and entering the address in the next screen. You can also enter a subject for the message.
■ The Link to File dialog box disappears.
Á Click OK. Note: The Insert Hyperlink dialog box disappears and your hyperlink appears on your form or report.
475
6048-4 ch14.F
10/19/99
2:40 PM
Page 476
14
CHAPTER 14: CREATE CHARTS CREATE TABLES, FORMS,AND REPORTS
2 CHAPTER 14: CREATE CHARTS
CREATE CHARTS
ometimes a well-planned spreadsheet filled with data isn’t worth as much as a simple chart summarizing that same data. What takes your readers a few moments to figure out from a data
S
sheet becomes instantly obvious in a graph. Fortunately, it’s easy to add a chart to your forms and reports.
Introducing Charts–
Selecting Fields–
Presenting your table contents or query results to users in a datasheet is a powerful technique, but you can generate even more impact by adding charts to your forms and reports. Access makes it easy to create a chart; you simply launch the Chart Wizard and answer questions until your chart is ready to go. You should pay close attention to the size of your chart. The bars and lines can be read easily whatever size you choose, but you need to make sure the axis and category labels are legible. Fortunately, it’s easy to resize your form to make everything readable. Access gives you a wide variety of chart types to choose from. You can select the most appropriate chart type from the list and tell Access whether you want the chart to be rendered in two or three dimensions. If you change your mind and want to change your chart type, you can do so at any time.
Y X
476
Like the rest of the Access wizards, the Chart Wizard gives you a great deal of flexibility in creating your chart. For example, you can pull the chart data from either a table or a query. You should use a table to get your information when all of the data you need is contained in the table’s fields, although queries are often the best source of information for charts that summarize data. For instance, suppose you want to create a chart showing how product sales in a certain category have been affected by price increases. The easiest way to acquire that information is to create a query that pulls sales data from one table, sorts it by date, and associates it with price information from another table. You could go even further by grouping the query results by customer, illustrating how the price increase affected orders from each of your clients.
6048-4 ch14.F
10/19/99
2:40 PM
Page 477
Select a Chart Type–
Edit Chart Data–
Y
II CREATE TABLES, FORMS, AND REPORTS
The type of chart you choose has a crucial effect on the presentation of your data. For instance, line graphs are useful for illustrating how values change over time; they make it easy to compare trends among similar items. In the sample Northwind database included with Access, a line graph would effectively show how sales for one or more products vary by the month, quarter, or year. In the Chart Wizard, Access displays a description for the selected chart type, which summarizes the types of data the chart is designed to display and compares the selected chart type to the rest of the available types.
When you open your chart for editing, Microsoft Graph displays the datasheet used to create the chart. You can use the skills you learned in Chapter 4 to move around in the datasheet, select rows and columns of data, and edit the values. You should get in the habit of saving your changes every few minutes. To save your changes, click the File menu and click Update. Update operates like the Save option in most other programs; it writes the current state of your chart to disk and lets you keep working. Updating your chart after you’ve found the data that illustrates a vital point will save you time in the long run.
Y X
X
Show Data Labels– Change Colors of Chart Elements– Access makes it easy to change the appearance of your charts as well. You can change the color of the background, axes, text, and other elements. In addition to changing colors, you can experiment with different patterns, effects, and textures. Depending on the type of chart you’re creating, the ranges of data, and the tastes of your audience, you can make your charts as visually simple or complex as you like.
Creating a chart with just gridlines and lines showing relative values is a valuable tool for presenting comparative data. However, sometimes you’ll want to display the exact values represented by each line, bar, section, or point. Data labels do just that. 100 75 50
477
6048-4 ch14.F
10/19/99
2:40 PM
Page 478
14
CHAPTER 14: CREATE CHARTS
CREATE A CHART atasheets are useful devices for displaying your data in detail. As you learned in Chapter 10, for instance, you can perform calculations on fields in a query to help your users interpret the query’s results. But a chart can give your data instant impact, greatly enhancing the raw results and any written explanation of those results.
D
⁄ Click the form or report you want to add a chart to. Note: For this example, we chose a report.
478
You can make your chart as large or small as you like, although you should ensure the data can be read easily. If you add axis and other data labels to your chart, make sure they’re legible as well. If your chart is too large or too small for your needs, you can resize it by following the steps in task “Resize a Control” from Chapter 13.
¤ Click Design.
You’ll also be able to choose which colors to assign to the different elements of your charts. Access automatically assigns colors that are visually distinct but not “distinctive.” Change the defaults any time you like, making them brighter or stronger, or even more subtle, as you like.
■ The Design view of your report appears. ‹ Move the mouse pointer over the bottom edge of the report section to hold your chart.
Note: The pointer will change to a horizontal bar with a vertical arrow.
› Drag the edge until the section is large enough to display your chart.
6048-4 ch14.F
10/19/99
2:40 PM
Page 479
II
■ The report section expands.
ˇ Click Insert. Á Click Chart.
CREATE TABLES, FORMS, AND REPORTS
My report needs to be resized horizontally as well as vertically. How do I do that? You can resize your report horizontally by following the steps in task “Resize a Form or Report,” presented in Chapter 13.
I don’t know what size to make my chart. Is there a quick way to have Access assign a default area for the chart? You can have Access assign a default size to the chart by clicking any blank spot in the report.
■ Your pointer changes to a crossbar cursor. ‡ Click on a spot marking one corner of your chart. Note: A rectangle appears when you move the mouse.
° Holding down the left mouse button, drag the pointer until the rectangle is the desired size for your chart. Note: When you release the left mouse button, the Chart Wizard launches.
479
6048-4 ch14.F
10/19/99
2:40 PM
Page 480
14
CHAPTER 14: CREATE CHARTS
USE THE CHART WIZARD: SELECT FIELDS hen you launch the Chart Wizard, you’re asked to pick a query or table to supply the data for your chart. You can’t combine fields from more than one object in a single chart. If you want to use fields from more than one
W
⁄ Click Both.
query or table, you should create a new query to bring all of your records into a single file. In general, when you make a chart using the wizard, all of the fields from a table are available for you to use. But depending on the chart type you choose, you
may be limited to drawing values for the body of the chart from a single field. If you need to combine data from more than one field into a single value, you will need to modify your table or create a query with a calculated field.
■ The list in this area expands to include both tables and queries. ¤ Click the name of the table or query that contains the fields you want to use in your chart.
480
Note: In this example, we chose Product Sales for 1995.
‹ Click Next.
6048-4 ch14.F
10/19/99
2:40 PM
Page 481
II
■ The next Chart Wizard screen appears.
› Click the first field you want to use in your chart. ˇ Click the forward arrow button.
CREATE TABLES, FORMS, AND REPORTS
How do I change the table or query my chart is based on? You can change the table or query your chart uses by clicking the Back button until you arrive at the first Chart Wizard screen. Once at that screen, click the new chart or table you want to use and click Next.
How do I automatically add all fields in the table to the chart? Click the Add All Fields button, which looks like a double right arrow
■ The selected field appears in the Fields for Chart pane.
Note: For this exercise, add all of the fields to the Fields for Chart list.
Á Click Next.
481
6048-4 ch14.F
10/19/99
2:40 PM
Page 482
14
CHAPTER 14: CREATE CHARTS
USE THE CHART WIZARD: SELECT AND PREVIEW A CHART TYPE
he most important decision you make when creating a chart is which data you want to use. The second most important consideration is which type of chart presents your data most effectively. With the Chart Wizard, you can choose from 20 types of graphs, although some of the
T
■ The next Chart Wizard screen appears. ⁄ Click the button corresponding to the type of chart you want to create.
482
types are two- and threedimensional versions of the same basic graph. You can preview the chart you choose in the wizard, and you can change the chart type at any time, so feel free to experiment. To change the chart type after exiting the wizard, open the form containing the chart in Design
Note: In this example, we chose a column chart.
view and double-click the chart. The menu bar will change to include the Chart menu. You can open the Chart menu, choose Type, and select another chart type from the list presented. Access will let you know if you’ve picked an incompatible type for your data.
■ The chart button you pressed recesses.
■ A description of the chart type you selected appears in this space. ¤ Click Next.
6048-4 ch14.F
10/19/99
2:40 PM
Page 483
II
■ The next Chart Wizard screen appears.
‹ Click Preview Chart.
CREATE TABLES, FORMS, AND REPORTS
When should I choose a two-dimensional chart over a three-dimensional chart? Whether you choose a two- or threedimensional chart is largely a matter of taste, although you might consider using two-dimensional charts for preliminary summaries and three-dimensional charts for finished analysis.
If I preview the chart and decide I don’t like the chart type, can I change it? Yes. Just click the Back button in the wizard and pick a new type.
■ A preview version of your chart appears.
› Click Close.
483
6048-4 ch14.F
10/19/99
2:40 PM
Page 484
14
CHAPTER 14: CREATE CHARTS
USE THE CHART WIZARD: ASSIGN AXIS VALUE SOURCES hen you create a chart in Access, the program guesses which value you want to use for which axis. In a column chart, for instance, the x, or horizontal, axis is used to display the data categories (for example, product names) and the y, or vertical, axis is used to display the value associated with
W
■ Access guesses which field should be used for which axis. ⁄ Double-click the field name in the Value axis box.
484
the category (for example, sales). A bar chart switches the values of the axes but is otherwise the same. Access uses a third column in some charts to provide series values. As an example, suppose you wanted to create a chart showing the sales for each product, with the products sorted by
Note: Access automatically takes the sum of the values on the value axis.
category. The vertical axis would display the sales total for each product, the horizontal axis would contain the category names, and the series values would be drawn from the product names. In essence, you are using the series value to assign a sort order to the values on the horizontal axis.
■ The Summarize dialog box appears.
¤ Click the summary operation you want Access to perform. Note: In this case, we chose Sum.
‹ Click OK.
6048-4 ch14.F
10/19/99
2:40 PM
Page 485
II
■ The Summarize dialog box disappears.
› Click Next.
CREATE TABLES, FORMS, AND REPORTS
How do I have Access use the values from more than one query or table field (such as by taking the average of two values) on an axis? To combine the values from more than one field into a single field you will need to modify the source table or query so the information you want is contained in a single field.
How do I change the field Access uses for the values on an axis? You can assign an axis a new field to draw its values from by dragging the name of the field onto the box associated with the target axis.
■ The next Chart Wizard screen appears.
■ The new summary option appears in the Value Axis box.
485
6048-4 ch14.F
10/19/99
2:40 PM
Page 486
14
CHAPTER 14: CREATE CHARTS
USE THE CHART WIZARD: CHANGING YOUR CHART FROM RECORD TO RECORD eing able to add charts to forms and reports is extremely useful, but you may not always want to have the same chart appear on every page. Access lets you establish which fields contain the values that control how the chart will appear in your reports. Varying the data your chart depicts based on the contents of
B
⁄ Click the drop-down menu button in the Report Fields box.
the record displayed on the screen can be a handy tool for comparing a single data point (such as a particular sale) to a larger trend (such as a salesperson’s overall sales or sales to a client). You could also vary the chart based on the quarter of the year, the discount offered on an order, or the client.
If you like, vary your chart based on the contents of more than one field. You should experiment with different combinations of fields to see which group and order gives you the results you want.
■ A list of all available fields and their data types appears. ¤ Click the field you want to vary from record to record. Note: In this case, we chose Category Name.
486
‹ Click the drop-down menu button in the Chart Fields box.
6048-4 ch14.F
10/19/99
2:40 PM
Page 487
II
■ The menu appears. › Click the corresponding field in the chart.
Note: In this case, the corresponding field is Category Name.
CREATE TABLES, FORMS, AND REPORTS
How do I turn off varying my chart from record to record? You can turn off varying your chart from record to record by clicking the Report Fields drop-down menu and clicking No Field for each field you have entered.
How can I get help on customizing my chart? For help on customizing your chart, click the Contents tab, open the Graphics: Chart book, and click the help page entitled “Customize a Chart.”
■ The field appears in the Chart Fields box.
ˇ Click Next.
487
6048-4 ch14.F
10/19/99
2:41 PM
Page 488
14
CHAPTER 14: CREATE CHARTS
USE THE CHART WIZARD: COMPLETE THE CHART ow that you’ve selected a data source for your chart, chosen what type of chart Access will use, and ordered the data, it’s time to name your chart and have Access insert it into your form or report. You should give your chart a descriptive name, one that will
N
⁄ Type a name for your chart in this space.
488
make it stand out from the other controls and objects on your form or report. Although your chart will stand out from the rest of the objects on your form or report, it is a good idea to stay in the habit of naming each element so that it can be easily identified from a text list.
¤ Click Finish.
Help on working with charts is readily available from the final wizard screen. If you want Access to display the main chart help file, simply click the check box next to “Display Help on working with my chart.”
■ The chart appears in your report.
1
6048-4 ch14.F
10/19/99
2:41 PM
Page 489
II CREATE TABLES, FORMS, AND REPORTS
14
CHAPTER 14: CREATE CHARTS
DELETE A CHART eleting a chart is a simple process: simply click the chart and use the Delete option from the Edit menu to erase it from your chart. If you aren’t sure you want to delete the chart permanently, such as if you just want to see what the form or
D
⁄ Click the chart.
report looks like without the chart included, you should use the Cut option instead of Delete. Unlike when you delete forms, reports, queries, or data access pages, Access does not ask you if you are certain you want to delete a chart. You can recover
¤ Click Edit.
the chart quickly by clicking the Edit menu and choosing Undo Delete, but if you close Access without restoring the chart it will be erased from the Windows Clipboard and will need to be recreated from scratch.
■ The chart disappears.
‹ Click Delete.
489
6048-4 ch14.F
10/19/99
2:41 PM
Page 490
14
1
CHAPTER 14: CREATE CHARTS
OPEN A CHART
ccess makes it easy for you to examine a chart up close, where you can see the data that underlies the chart. The data itself is presented in a spreadsheet and can be edited. When you open a chart for viewing or editing, Access launches Microsoft Graph.
A
⁄ Click the chart you want to open. ¤ Click Edit.
490
Microsoft Graph is a companion program that can interact with any Microsoft Office program. Thus, any chart you generate in Access can be copied or linked to any other Office document. In addition to viewing the data, clicking Open from the Chart Object submenu gives you
‹ Click Chart Object. › Click Open.
direct access to the chart’s elements, like the axis labels, graph bars and lines, and even the chart type. You can change any of those elements from within Microsoft Graph.
■ Microsoft Graph launches.
■ Your chart appears in the Microsoft Graph window.
6048-4 ch14.F
10/19/99
2:41 PM
Page 491
II CREATE TABLES, FORMS, AND REPORTS
14
CHAPTER 14: CREATE CHARTS
CLOSE A CHART hen you are done working with your chart in Microsoft Graph, you should close the Chart window and return to the form or report from which you launched Microsoft Graph. Unlike when you delete a form, report, or query, Microsoft Graph does not verify that it is OK to quit editing the chart and return to Access. That’s not a
W
⁄ Click the Close box.
problem — Graph automatically saves your changes when you close it and return to Access. However, if you are interrupted while you are modifying a chart (such as by a power failure) and don’t have the chance to close Graph normally, you could lose your changes. To make sure Microsoft Graph keeps your changes, you should get in the habit of clicking the
File menu and clicking Update every few minutes. Update operates like the Save option in most other programs; it writes the current state of your chart to disk and lets you keep working. Updating your chart after a tricky change you finally got right will save you time in the long run.
■ The Microsoft Graph window disappears.
491
6048-4 ch14.F
10/19/99
2:41 PM
Page 492
14
CHAPTER 14: CREATE CHARTS
EDIT A CHART: CHANGE COLORS OF CHART ELEMENTS
he default color scheme varies by chart type, but it always features contrasting colors that don’t overpower their neighbors. Although the default colors are
T
⁄ Open the chart as you learned to do in task “Open a Chart,” presented earlier in this chapter. ■ Microsoft Graph launches.
492
usually well-chosen, you can change them any time. If you do want to change any element of your chart, such as the background, foreground, or axis colors, you can do so quickly
by double-clicking your chart while in Design view and using Microsoft Graph’s editing capabilities.
¤ Double-click the chart element you want to modify.
■ The Format window appears.
■ A preview of the color appears in this space.
Note: Microsoft Graph lets you know which chart element your mouse pointer is over by displaying a pop-up label. In this example, the pointer is over the Chart Area (i.e., the background).
‹ Click the color you want to assign to the chart element you selected.
› Click OK.
6048-4 ch14.F
10/19/99
2:41 PM
Page 493
II
■ The chart element takes on the color you assigned.
ˇ Click the Close box.
CREATE TABLES, FORMS, AND REPORTS
How do I go beyond simple colors and add textures, patterns, and other fill effects to my chart elements? While in the Format window, click Fill Effects. A new screen will appear with tabs for patterns, textures, and other effects. Explore these controls and, when you want to see what your choices look like, click OK.
Is there a quick way to undo my change? You can undo your change by clicking the Edit menu and clicking Undo.
■ Microsoft Graph closes.
493
6048-4 ch14.F
10/19/99
2:41 PM
Page 494
14
CHAPTER 14: CREATE CHARTS
EDIT A CHART: EDIT CHART DATA nce you’ve created your chart, you can open it in Design view and look at the data Microsoft Graph uses to create the lines and bars in the chart. You can edit the datasheet’s values as you learned to do in Chapter 4. Choosing when to modify the data underlying your chart can be difficult, though there are
O
⁄ Click the chart you want to edit. ¤ Click Edit.
some circumstances when it’s the right thing to do. For instance, if you’ve duplicated a form rather than created a new one, you could either erase the old chart or, if you want to use the same type of chart and only change the underlying data, you can open the copy of the chart and change the data to reflect the contents of your new chart.
‹ Click Chart Object. › Click Open.
You could also change the data in your chart if you have received updated figures, or if you want to create a hypothetical chart displaying a projection.
■ The chart and data used to form the chart appear. ˇ Click the title bar of the datasheet.
Á Edit the data as you learned to do in the Chapter 4 task “Edit Data.” Note: For this example we changed the value in cell C1 (3rd Qtr, East) to 30.
‡ Press Enter. 494
6048-4 ch14.F
10/19/99
2:41 PM
Page 495
II
■ The chart changes to reflect the new data.
° Click the Close box.
CREATE TABLES, FORMS, AND REPORTS
How do I change the font in which the data is displayed in Microsoft Graph? You can change the font the data is displayed in by clicking the drop-down menu button on the Font list box, located at the right end of the Graph toolbar, and clicking the font you want.
Can I add a whole new row of information in Microsoft Graph? Yes, you can add any data you want. Remember, though, that the graph isn’t linked to the table it is based on; you will only change the graph, not the table.
■ The Microsoft Graph window disappears.
495
6048-4 ch14.F
10/19/99
2:41 PM
Page 496
14
CHAPTER 14: CREATE CHARTS
EDIT A CHART: SHOW DATA LABELS ost of the time it’s easy to read a chart and get a feel for the relative values represented within it. Other times, such as when the scale is quite large (say 10,000 units per grid line), the values are very close together, or your users would benefit from having the precise values at their
M
⁄ Open the chart as you learned to do in task “Open a Chart,” presented earlier in this chapter. ■ Microsoft Graph launches.
496
fingertips, displaying the exact values represented by a line, bar, or point on your graph would be a good idea. You will need to take into account how much room you have for your chart on your form or report. If you’re pressed for space, you might consider using lines and labels to “call out” the
¤ Click Chart. ‹ Click Chart Options.
values represented on your chart. If space is truly at a premium, you could put the chart in a separate form and create a control (as you learned to do in the Chapter 13 task “Create a Control”) that opens the other form when clicked.
■ The Chart Options window appears.
› Click the Data Labels tab.
6048-4 ch14.F
10/19/99
2:41 PM
Page 497
II
■ The Data Labels screen appears. ˇ Click Show Value.
Á Click OK.
CREATE TABLES, FORMS, AND REPORTS
How do I show the legend key next to a label? You can show the legend key for a label by clicking the “Legend key next to label” check box.
Can I label the axes as well? Yes. Just add names in the axis fields in the Titles pane of the Chart Options box.
■ The data labels appear on your chart.
‡ Close the chart as you learned to do in task “Close a Chart,” presented earlier in this chapter.
497
6048-4 ch14.F
10/19/99
2:41 PM
Page 498
14
CHAPTER 14: CREATE CHARTS
EDIT A CHART: SHOW THE DATA TABLE harts are great tools for summarizing data, but they’re not always a substitute for having the raw data. With Access, you get the best of both worlds. Not only can you show a chart illustrating the underlying data, but you can also show the data itself. By telling Access to display the datasheet graph used to generate the chart,
C
⁄ Follow steps 1-3 in task “Edit a Chart: Show Data Labels” to open the Chart Options screen.
498
you can satisfy viewers who appreciate summaries but like to see the information a chart is based on. Displaying the data behind your chart relates the actual values to the image displayed in your form. If it’s been a while since you created a chart, you should consider either displaying data labels (as you learned to do
¤ Click the Data Table tab.
in the previous task) or examining the data behind your chart. This consideration is especially true if you didn’t create the chart yourself. You should take the time to look at the values behind the chart to get a better feel for the information it represents.
■ The Data Table page appears.
Note: The data table appears below the chart.
‹ Click “Show data table.”
› Click OK.
1
6048-4 ch14.F
10/19/99
2:41 PM
Page 499
II CREATE TABLES, FORMS, AND REPORTS
14
CHAPTER 14: CREATE CHARTS
EDIT A CHART: ADD AXIS TITLES
he Chart Wizard allows you to create charts that are very easy to read, especially when you know what data is being displayed and how it’s been summarized. For other users, and yourself if you haven’t looked at a chart for a while, it can be hard to figure out what information is being represented. You can make your charts easy to
T
⁄ Follow steps 1-3 in task “Edit a Chart: Show Data Labels” to open the Chart Options screen.
read by adding descriptive axis titles. Axis titles tell the viewer exactly what information is represented by the values on the horizontal (or x) axis and the vertical (or y) axis. If space is at a premium and displaying axis titles takes up too much room, consider using data labels to
¤ Click the Titles tab.
explain which data is represented on which axis. Whatever your choice, save your changes frequently. Although redoing a simple task like adding axis titles won’t take that much time, updating your chart regularly will save you time in the long run.
■ The Titles page appears.
ˇ Click OK.
‹ Type the title for the Category axis in this space. › Type the title for the Value axis in this space.
499
6048-4 ch14.F
10/19/99
2:41 PM
Page 500
14
CHAPTER 14: CREATE CHARTS
EDIT A CHART: SHOW AND PLACE THE LEGEND
ccess automatically includes a listing of the colors used to represent the various data categories in your chart. This list, called a legend, gives anyone who views your chart the ability to interpret the data quickly and accurately. Once you’ve added your legend, you can change its
A
⁄ Follow steps 1-3 in task “Edit a Chart: Show Data Labels” to open the Chart Options screen.
location on the chart or hide it again with a few clicks of the mouse. If you’re pressed for space and don’t have the room to add your legend, you could put it on another form and add a hyperlink to that form. You could also put your chart on the front page of a tab control and display the legend on another page.
¤ Click the Legend tab.
Regardless of the method you choose, you should save your changes whenever you’re happy with what you’ve done. While a simple task like moving or hiding the legend is easy to redo, you’ll save time in the long run by updating your chart regularly.
■ The Legend page appears.
PLACE THE LEGEND
⁄ Click the radio button corresponding to the area of the page on which you would like the legend to appear. Note: In this case, we clicked Left.
500
6048-4 ch14.F
10/19/99
2:41 PM
Page 501
II CREATE TABLES, FORMS, AND REPORTS
When should I consider hiding the legend? You should consider hiding the legend when you have a limited amount of space to fit the chart into. If you can make the chart legible by making the main area larger and removing the legend, you should do so.
■ The legend appears on the left side of the chart.
HIDE THE LEGEND
■ The legend disappears.
⁄ Click Show Legend.
501
6048-4 ch15.F
10/19/99
2:43 PM
Page 502
15
CHAPTER 15: CREATE PIVOT TABLES CREATE TABLES, FORMS,AND REPORTS
2
CHAPTER 15: CREATE PIVOT TABLES
CREATE PIVOT TABLES
A
ccess gives you a number of useful tools to arrange and summarize your data, such as filters and crosstab queries. If you also have
Introducing Pivot Tables–
“Pivot” Pivot Tables–
A pivot table is a type of spreadsheet you can create from a query or table in your Access databases. Pivot tables aren’t native Access objects; instead, they are Microsoft Excel objects you can include in your Access databases. You need to have Excel installed to use pivot tables. The best way to become familiar with a pivot table is to open one and experiment. You can rearrange the data in the table in many ways, limited only by the fields you’ve used to create the pivot table. You will need to perform any calculations required to provide the data for your pivot table in the underlying table or query. Pivot tables give you a lot of flexibility in arranging your data, but they do not have extensive calculation or data summary capabilities. JAN
Microsoft Excel installed, you can use an even more powerful tool: pivot tables.
FEB.
MAR.
APR.
Pivot tables present the data from your tables and queries in an easily understood and flexible package. You can pivot, or rearrange, your data to emphasize any aspect of the dynaset you like. When you move a field name in a pivot table, it rearranges the data based on where you put it on an axis. On the horizontal axis, the order of the fields denotes how the data columns are arranged. For instance, if you use the Category Name and Product Name fields to arrange your data, the columns will start with the first product in the first category (arranged alphabetically) and continue until the last product name in the last column is reached.
42.5
50.1
70.0
65.8
1998
49.4
58
68.4
50.3
1997
57.1
64.2
63.3
75.2
1998
70.7
72.9
77.4
83.6
FEB.
1997
42.5
50.1
70.0
65.8
1998
49.4
58
68.4
50.3
1997
57.1
64.2
63.3
75.2
1998
70.7
72.9
77.4
83.6
Jones 1997 1998
502
MAR.
APR.
Jones
Smith 1997
JAN Smith
Smith JAN
42.5
FEB
49.4
50.1 58
MAR 70.7
72.9
APR
57.1
64.2
MAY
70.7
72.9
6048-4 ch15.F
10/19/99
2:43 PM
Page 503
Filter Data in a Pivot Table–
Year 1996 1997 1998 Cancel
OK
1996 1997 1998
II
Creating a pivot table in Access is simple and straightforward, thanks to the Pivot Table Wizard. The wizard walks you through the process of creating a pivot table step by step, with explanations and additional help available throughout the process.
CREATE TABLES, FORMS,AND REPORTS
Once you have established the hierarchy of fields on each axis of your pivot table, you can limit the data your pivot table displays by selecting values from fields in your table. When you click on the drop-down menu next to a field name, an index of the values in that field appears. You can control which entries are included in your pivot table by checking and unchecking those entries. For instance, if you were only concerned with sales in two categories, you could use the drop-down lists to refine your table. If you want to filter your pivot table’s dynaset based on numerical data or calculations, such as only showing the top three salespeople for a quarter, you will need to include that filter in the underlying table or query. To learn more about creating filters for your tables and queries, refer to Chapter 5.
Create a Pivot Table–
Customize Your Pivot Table– When you examine the Sales Analysis pivot table, included with the sample Northwind database, you may notice that Access included subtotals for each data element (such as a quarter of a year or a product) as well as grand totals for each column and row. You can tell Access to turn those features, and many others, off or on by clicking the Options button inside the wizard. You can reenter the Pivot Table Wizard at any time by right-clicking the Excel spreadsheet and clicking Wizard.
Smith JAN
40.5 42.5
50.1
FEB
47.3 49.4
58
MAR 69.2 70.7
72.9
APR
56.3 57.1
64.2
MAY
68.9 70.7
72.9
Month
Total
Month
Total
Running
JAN
150
JAN
150
150
FEB
170
FEB
170
320
MAR
142
MAR
142
462
APR
215
APR
215
677
503
6048-4 ch15.F
10/19/99
2:43 PM
Page 504
15
CHAPTER 15: CREATE PIVOT TABLES
EXAMINE A PIVOT TABLE
ivot tables have a lot in common with crosstab queries, although pivot tables go far beyond what can be done with a standard crosstab query. A crosstab query is like a spreadsheet — it relates a value to two other values. For instance, you could generate a list of monthly sales figures for each
P
⁄ Click Forms.
504
salesperson and display them in a crosstab query with the sales representatives’ names as row headings, the month and year as column headings, and the body of the query filled in by the corresponding sales value. Crosstab queries are useful, but limited. To extend what you can do with spreadsheet-like
¤ Double-click Sales Analysis.
objects, Access has “borrowed” pivot tables from Microsoft Excel. You should open an existing pivot table to get a feel for how the objects are constructed and can be used. Once you get to know them, you’ll find pivot tables to be exceptionally useful items.
■ The Sales Analysis pivot table form appears.
‹ Click Edit Pivot Table.
6048-4 ch15.F
10/19/99
2:43 PM
Page 505
II
■ The pivot table opens as a Microsoft Excel worksheet.
› Click File. ˇ Click Close & Return to
CREATE TABLES, FORMS, AND REPORTS
Can I edit a pivot table without launching Excel? You can edit a pivot table in Microsoft Access by right-clicking the table and selecting Worksheet Object ➪ Edit from the pop-up menu that appears. The Access interface is not as intuitive or flexible as the Excel interface, so you should use the latter whenever possible.
How do I revert my pivot table to its original configuration? The best way to ensure you keep a record of your pivot table’s original configuration is to make a backup copy of the form, as you learned to do in the Chapter 11 task “Copy a Form” before you change anything.
■ Microsoft Excel disappears.
Pivot Form.
505
6048-4 ch15.F
10/19/99
2:43 PM
Page 506
15
CHAPTER 15: CREATE PIVOT TABLES
PIVOT A PIVOT TABLE
fter you’ve created your pivot table, you should move its elements around to see how the display changes. Pivoting a pivot table is a lot like changing the grouping levels in a report (described in Chapter 12). Moving a field name to the left of another column heading (or above a row heading) gives the
A
⁄ Open the Sales Analysis pivot table for editing as you learned to do in the previous task, “Examine a Pivot Table.”
506
heading moved higher grouping priority than the headings below or to the right of it. You should experiment with a variety of pivots before you decide on a “normal” state for your pivot table. Write down the exact configuration of the table when it is in its normal state. Keeping a written list of the
¤ Click LastName and, holding down the left mouse button, drag the LastName box to the right of Years.
column headings, row headings, and headings in the Page area (which can be used to filter your pivot table, as you’ll learn in the next task) will ensure that you can return a pivot table to the state you need to illustrate your points.
■ The pivot table pivots, with LastName becoming part of the column values.
1
6048-4 ch15.F
10/19/99
2:43 PM
Page 507
II CREATE TABLES, FORMS, AND REPORTS
15
CHAPTER 15: CREATE PIVOT TABLES
FILTER A PIVOT TABLE ne of the advantages of pivot tables is that they can display an enormous amount of data at a time. The disadvantage is that an enormous amount can be way too much for you or users to take in at one time. Fortunately, you have the option to restrict the number of categories displayed in your table. Clicking the drop-down menu button next to a field name
O
⁄ Click the drop-down menu button of the field name containing the values you want to use to filter your pivot table. Note: In this case, we chose LastName.
displays an index of the values in that field with a check box next to each value. Unchecking a box removes the data relating to that entry from your table. For instance, if you wanted to show sales figures for one or two salespeople in a specific pivot, you could uncheck the other names in your list. You can also filter your pivot table’s data on numerical data or
¤ Click the values you want to use to filter your pivot table.
calculations, but there’s no direct way to do it in the pivot table itself. Instead, you’ll need to perform the calculations in the underlying table or query and filter the data using one of the techniques you learned in Chapter 5.
■ The pivot table appears in filtered form.
Note: In this case, we chose Buchanan, Callahan, and Davolio.
‹ Click OK. 507
6048-4 ch15.F
10/19/99
2:43 PM
Page 508
15
CHAPTER 15: CREATE PIVOT TABLES
CREATE A PIVOT TABLE enerating a pivot table may seem like a daunting process, but Access makes it easy to do with the Pivot Table Wizard. The wizard, which you can launch from the New Form dialog box, steps you through the process and offers explanations and help throughout.
G
⁄ Create a query to use as the base for your pivot table, as you learned to do in Chapter 10. Note: In this example, we saved the new query under the name Supplier Analysis.
508
Consider creating a pivot table any time you want to encapsulate more data than will fit into a crosstab query or table into a single database object. Part of the beauty of pivot tables is that they can display as much or as little data as you like. If you want to remove a field from the body of the report, you simply move it to
¤ Click the New Object drop-down menu button. ‹ Click Form.
the Page area of the pivot table. You can still use the contents of that field to filter your table, and can add it back into the body of the table at your leisure.
■ The New Form dialog box appears.
› Click Pivot Table Wizard. ˇ Click OK.
6048-4 ch15.F
10/19/99
2:43 PM
Page 509
II CREATE TABLES, FORMS, AND REPORTS
How do I add fields from more than one table or query to my pivot table? You can add fields from more than one table or query by clicking the Tables/Queries drop-down menu button in the second screen of the wizard and choosing the next table or query from which to add fields.
■ The Pivot Table Wizard Introduction screen appears.
Á Click Next.
■ The next Pivot Table Wizard screen appears.
‡ Click the Tables/Queries drop-down menu button. ° Click Query: Supplier Analysis. CONTINUED
509
6048-4 ch15.F
10/19/99
2:43 PM
Page 510
15
CHAPTER 15: CREATE PIVOT TABLES
CREATE A PIVOT TABLE t’s all right to add all of the fields from a table or query to your pivot table. At worst, you can leave the tables on the sidelines while you use the wizard to build your pivot table. You could also drag unneeded fields to the Page area of the Pivot Table Wizard Design
I
■ The fields in the Supplier Analysis query appear in the Available Fields pane.
510
CONTINUED
screen, giving users the ability to use the drop-down menus associated with those fields to filter the pivot table’s contents. The downside to adding a lot of fields to a pivot table is that a user could use the fields to filter the dynaset without leaving visible clues that the filtering is
· Click the Add All Fields button.
taking place. Since the field names don’t change in appearance when users limit which values from a field will be used, another user would need to check each field name to see if table results were incorrectly configured for their needs.
■ All of the fields appear in the Fields Chosen for Pivoting pane.
‚ Click Next.
6048-4 ch15.F
10/19/99
2:43 PM
Page 511
II
■ The Checkered Flag screen appears.
— Click Layout.
CREATE TABLES, FORMS, AND REPORTS
How do I work with the layout screen? You drag the field names where you want them to go in the pivot table. See the next task, “Define Your Pivot Table’s Layout,” for details.
What’s behind the Options button? Click Options to turn on and off such items as grand totals for columns and rows, table autoformat, and general layout options.
■ The Layout screen appears.
511
6048-4 ch15.F
10/19/99
2:43 PM
Page 512
15
CHAPTER 15: CREATE PIVOT TABLES
CREATE A PIVOT TABLE: DEFINE YOUR PIVOT TABLE’S LAYOUT
he order you give your fields in a pivot table directly affects how the dynaset is organized. As in a spreadsheet, data is organized by column and row. Unlike in a spreadsheet, however, the data is grouped by the values in the fields supplying the data. For
T
⁄ Click the box with the name of the field that will provide the data for your pivot table and, holding down the left mouse button, drag it to the Data area.
512
more information on grouping and how it affects your data, see Chapter 12. Remember that you can only draw data from one column in the underlying table or query. Plus, any calculations involving the data in your pivot table will need to be performed before the
Note: In this case, we chose the Quantity field.
table is generated. For instance, if you want to find your firm’s average monthly sales, you’ll need to calculate that value in a query or table and include the field with the result in the pivot table.
■ The field name appears in the Data area.
¤ Drag the box representing the first field you would like to appear in the data rows.
Note: This field will serve as the first level of organization for the fields in the data rows. We chose CategoryName.
6048-4 ch15.F
10/19/99
2:43 PM
Page 513
II
How do I use the Pivot Table Wizard to edit an existing pivot table? After you click the Edit Pivot Table button, you can launch the Pivot Table Wizard from within Excel by opening the Data menu and clicking PivotTable and PivotChart Report.
■ CategoryName appears in the Row area.
‹ Drag the box representing the second field you want to use for your rows to the Row area, below the first field.
Note: This field will serve as the second level of organization for the data rows. We chose ProductName.
CREATE TABLES, FORMS, AND REPORTS
How can I add or remove field subtotals? Double-click a field name. In the box that appears, click a button in the Subtotal area.
How do I know where on an axis a field name will appear? You can tell where a field name will appear by the presence of a large gray cursor that appears when you move the field name over an axis. The cursor appears in the position the field name will assume when you release the left mouse button.
■ ProductName appears in the Row area, below CategoryName.
› Drag the box representing the field you want to use for your data columns to the Column area.
Note: In this case, we chose the LastName field.
CONTINUED
513
6048-4 ch15.F
10/19/99
2:43 PM
Page 514
15
CHAPTER 15: CREATE PIVOT TABLES
CREATE A PIVOT TABLE: DEFINE YOUR PIVOT TABLE’S LAYOUT CONTINUED our pivot table contains cells of data corresponding to the value at the head of the cell’s column as well as the value at the head of the cell’s row. You can also assign fields to the Page area — although fields in the Page area don’t affect the
Y
■ LastName appears in the Column area.
514
grouping of the data in the pivot table, you can filter your table data based on values in fields in the Page area. When you pivot your pivot table, it’s a good idea to write down the specific order of fields in the column and row areas (and
ˇ Drag the CompanyName field to the Page area.
filter, if any) that led to the arrangement. Although you can undo pivots made since the last time you opened your pivot table, if you close your pivot table, Excel’s record of the previous pivots is erased.
■ CompanyName appears in the Page area.
Á Click OK.
6048-4 ch15.F
10/19/99
2:43 PM
Page 515
II
■ The Checkered Flag screen appears.
‡ Click Finish.
CREATE TABLES, FORMS, AND REPORTS
How do I have Access refresh my pivot table’s data at regular intervals? To have Access refresh your pivot table data at regular intervals, click the Options button in the Pivot Table Wizard, check the Refresh Every check box, and enter how often (in minutes) you want Access to refresh the data.
How do I have Access refresh my pivot table’s data whenever I open the form? You can have Access refresh your pivot table’s data whenever you open the form by clicking the Options button in the Pivot Table Wizard and checking the Refresh on Open check box.
■ Your pivot table appears in Form view.
515
6048-4 ch16.F
10/20/99
3:41 PM
Page 516
16
CHAPTER 16: CREATE MACROS CREATE TABLES, FORMS,AND REPORTS
2 CHAPTER 16: CREATE MACROS
INTRODUCING MACROS acros are one of the most versatile tools in your Access arsenal. You can use them to open forms, filter table data or query results, display messages to your users, and even run other macros. Macros are composed of individual instructions that tell Access what action it should perform
M
(opening another object, running a query, or even starting another program), under what conditions the action should be performed (if another object is open, if a field contains a certain value, or if a user has not entered a value in a field), and comments you include, if any, to make your macro easier to understand.
Open and Examine Macros–
Define Macro Actions–
One of the best ways to learn about macros is to open an existing macro and examine the actions, conditions, and other arguments used to create it. The Northwind sample database contains a number of macros that display quite a few different programming techniques. Examining macros is made much easier if the macro’s author has included comments for all but the most trivial actions. You should annotate your macro actions as well. If you don’t look at a macro for a few months or need to transfer control of your database to someone else, those comments will make the transition much smoother.
After you’ve created your macro, you can define its actions using Access’ built-in macro creation interface. Part of the interface is a list of predefined actions you can use to build your macro. The list is both comprehensive and extremely flexible — you can open any database object, print most of them, and, if you want, run your own custom actions you create using the Visual Basic Editor you’ll learn about in Chapter 21.
Action Beep
Update
Open form Close form Run code
1. Find new records. 2. Copy records to table. 3. Save table. 4. Close table.
516
Group Macros– If you are creating a custom application with lots of macros, it can be difficult to keep track of which macro does what. You should group your macros to make sure all of the macros for a form end up in a
6048-4 ch16.F
10/20/99
3:41 PM
Page 517
Name
Action
Condition Comment
Open
Close
Debug a Macro– The macro interface makes your task fairly easy, but you’ll still need to check your work as you go along. For instance, if you wrote a macro to take text from one form and transfer it to another form, you would need to copy the text, open the second form, and write the data to the target area. If the text didn’t transfer properly, or if Access displayed an error message, you could debug your macro by stepping through it one action at a time.
Make a Macro Action Conditional–
II CREATE TABLES, FORMS, AND REPORTS
single file. Giving your macro file the same name as the form will make it easier to keep track of your work.
When you create a macro, you can make any of its actions conditional on something else being true. For instance, if your macro ran a query that used the values from two fields as its criteria, you could make the step running the query conditional on both fields containing a value. You should test a conditional macro thoroughly. Start by entering values you know will work, verify the results, and start entering values that won’t work. If your macro needs to have values in two fields to work, try leaving one of the fields blank, or entering a value that doesn’t occur in your tables. Finding ways to make your macros break is a great way to learn how conditional statements work. Action
Condition
Open form
IF it’s not open.
Save form
IF it’s been changed.
1. Open form. 2. Read data.
Did this step work? Move to next step.
3. Close form.
517
6048-4 ch16.F
10/20/99
3:41 PM
Page 518
16
CHAPTER 16: CREATE MACROS
CREATE AND SAVE A MACRO
ccess gives you a variety of tools to automate tasks within your database. In Chapter 13 you learned how to create controls for your forms and reports; in this chapter, you’ll find out how to create actions to be launched by those controls. You can program a macro to perform a wide range of tasks, such as opening a form or report, running a query, redrawing an object on the screen, applying a
A
CREATE A MACRO
⁄ Click Macros.
518
filter to a table, or creating a custom message box. You can also use a macro to run another macro or a Visual Basic code module. Another valuable feature of macros: You can easily translate them to Visual Basic code modules. The macro creation process is simple, but it may not always be possible for you to include macros in database applications you distribute to other users. In those instances,
you should translate your macros into Visual Basic modules, which become part of the object that invokes them. As with when you create any other database object, you should save your work often. One good rule of thumb is to save your macro every time you make a change you wouldn’t want to have to repeat.
■ The macros associated with your database appear.
¤ Click New.
6048-4 ch16.F
10/20/99
3:41 PM
Page 519
II CREATE TABLES, FORMS, AND REPORTS
When should I choose a macro over a Visual Basic procedure to automate a process? Since macros are relatively easy to create, you should use them for any simple tasks like opening and closing forms, etc. For more complex tasks (that is, those that can’t be done with the actions from the action list), you should use Visual Basic.
How do I tell what database object calls my macro? You can determine which database object calls your macro by clicking the macro, opening the View menu, and clicking Properties.
How do I save my macro under a new name? To save your macro under a new name, click Save As from the File menu and type a new name for the macro in the dialog box.
■ The Macro Creation window appears.
⁄ Click File.
■ The Save As dialog box appears.
¤ Click Save.
‹ Type a name for your
SAVE A MACRO
macro in this space.
› Click OK. Note: The title bar of your macro's window will change to reflect the macro's name.
519
6048-4 ch16.F
10/20/99
3:41 PM
Page 520
16
CHAPTER 16: CREATE MACROS
OPEN A MACRO hen you want to open a macro, whether to examine how it was constructed or to change it, you open it in Design view. Once you have your macro open, you can step through it to make sure each procedure is working properly, add or delete steps, and change the conditions under which an action will fire.
W
⁄ Click the macro you want to open.
520
You can have as many macros open at a time as your system resources allow, although you should keep the number manageably low so you can switch between windows easily and keep track of which window has been changed in what way. One good reason to have more than one macro open at a time is to place them side by side, using
¤ Click Design.
the skills you learned in the Chapter 1 task “Arrange Windows.” You should probably cascade the macros vertically so each one can spread out over the screen horizontally, showing much more of the cells that make up the Macro window.
■ The macro appears.
1
6048-4 ch16.F
10/20/99
3:41 PM
Page 521
II CREATE TABLES, FORMS, AND REPORTS
16
CHAPTER 16: CREATE MACROS
CLOSE A MACRO t’s a good idea to close a macro as soon as you’re done examining or changing it. You can have any number of macros open simultaneously, but needing to shift through four or more macros to find the one you want can be a time-consuming
I
⁄ Click the Close box.
and frustrating process. It’s much easier to simply close any macro you don’t need at the moment; you can always open it again later. Remember to save your work frequently. You do have a safety net if you try to close your macro
without saving your work — whenever you try to close a macro with unsaved changes, Access will display a dialog box asking if you want to save your work.
■ The macro disappears.
521
6048-4 ch16.F
10/20/99
3:41 PM
Page 522
16
CHAPTER 16: CREATE MACROS
DEFINE MACRO ACTIONS nce you’ve decided what you want your macro to do, you need to tell it exactly how to do it. A computer’s greatest strength is that it will do precisely what you tell it to. The downside is that it does precisely what you tell it to. Fortunately, it’s easy to precisely define your macro’s
O
⁄ Click the first cell in the Action column.
actions. Access comes with a list of preprogrammed actions for use in macros. The list includes a wide variety of actions — everything from opening forms to printing reports to starting other programs on your computer. If you want, you can write a custom action in Visual Basic for Applications. You’ll learn how to
¤ Click the drop-down menu button.
write Visual Basic code modules in Chapter 21. Once you’ve written a module, you can call it from within your macro like any other predefined action.
■ The drop-down menu appears. ‹ Click the first action you want this macro to perform.
522
Note: In this case, we chose Beep.
6048-4 ch16.F
10/20/99
3:41 PM
Page 523
II
■ The action appears in the Action cell.
■ A description of the action appears in this space.
CREATE TABLES, FORMS, AND REPORTS
Where can I get more information on adding actions to macros? You can get more help on adding actions to macros by asking the Office Assistant (described in Chapter 1) how do I add an action to a macro?
Is help available on the actions in the action list? You can get help on any action in the action list by launching Microsoft Help, clicking the Index tab, and typing the name of the action in the text box.
■ The cursor appears in the Comment cell.
ˇ Type a comment for the action in this space.
› Click the Comment cell next to the action.
523
6048-4 ch16.F
10/20/99
3:41 PM
Page 524
16
CHAPTER 16: CREATE MACROS
GROUP MACROS ne way to manage your macros is to create an entirely new macro file for each procedure you automate. The problem you soon run into when creating a complex form like a custom switchboard (see Chapter 19) is that there are
O
⁄ Click View.
soon more macros than you can keep track of easily. Fortunately, Access makes it easy to manage your macros. Rather than keep each macro in a separate file, you can group macros into a single file. Putting every macro in your database
¤ Click Macro Names.
into just one file would be a different version of the original problem, but you can strike a reasonable compromise by saving all of your macros for a specific form or report in a macro file with the same name as the file they are called from.
■ The Macro Names column appears. ‹ Click the cell in the Macro Names column next to the first action in your macro.
524
Note: For this exercise, we created a simple macro containing a single OpenForm action.
6048-4 ch16.F
10/20/99
3:42 PM
Page 525
II CREATE TABLES, FORMS, AND REPORTS
How do I refer to a macro in a macro group? The syntax for referring to a macro in a macro group is to use the group name and then the name of the macro. For instance, a macro called Create New Form in the group (that is, macro file) My Macros would be referred to as “MyMacros.CreateNewForm.”
■ The cell activates. › Type the name of the macro in this space.
ˇ Click in an open Macro Names cell below the last action in your first macro.
■ The cell activates. Á Type the name of your next macro in this space.
‡ Write your new macro, following the steps in task “Define Macro Actions,” presented earlier in this chapter.
525
6048-4 ch16.F
10/20/99
3:42 PM
Page 526
16
CHAPTER 16: CREATE MACROS
INSERT A ROW hen you create a macro, it’s important to make it as readable as possible. You might be the only person charged with maintaining your database at the moment, but you should make your code as easy to read as possible for anyone who may have to step in while you’re on vacation or if you have moved on.
W
⁄ Click anywhere in the row below where you want the new row to appear.
526
Adding comments to each step (and at the beginning of a major sequence) helps make your macro understandable, but you don’t want to bunch your actions together without any space between them. Instead, you should make sure there is at least one row between major segments of your macro. If you don’t remember to put them in
¤ Click Insert Rows.
when you create the macro, you can always insert them later using the skills you’ll learn in this task. You can, of course, insert a row to make room for new actions in your macro.
■ The new row appears above the row you had selected.
1
6048-4 ch16.F
10/20/99
3:42 PM
Page 527
16
CHAPTER 16: CREATE MACROS
II CREATE TABLES, FORMS, AND REPORTS
DELETE A ROW
dding rows between major segments of your program can go a long way toward making your macros more readable. Not only may other people need to administer your database in the future, but also you may have to revisit your
A
⁄ Click anywhere in the row you want to delete.
work after a number of years. Adding adequate comments makes it easy for you or your associates to understand your macros. Of course, if you overdo it and want to close your code up a bit, you can do so by deleting rows.
¤ Click Delete Rows.
You should also delete a row if it contains an action you want to eliminate from your macro.
■ The row disappears.
527
6048-4 ch16.F
10/20/99
3:42 PM
Page 528
16
CHAPTER 16: CREATE MACROS
DEBUG A MACRO
ccess makes writing macros simple, but mistakes can still happen. When you put together a complex set of instructions, you will definitely want to check your code for errors. You can check your code every step of the way by running your
A
macro in single-step mode. When you step through a macro, Access shows the macro name, action name, condition, and arguments associated with that step of the macro. Remember that if you grouped all the macros for a form or report into a single file, the macro name may be different
⁄ Open the macro to debug.
¤ Click the Single Step button.
Note: In this example, we clicked Customer Labels Dialog. Our goal is to find out which object the macro is attached to.
‹ Click the Close box to
528
close the macro file. Note: If you are asked if you want to save the macro file, do so.
than the name of the file you set to single step. You can have Access continue stepping through the macro, halt the macro at the current step, or finish the macro without any more pauses.
■ The macro disappears. › Open the database object your macro is attached to.
Note: If your macro’s comments don’t mention which object the macro is attached to, you’ll need to check the action properties of the database objects it could be attached to.
6048-4 ch16.F
10/20/99
3:42 PM
Page 529
II
■ The object appears. Note: In this case, the macro is attached to the Customer Labels Dialog Form.
ˇ Click Preview.
CREATE TABLES, FORMS, AND REPORTS
How do I tell Access to complete the macro without stopping between steps? To have Access complete the macro without pausing, click the Continue button.
How do I tell Access to stop singlestepping and exit the macro? You can have Access exit your macro by clicking the Halt button.
■ The Macro Single Step dialog box appears.
Note: To have Access execute the current macro step, click Step. When the last step is executed, the Macro Single Step dialog box disappears.
529
6048-4 ch16.F
10/20/99
3:42 PM
Page 530
16
CHAPTER 16: CREATE MACROS
MAKE A MACRO ACTION CONDITIONAL ne of the more handy features of Access’ macro programming environment is that you can make a macro action conditional. That is, you can have it execute if and only if certain conditions are true. Those conditions can include another form being open,
O
⁄ Open the macro containing the action you want to make conditional.
530
a value being within a certain range, or if a particular control has been clicked. Debugging your macro is extremely important if you use a lot of conditional statements. Remember that when you step through a macro, Access shows the macro name, condition,
¤ Click View. ‹ Click Conditions.
action name, and arguments associated with each step. When verifying your macro, pay close attention to the condition and arguments Access is using to complete that step. When you are satisfied they are correct, you can move on to the next action safely.
■ The Condition column appears.
› Click the Condition cell for the action you want to make conditional.
6048-4 ch16.F
10/20/99
3:42 PM
Page 531
II
■ The action arguments for the action appear.
ˇ Click the Where Condition text area.
CREATE TABLES, FORMS, AND REPORTS
How can I get help with setting a condition? You can get more detailed help on setting a condition by asking the Office Assistant (detailed in Chapter 1) for examples of macro conditions.
Where do I get help using the Expression Builder? You can get help on the Expression Builder by asking the Office Assistant (detailed in Chapter 1) “How do I use the Expression Builder?”
■ The cell becomes active. ■ The Build button appears. Note: You can click the Build button to use the Expression Builder to create your condition.
Á Type the condition for the action in this space. Note: For instructions on creating a condition, see task "Create a Query from Scratch: Set Criteria" in Chapter 9.
531
6048-4 ch16.F
10/20/99
3:42 PM
Page 532
16
CHAPTER 16: CREATE MACROS
INVOKE CONTROLS FROM MACROS: CREATE A SOURCE CONTROL hen you create a control, you have the ability to launch a macro or Visual Basic code module based on the actions of that control. If you create an option group, for instance, you could assign a different macro or code module to each of the options within that group.
W
⁄ Create a form and create a control as you learned to do in Chapter 13. Note: For this exercise we created a text box, described in task “Create a Text Box.”
For this example, we have chosen to create a command button that automatically copies text entered in one text box to a text box on a separate form. To automate this process, you will need to create a source control, create a target control, write the macro to make the transfer, and
¤ Click the Properties button.
create the command button to trigger the macro. In this case, the source control — a text box — will not have a macro associated with it directly. Instead, it will be acted upon by the macro associated with the command button.
■ The Properties box appears.
Note: In this instance, we typed "TextSource."
Note: If the All tab is not selected, click it now.
ˇ Click the Close box to close the Properties box.
‹ Click the Name text box. › Type the name of your control in this space.
532
6048-4 ch16.F
10/20/99
3:42 PM
Page 533
II
■ The Properties box disappears. Á Save your form by following the directions in the Chapter 11 task “Save a Form.”
Note: In this case, we saved the form under the name "TextSource."
CREATE TABLES, FORMS, AND REPORTS
Where can I get more help with setting the properties of a control? Open the Answer Wizard as you learned to do in Chapter 1’s task “Getting Help: Using the Answer Wizard Tab” and type Set properties for a form, report, section, or control in the question text area.
How do I get help with a specific property? To get help on a specific property, click the property name and press F1.
■ The New Form dialog box appears.
‚ Click OK.
· Click Design view.
‡ Click the New Object drop-down menu button.
° Click Form. CONTINUED
533
6048-4 ch16.F
10/20/99
3:42 PM
Page 534
16
CHAPTER 16: CREATE MACROS
INVOKE CONTROLS FROM MACROS: CREATE A TARGET CONTROL
he target control in a macro usually accepts input from another control or a calculation performed in a macro. For instance, if you wanted to copy consumer comments into a central file, you could use a macro to copy the contents of the comment field to
T
■ A blank form appears in Design view. — Create a control as you learned to do in Chapter 13. Note: For this exercise we created a text box, described in task "Create a Text Box."
534
the Clipboard, open the target file (perhaps a Microsoft Word document), and paste the comment into the file. The command button is the most obvious control type to use when you want your users to activate a macro by clicking an object on a form, but you could
± Click the Properties button.
perform similar operations using other types of controls. For instance, you could use a check box to run a macro whenever it was checked (or whenever its condition changed, such as from checked to unchecked, or vice versa).
■ The Properties box appears.
Note: In this instance, we typed "TextTarget."
Note: If the All tab is not selected, click it now.
Click the Close box to close the Properties box.
Á Click Name. ª Type the name of your
control in this space.
£
6048-4 ch16.F
10/20/99
3:42 PM
Page 535
II CREATE TABLES, FORMS, AND REPORTS
How do I display the Properties page containing just the control’s name and other general information? You can display the Properties page with the control’s name by clicking the Other tab.
■ The Properties box disappears.
¢ Click File. ° Click Save.
■ The Save As box appears.
¤
Type the name of your form in this space.
Note: In this case, we typed the name "TextTarget."
¦ Click OK.
535
6048-4 ch16.F
10/20/99
3:42 PM
Page 536
16
CHAPTER 16: CREATE MACROS
INVOKE CONTROLS FROM MACROS: CREATE A SAMPLE MACRO
o complete the next phase of this process, you will need to write the macro that copies the text from one control and pastes it into another. In this case, the macro will not be directly associated with the
T
⁄ Create a macro as you learned to do in task “Create a Macro.”
source control. Instead, it will be triggered by a command button located just below the source text box. You could perform similar operations using other types of controls. One instance might be when the same option group
‹ Click the drop-down menu button. › Click OpenForm.
occurred on two separate forms. If the option the user selected should always be the same on both forms, you could write a macro that changed one group whenever the other was changed.
■ The Action Arguments pane changes to reflect your choice.
¤ Click the first cell in the
ˇ Type the name of the
Action column.
form you want to open in this space.
536
Note: In this case, the form is named "TextTarget."
Á Click the next Action cell.
6048-4 ch16.F
10/20/99
3:42 PM
Page 537
II CREATE TABLES, FORMS, AND REPORTS
How do I display a list of the forms available in this database? You can show a list of the forms in the database by clicking the Form text area, clicking the drop-down menu button that appears, and clicking the name of the form you want to open.
‡ Click the drop-down menu button. ° Click SetValue. · Click Item. ‚ Type the full name of the field the macro will update.
— Click Expression. ± Type the name of the field Access will use as the data source for the macro.
Á Click File. ª Click Save.
Note: Type a name for your macro in the space provided, click OK, and close the macro. For this exercise, name the macro TextTransfer.
Note: In this case, we typed "[Form]!TextSource]! [TextSource]."
537
6048-4 ch16.F
10/20/99
3:42 PM
Page 538
16
CHAPTER 16: CREATE MACROS
INVOKE CONTROLS FROM MACROS CREATE A TRIGGER CONTROL
lthough we’ve used a command button as the trigger control in this example, you could use most any of the other controls available to you through the toolbox. The simplest controls to use are of
A
the “on/off” variety: radio buttons, toggle buttons, and check boxes. If you want to give your users a choice of where they want the information to end up, you can let them choose by putting the
⁄ Open the TextSource form.
Note: Your mouse pointer changes to a plus sign.
Note: If the Toolbox doesn't appear automatically, open it as you learned to do in the Chapter 13 task “Open the Toolbox.”
‹ Click the spot you want the control to appear.
¤ Click Command Button. 538
names of the possible destination controls in a list box. When the user makes his or her choice, a macro would take the value from the box and use it as the name of the control to receive the information.
■ The Command Button Wizard appears.
› Click Miscellaneous.
6048-4 ch16.F
10/20/99
3:42 PM
Page 539
II CREATE TABLES, FORMS, AND REPORTS
How can I change the control a macro is assigned to? Since a macro is called from a control, you should create a new control and tell it to trigger the macro when it is clicked. Remember that more than one control can be associated with the same macro.
■ The list of actions in the Action pane changes. ˇ Click Run Macro.
Á Click Next.
■ The next Command Button Wizard screen appears. ‡ Click the macro you want to run when the control is activated.
° Press Ctrl+S to save your changes. · Click Finish. Note: You can customize your command button’s appearance by moving to the next wizard screen.
Note: In this case, launch TextTransfer.
539
6048-4 ch16.F
10/20/99
3:42 PM
Page 540
16
CHAPTER 16: CREATE MACROS
INVOKE CONTROLS FROM MACROS RUN THE MACRO
he behind-the-scenes work is done: you’ve created the source and target controls, written the macro to transfer the text between those controls, and created a command button to tell Access when it’s time to run the macro. All that’s left is to run it.
T
⁄ Click the form with the macro-linked control. Note: In this example, the form is named TextSource.
540
If everything goes according to plan, once you enter some text into the source control and click the trigger control, the form containing the target control will appear with the text inside it. If not, the easiest way to check for errors is to follow the steps in
¤ Click Open.
the task “Debug a Macro,” presented earlier. You should also walk your way through the steps in this sample exercise again to make sure that you didn’t leave a step out and that you spelled everything correctly.
■ The form appears. ‹ Type some sample text in this space.
› Click the command button.
6048-4 ch16.F
10/20/99
3:42 PM
Page 541
II CREATE TABLES, FORMS, AND REPORTS
My macro is only moving one step at a time. Why is that? You probably left the Single-Step button clicked in the macro’s window. To allow the macro to run normally, open the macro in Design view and click the Single-Step button. It should switch to the “up” position.
■ The target form appears with the sample text.
ˇ Click the Close box.
■ The target form disappears.
541
6048-4 ch17.F
10/20/99
4:11 PM
17
Page 544
CHAPTER 17: CREATE A PROJECT BUILD AN APPLICATION
3 CHAPTER 17: CREATE A PROJECT
CREATE A PROJECT
M
ost commonly, an Access database works as a standalone application that’s either stored locally on a user’s hard disk or
Introducing Projects–
accessed over a network. But with Access 2000, you can also connect to databases stored on common SQL servers. System Requirements for Using Projects–
The Microsoft Access project file, new in Access 2000, lets you build an Access-based user interface for databases created using the Structured Query Language (SQL). Remember, the standard, nonproject Access database is built as a standalone application. By replicating a database in whole or in part, users can carry the information they need with them. However, the replica is itself an independent application; users need to reconcile any changes with the master database when they return to the office. In contrast, a Microsoft Access project is divided into parts: the client side (which contains the project file) and the server side (which contains the database’s data files). The project file itself contains no data, only the HTML- and code-based elements of the database (forms, reports, data access pages, macros, and code modules). The rest of the database elements are stored on a SQL server. Users must connect to the server to view, create, modify, and delete tables, views, stored procedures, and database diagrams.
You can use Microsoft Access projects with a number of SQL Server databases. Microsoft’s SQL Server versions 6.5 and 7.0 are available separately or as part of Microsoft’s BackOffice Server package. A version of Microsoft’s SQL Server may be included in some editions of Office 2000; check your installation discs and documentation to see if the server is included. The string to search for is “mssql7”, which is short for Microsoft SQL Server 7.0. Here are the system requirements for running project-compatible SQL servers:
SQL Server 7.0, running on Windows NT 4.0 (with Windows NT Service Pack 4 or later) or Windows 95/98
Microsoft Data Engine (MSDE) on Windows NT 4.0 or Windows 95/98
SQL Server 6.5 on Windows NT 4.0 (with SQL Server Service Pack 5 or later)
SQL server
7.0 Project SQL data base User’s computer
544
Windows Windows Windows
95
98
NT
6048-4 ch17.F
10/20/99
4:11 PM
Page 545
Stored Procedures–
Examine and Create Stored Procedures– You can create your own stored procedures, but Access includes a number of them already. To examine a stored procedure, simply click the Stored Procedures icon in the Objects pane of the main Project window. Take the time to examine a number of the stored procedures included with the standard Access distribution. You can learn a lot by reading the code and comments in the stored procedures, not to mention that you will know if there’s an existing procedure you can use instead of creating one from scratch. You can create a stored procedure from the main Microsoft Access Project window by displaying your stored procedures and clicking the New button at the top of the window. When you click New, Access launches the Stored Procedure Editor, which looks very similar to the Visual Basic for Applications Editor (described in Chapter 21). The editor appears with the minimum SQL statements needed to perform the procedure. You can add SQL statements, comparisons, and queries to the stored procedure. Remember to save your work frequently! The SQL statements you can use depend on the server hosting your database. Check your server’s documentation for more information.
III
Join Select Project
Stored procedures PROJECT JOIN
545
BUILD AN APPLICATION
A powerful element of Microsoft Access projects is the ability to use stored procedures, or precompiled collections of SQL and flow control statements. Stored procedures extend the functionality of standard SQL statements in several ways. First, a stored procedure can contain more than one SQL statement, as well as commands controlling program flow, performing logical operations, and running queries against the database. You can define the input and output parameters for the stored procedures or allow users to enter their own. A second advantage of stored procedures over traditional SQL statements is that you can reference other stored procedures from within your stored procedure. References are an easy way to simplify your coding and program documentation — instead of having to wade through a morass of statements and definitions to find the statements you want, you can simply refer to the other procedure and add a comment in the main file about what the stored procedure does and what data it returns. Finally, stored procedures run more quickly than standard SQL statements because they are compiled (turned into executable code before running) rather than interpreted (read and executed step by step when called) by the server. The speed difference between compiled and interpreted code is miniscule for smaller databases but increases rapidly with database size.
6048-4 ch17.F
10/20/99
4:11 PM
17
Page 546
CHAPTER 17: CREATE A PROJECT
CREATE A PROJECT BASED ON AN EXISTING DATABASE hen you create a standard database, you make all of the objects for that database available to your users. Users are able to inspect your design and, if they know how, change your database’s structure and fiddle with the underlying procedures. One way of restricting users’ ability to access, delete, and change database objects is to use the User-Level Security Wizard and other security-related tools.
W
⁄ Start Access as you learned to do in the Chapter 1 task “Launch Access 2000.” ¤ Click “Access database wizards, pages, and projects.” 546
These security tools, which you’ll learn about in Chapter 22, are handy ways to ensure your users don’t accidentally erase or modify any of your database’s objects. Another way to give users the ability to work with your data but not change the underlying design is by distributing replicas of your database. Replicas, also discussed in Chapter 22, are complete copies of databases; the difference is that their structure can’t be modified.
‹ Click OK.
Projects are a third way of ensuring security. They have the added bonus that data entry operators and administrators can access databases over a network. One way to think of a project is as a user interface, where a user can view and manipulate data without the possibility of damaging or erasing it.
■ The New window appears. › Click Project (Existing Database).
ˇ Click OK.
6048-4 ch17.F
10/20/99
4:11 PM
Page 547
Can I create a new project even though I have another database or project open? You can create a new project while you have another project or database open by clicking the New toolbar button. The project or database you were working on disappears, and the New window, which you saw in steps 4 and 5 of this task, appears.
547
BUILD AN APPLICATION
III
6048-4 ch17.F
10/20/99
4:11 PM
17
Page 548
CHAPTER 17: CREATE A PROJECT
CREATE A PROJECT NOT BASED ON AN EXISTING DATABASE f you want, Access also gives you the ability to create a project that’s not connected to an existing database. Building a project that’s not hooked to an existing database gives you more flexibility to be creative with your project. If you have a firm idea of what the project and database’s designs
I
Ú
Start Access as you learned to do in the Chapter 1 task “Launch Access 2000.”
¤ Click “Access database wizards, pages, and projects.” 548
should be but haven’t had the time to produce the database itself, waiting to bind the projects to the databases prevents users from innocently using your database before it is ready. Projects are the perfect tool for customer order entry. Not only is the user insulated from
‹ Click OK.
the main database, but you, the administrator, don’t have to keep track of replicas that might need to be reconciled to the master copy.
■ The New window appears. Note:IftheGeneraltabisn’t cli ked,cli kitnow.
› Click Project (Existing Database).
ˇ Click OK.
6048-4 ch17.F
10/20/99
4:11 PM
Page 549
Can I create a database and its project at the same time? You can create a database and its project at the same time by clicking the Project New Database icon in the General page of the New window and stepping through the wizard. For help on creating your new project and database, see the Chapter 2 task “Create a New Database with the Wizard” and task “Create a Project Based on an Existing Database” presented earlier in this chapter.
■ The File New Database window appears. Á Type the name of your new project in this space.
‡ Click Create.
How do I link a project to a database? Open the project, click the File menu, and click Connection. The Data Link Properties dialog box will appear — follow steps 8–12 in task “Create a Project Based on an Existing Database” presented earlier in this chapter.
■ The Data Link Properties dialog box appears.
° Click Cancel. N o te : Y o u r p r o je c t a p p e a r s w h e n th e D a ta L in k P r o p e r tie s d ia lo g b o x c lo s e s .
549
BUILD AN APPLICATION
III
6048-4 ch18.F
10/19/99
3:15 PM
Page 550
18
CHAPTER 18: CREATE AN APPLICATION BUILD AN APPLICATION
3 CHAPTER 18: CN APPLICATION
CREATE AN APPLICATION hether you create a custom database or use one of the wizards, the end result is a program your users will use to manage their data. Such programs are called applications because they are designed for just that: a specific application. This chapter gives you a quick overview of an important part of any application: event handling.
W
Whenever a user moves the mouse pointer or clicks a mouse button, an event occurs. Access allows you to identify which of those events are important and define specific responses to your users’ actions. The remaining chapters in this section show you how to use the skills you’ll learn here to tie actions to specific controls, toolbars, and menus.
Data Events–
Error and Timing Events–
Data events are triggered when data is entered, changed, or deleted in a form or control. These events can also be triggered when a record in a datasheet becomes active or inactive. One useful data event is OnDirty. The name sounds funny, but it refers to an event that initiates when the text in a control has been changed. The control is “dirty” in the sense that its new contents haven’t been acted upon yet. Keyboard Events– Keyboard events, as the name implies, occur when a user types a character, holds down a key on the keyboard, or releases a key while an object has the focus. The OnKeyPress event is particularly useful — it waits for the user to type a printable character before initiating its action. One possible use for this event would be to wait until a user has begun typing something in a text box, perhaps a message, and then display a message telling the user to “Click the Send button when you are ready to send your message.”
550
Programmers who need to create computer programs from scratch spend a lot of time developing error-handling routines. After all, users make all kinds of interesting mistakes! Fortunately, Access takes care of most of the common errors automatically. Let users know something has gone wrong by generating your own messages, in case Access runs into a problem processing form or control data. Timing events are also quite useful. If you want to refresh a database’s contents every half hour, or run a query every ten minutes, you can assign a value to the object’s TimeInterval property and use the OnTimer event to trigger a macro or Visual Basic code module that performs the necessary task. Mouse Events– Mouse events occur when you click, doubleclick, press, or release the mouse button, or move the mouse pointer over an object. OnClick is the most familiar of these eventhandling routines. Under most circumstances, when you click an object such as a control button, the macro or Visual Basic code module behind it runs. You can use these events to assign different behaviors for each action. In Access’ main Database window, for instance,
6048-4 ch18.F
10/19/99
3:15 PM
Page 551
Filter Events– Filter events trigger whenever you apply a filter or click the Filter by Form button when you view a table in Datasheet view. Some events you could trigger when a filter is invoked include displaying the name and criteria of the filter, counting the number of records hidden by the filter, and displaying a button to undo the filter. Print Events– Print events occur when you try to print an Access report. You can choose one or more events in the print routine to trigger your macros or code modules when Access determines which data should be included in a report section, when (if) Access discovers the report to be printed contains no data, when Access formats a page to be printed, when Access formats the data in a report section, and when (if) Access has to backtrack one or more steps in the printing process to apply previously used formatting to the current report section. Triggering events when a report contains no data is a simple way to handle user and programming errors. For instance, if a user wants to print a report containing all the orders placed on a particular day and there were none, displaying a dialog box with a “No orders were placed on that day” message alerts the user to the lack of data and allows them to continue without printing a blank page.
Focus Events– Focus events are triggered when a form, report, or control is made active by a user — usually by clicking it. Access, like most other Windows programs, indicates which object “has the focus” by highlighting it. You can have Access run a macro or Visual Basic code module when a specific object gets the focus, when the focus changes from one object to another, when the focus changes to an object in another program, or when an object loses focus.
III
Window Events– As you might guess from the name of the category, Window events are triggered when you open, close, or resize a Form or Report window. Some events you might want to run when a window opens or closes could include ensuring there were no incomplete fields in a form, that the data needed to open a report was available, or that the form or report wasn’t needed by some other ongoing process.
551
BUILD AN APPLICATION
moving the mouse pointer over an object causes its full name to appear; clicking the same object puts it “in focus”; and doubleclicking the object opens it. You can model your objects’ behavior on this pattern or create your own.
6048-4 ch18.F
10/19/99
3:15 PM
Page 552
18
CHAPTER 18: CREATE AN APPLICATION
VIEW AND ASSIGN EVENT PROPERTIES FOR A FORM OR REPORT vents are really just another way to describe what the user or the computer does. By defining events, you can tell Access when to perform a certain procedure, or action. For example, you could tell Access to display an error message if your users tried to close a form while some fields weren’t filled in.
E
⁄ Open a form as you learned to do in the Chapter 11 task “Open a Form in Design view.” Note: In this case, we opened the Products form.
552
Each Access object has its own list of events that can be associated with it. One of the events associated with a form, for example, is “on load,” which means the form is opened. Another is “on insert,” or when content is inserted. You can attach either macros or Visual Basic procedures to events; create your own or use one of the
¤ Click the Properties button.
samples that come with Access. For more information on macros, see Chapter 16. For more information on Visual Basic procedures, see Chapter 21.
■ The Properties dialog box appears.
‹ Click the Event tab.
6048-4 ch18.F
10/19/99
3:15 PM
Page 553
How do I view the events associated with a specific control? Open the form or report containing the control, click the control, and then click the Properties button. The object’s properties will appear in the dialog box.
■ The Event pane appears. › Click the name of the event you want to assign a procedure to.
ˇ Click the drop-down menu button. Á Click the name of the procedure.
How do I build a new action to go with the event I’ve chosen? You can build a new action by clicking the Build button and choosing the Macro, Code, or Expression Builder.
■ The name of the procedure appears in the Properties box.
Note: To close the Properties dialog box, click the Close box.
553
BUILD AN APPLICATION
III
6048-4 ch19.F
10/19/99
3:17 PM
Page 554
19
CHAPTER 19: CREATE SWITCHBOARDS
CREATE SWITCHBOARDS hen you create a database using one of Access’ database wizards, the program automatically creates a switchboard, or special form that provides a simple interface to
W
your database. You can use the switchboard to enter new data, edit existing data, or modify the switchboard itself.
Create a New Switchboard–
Create a New Switchboard Page–
When you create a new database, it can take users some time to get used to your design, which objects you’ve included in your database, and what they can do with the objects in your database. A switchboard makes it easier for your users to perform data entry and other database tasks. You’re not limited to crowding all of your functions onto a single Switchboard page. You can create as many pages as you like, each containing a group of related tasks for your users to perform. If you create a database using a wizard, Access automatically creates a switchboard with three pages: the Main page, which allows your users to open forms to add, delete, or modify data in your database; the Reports page, which lets your users view and print out reports derived from your table and query data; and the Administration page, which lets your users make changes to your database, including the switchboard itself. If you create a database from scratch, you might want to create a switchboard form to make it easier for your users to find the functions they’re looking for without having to dig through all of your database’s objects. Add/view main records Edit records Print records Close switchboard
554
Even if Access automatically created a switchboard for your database, you should create a new one when you add a new set of objects to your database. You can also create a new switchboard to cluster frequently used objects. You can have as many pages in your switchboard as you need, though you should keep the number low so your users will have fewer places to look for the task they want to accomplish. When you create a database from scratch, you might want to use the wizard-created switchboard design as a base for your own. The wizard switchboard is fine for most purposes, and it can be modified much more easily than starting from scratch. Print reports Add/view main records Edit records Print records Close switchboard
6048-4 ch19.F
10/19/99
3:17 PM
Page 555
Add and Delete Switchboard Items–
Print reports Print sales Print contacts
III Print sales Print contacts Print leads
Create a Custom Switchboard– When you create a database using a wizard, Access can create a switchboard automatically because it knows exactly which objects and functions have been included. If you create a database from scratch, Access has no way of knowing which items you’ve included or what the items do. You can use the skills you learned in Chapter 13 to create a switchboard from scratch. When you create a switchboard from scratch, you’re really just creating a form and stripping away nonessential items like scroll bars, dividing lines, and navigation bars. Run macro #1
Change Switchboard Art– Choosing a proper technical design for your switchboard (which items and pages you include, what order they’re in, and what page they occur on) is a vital part of making it easy for users to take advantage of your database. Another important element of your switchboard is its appearance. Access includes an image with each wizard-created switchboard, and you can change the image any time. Access supports a wide variety of image formats, so you shouldn’t have trouble pasting existing images into a switchboard. If you like, you can also use an image from the Microsoft
Open Format #3
Print report #6
555
BUILD AN APPLICATION
To add or delete switchboard items, you open the Switchboard Manager, open the page you want to add or delete items from, and either designate the item to be deleted or tell Access you’d like to create a new one. You might want to add a switchboard item to one of your pages when you add a new table, form, query, or macro to your database. If you’ve created another page to hold a group of related items, you’ll need to create a new switchboard item on another page (perhaps the Main page, perhaps another lower in the hierarchy) so the user can get to the new page. Choosing when to delete a switchboard item calls for a similar thought process — if you don’t think your users will need to use an item, you should delete it.
Clip Gallery, which contains an assortment of images like animals, banners, and shapes.
6048-4 ch19.F
10/19/99
3:17 PM
Page 556
19
CHAPTER 19: CREATE SWITCHBOARDS
MODIFY A SWITCHBOARD CREATED BY THE DATABASE WIZARD
lthough the main Access interface makes it fairly easy to navigate within a database, you can make it even easier for users to work with your database by creating a switchboard. A switchboard is especially helpful for users with little or no experience using Access.
A
⁄ Create a database with a wizard as you learned to do in Chapter 2.
A switchboard is a special type of form with controls that automate tasks like data entry, opening and closing other forms, and printing forms or reports. When you create a database using the Access database wizard, a process illustrated in Chapter 2, Access automatically creates a switchboard.
Note: For this example, create a Contact Management database using all of Access' default settings by clicking Finish in the first wizard screen.
¤ Click Change Switchboard Items. 556
This task illustrates how to change the label associated with a switchboard item. You’ll learn how to change the graphics, controls, and events on your switchboard later in this chapter.
■ The Switchboard Manager appears.
Note: In this case, we chose Main Switchboard (Default).
‹ Click the Switchboard page you want to edit.
› Click Edit.
6048-4 ch19.F
10/19/99
3:17 PM
Page 557
How do I open the Switchboard Manager from the menu bar? You can open the switchboard from the menu bar by clicking Tools ➪ Database Utilities ➪ Switchboard Manager.
How do I save the changes I’ve made in the Switchboard Manager? Access automatically applies your changes as you make them; you don’t need to do anything else to save them.
How do I make sure my users can’t accidentally modify my switchboard? You can permanently prevent anyone from modifying your switchboard by removing the Administration item on the main Switchboard page, but you will not be able to modify the switchboard either.
■ The Edit Switchboard Page screen appears.
ˇ Click the switchboard item you want to edit.
Note: In this case, we chose to edit the Enter/View Contacts item.
■ The page you chose opens for editing.
Á Click Edit.
CONTINUED
557
BUILD AN APPLICATION
III
6048-4 ch19.F
10/19/99
3:17 PM
Page 558
19
CHAPTER 19: CREATE SWITCHBOARDS
MODIFY A SWITCHBOARD CREATED BY THE DATABASE WIZARD CONTINUED
nce you have located the switchboard item you want to edit, you can modify the text associated with the item, the type of command the item initiates, and the database object the command uses to complete its task. In general, the Database Wizard orders switchboard
O
■ The Edit Switchboard Item dialog box appears. ‡ Type new text for the switchboard item in this space.
558
items well. The wizard arranges items according to the following model: entering information, viewing information, performing administrative tasks, and closing the database. But you can also change the order of the items on each switchboard page. To change an item’s place on the page, click the item and then
° Press OK.
click either the Move Up or Move Down button. For instance, you could create a switchboard for an assistant Access administrator with the Change Switchboard Items option at the top of the list.
■ The Edit Switchboard Item dialog box disappears.
· Click Close.
6048-4 ch19.F
10/19/99
3:18 PM
Page 559
How do I change the order of the items on a page? You can change where an item appears on a page by clicking the item and clicking either the Move Up or Move Down button.
■ The Edit Switchboard Page dialog box disappears.
‚ Click Close.
How do I print the Switchboard page I have open? You can print the Switchboard page by clicking its title bar to ensure it is active, opening the File menu, and clicking Print.
■ The Switchboard Manager dialog box disappears.
■ Your new text appears in the switchboard.
559
BUILD AN APPLICATION
III
6048-4 ch19.F
10/19/99
3:18 PM
Page 560
19
CHAPTER 19: CREATE SWITCHBOARDS
CREATE A NEW SWITCHBOARD PAGE
witchboards are a lot like menus. You offer your users a list of actions they can perform, the user makes his or her selection, and the switchboard control initiates the task. They are also like menus in another important way: if you add too many options, they become confusing rather than helpful. Just as it often makes sense to create submenus, there are plenty
S
⁄ Open the Switchboard Manager as you learned to do in steps 1–3 of task “Modify a Switchboard Created by the Database Wizard,” presented earlier in this chapter. 560
of occasions when creating a new Switchboard page to house a number of related options is the best design alternative. The Access Database Wizard follows this model when it creates its default switchboards. If you open the Switchboard Manager inside one of the default switchboards (we chose the Contact database’s main switchboard), you’ll see three
¤ Click New.
pages: the Main Switchboard page, the Administration Switchboard page, and the Reports Switchboard page. You should take a moment to look at how the default switchboards are set up. You might want to use that design in your custom switchboard, but you may also see ways to improve upon the standard design.
■ The Create New dialog box appears. ‹ Type a name for your new Switchboard page in this space.
› Click OK.
6048-4 ch19.F
10/19/99
3:18 PM
Page 561
How do I change the page that comes up when a switchboard is launched? You can assign a page to come up when the switchboard launches by clicking the page name and clicking the Make Default button.
■ The new page appears in the Switchboard Manager.
ˇ Click Close.
My new switchboard page doesn’t have anything on it! How do I add items to the page? Instructions for adding items are in the very next task, “Add Items to a Switchboard Page.”
■ The Switchboard Manager disappears.
561
BUILD AN APPLICATION
III
6048-4 ch19.F
10/19/99
3:18 PM
Page 562
19
CHAPTER 19: CREATE SWITCHBOARDS
ADD ITEMS TO A SWITCHBOARD PAGE ou’ll need to add items to a Switchboard page whenever you add new functions or objects to your database, or if you need to replace an item deleted earlier. You might consider sitting down with a pencil and paper to map out what you want your switchboards to look like,
Y
⁄ Open a Switchboard page for editing as you learned to do in steps 1–4 of task “Modify a Switchboard Created by the Database Wizard.”
including the items you want to add. Use the wizard-created switchboards as a model, draw up your plan, and check it for repetition, out-of-place items, and missing pieces. Remember that there’s a fine line between having too many items on a single page and not having enough. If you have too many
items, you’ll want to create a new Switchboard page as well (see “Create a Custom Switchboard” later on in this chapter). Once you’ve decided on a structure, you can begin adding items to your pages.
Note: For this example, open the Show Forms page.
■ The Edit Switchboard Item dialog box appears.
¤ Click New.
‹ Type the label for your new switchboard item in this space.
› Click the drop-down menu button in the Command text box. ˇ Click the command you want the control to execute. Note: In this case, we chose "Open Form in Edit Mode."
562
6048-4 ch19.F
10/19/99
3:18 PM
Page 563
The Command drop-down menu has entries for opening a form in add mode and opening it in edit mode.What’s the difference? Opening a form in add mode allows your users to add new records to the underlying table. Opening a form in edit mode allows them to add new records and modify existing ones.
■ The third element of the Edit Switchboard Item dialog box changes to reflect the command you chose. Note: In this case, Access needs to know which form you want to open in add mode.
Á Click the drop-down menu button in the Form text area.
BUILD AN APPLICATION
III
■ The item appears in the Edit Switchboard Page dialog box.
‡ Click the form you want to open via this control. Note: In this case, we chose Calls.
° Click OK. 563
6048-4 ch19.F
10/19/99
3:18 PM
Page 564
19
CHAPTER 19: CREATE SWITCHBOARDS
DELETE A SWITCHBOARD PAGE ITEM ne of the advantages of using switchboards in Access is that you can modify switchboards just about any way you want, including deleting items. Of course, you should delete a switchboard item if you don’t
O
⁄ Open a Switchboard page for editing as you learned to do in steps 1–4 of task “Modify a Switchboard Created by the Database Wizard.”
564
think it will be used. But you should also delete an item if you have placed a similar item on another page. It is less confusing to the user if you have just one occurrence of every item. If you’re using wizard-created switchboards, however, you
¤ Click the item you want to delete. ‹ Click Delete.
should never delete the Administration control on the Main page and the Change Switchboard Items control on the Administration page. If those controls are not present, you will not be able to reach the Switchboard Manager.
■ The item disappears.
Note: If you are asked if you are sure you want to delete the item, click Yes.
1
6048-4 ch19.F
10/19/99
3:18 PM
Page 565
III
DELETE A SWITCHBOARD PAGE witchboards make it easy for your database’s users to perform the jobs they need to perform, whether that’s running queries, adding data to your tables, or creating reports to display the information in your database.
S
⁄ Open the Switchboard Manager as you learned to do in steps 1 and 2 of task “Modify a Switchboard Created by the Database Wizard.”
There may be times when your database’s structure will change significantly. When that happens, you may need to delete one or more Switchboard pages so your users won’t try to get at options you’ve removed.
¤ Click the page you want to delete. ‹ Click Delete.
Deleting a Switchboard page is permanent — once the page is gone, there is no way to recall it. Access will display a dialog box asking you if you’re sure you want to delete the page, but once you click OK the page is gone for good.
■ The page disappears.
Note: If you are asked if you are sure you want to delete the item, click Yes.
565
BUILD AN APPLICATION
19
CHAPTER 19: CREATE SWITCHBOARDS
6048-4 ch19.F
10/19/99
3:18 PM
Page 566
19
CHAPTER 19: CREATE SWITCHBOARDS
CHANGE SWITCHBOARD ART
witchboards are about getting things done easily — they help users and administrators fulfill the tasks and make the changes they need to make. Beyond the technical benefits of a switchboard, you should consider your switchboard’s appearance. Access automatically
S
Following steps 1 3 in task "Open a Form," open the form containing the switchboard you want to modify in Design view.
566
includes artwork in your switchboard (the specific image depends on the wizard you used to create your database), but you should feel free to change it. Microsoft Access comes with a collection of images you can use in your switchboards. The Microsoft Clip Gallery includes graphics of animals, banners,
⁄ Click the picture you want to replace. ¤ Click the Properties button.
business items, things found in nature, navigation controls, shapes, and objects or conceptual drawings from quite a few other categories. You can also choose one of your own graphics, such as a corporate or departmental logo.
■ The Properties box appears.
‹ Click the Picture text box. › Click the Build button.
6048-4 ch19.F
10/19/99
3:18 PM
Page 567
I want to create an object to insert into my switchboard. How do I do that? By opening the Insert menu and clicking Object, Access will display a list of the programs you can use to create an object to insert into your switchboard. When you close the other application, Access will reappear.
■ The Insert Picture dialog box appears.
ˇ Locate a graphic to add to switchboard using steps 5 and 6 of task “Insert an Image,” presented in Chapter 13.
What graphic formats does Microsoft Access allow me to use? Access understands most of the common graphics formats, including .jpg, .gif, .pcx, .eps, and many others.
■ The image appears on your switchboard.
Á Click OK.
567
BUILD AN APPLICATION
III
6048-4 ch19.F
10/19/99
3:18 PM
Page 568
19
CHAPTER 19: CREATE SWITCHBOARDS
CREATE A CUSTOM SWITCHBOARD hen you create a database without using a wizard, Access does not automatically create a switchboard to go along with it. However, creating a switchboard from scratch is simple: it’s just like creating a form from the ground up. You should remove the scroll bars, dividing lines, and record
W
navigation tools normally added to a form when you create a switchboard from scratch. Since users will move within your switchboard using controls you define, those extra navigation tools are not needed. If you want to make your custom switchboard look like a wizard-created switchboard, you can arrange your controls and
⁄ Double-click “Create Form in Design view.”
568
draw boxes to give it that “wizardly” look. But you are creating a switchboard from scratch, after all, so feel free to give it your own distinctive flavor.
■ The form appears.
¤ Click the Properties button.
6048-4 ch19.F
10/19/99
3:18 PM
Page 569
How do I make my custom switchboard appear when the database opens? Open the Tools menu from the main Database window and click Startup. In the dialog box that appears, click the dropdown menu button in the Display Form text area and click the name of the form you made your switchboard.
■ The Properties box appears.
‹ Click the Format tab.
Can I create a custom switchboard even if I created my database with a wizard? Certainly. A custom switchboard is really just a type of form, so you can create as many as you like.
■ The Format page appears.
ˇ Click the drop-down menu button.
› Click Views Allowed.
Á Click Form.
CONTINUED
569
BUILD AN APPLICATION
III
6048-4 ch19.F
10/19/99
3:18 PM
Page 570
19
CHAPTER 19: CREATE SWITCHBOARDS
CREATE A CUSTOM SWITCHBOARD CONTINUED
hen you create a custom switchboard, you don’t have access to the Switchboard Manager, so you need to create each page of your switchboard independently. The most straightforward way to do that is to create a separate
W
form for each Switchboard page. When a user clicks on a control to view another Switchboard page, he or she actually opens another form. Remember that you can add any type of control or graphic you want to your switchboards.
For instance, if you wanted to insert a graphic in your custom switchboard, you would follow the steps in Chapter 13’s task “Add a Picture.”
■ "Form" appears in the Views Allowed text area.
° Click the drop-down menu button.
■ "Neither" appears in the Scroll Bars text area.
— Click the drop-down menu button.
‡ Click Scroll Bars.
· Click Neither.
‚ Click Record Selectors.
± Click No.
570
6048-4 ch19.F
10/19/99
3:18 PM
Page 571
Do I have to use a separate form for each page of my switchboard? You can create switchboards using other database elements. One possibility is to create a tab control with a page corresponding to a page on a wizardcreated switchboard.
Á
“No” appears in the Record Selectors text area.
ª
Click the Close box to close the Properties box.
Now that I’ve got a form without navigational controls like scroll bars, how do I add the switchboard buttons? See the instructions for adding controls in Chapter 13.
■ The Properties box disappears.
Note: You may now add controls to your switchboard.
■ Repeat steps 10–12 to remove the navigation buttons and dividing lines on your switchboard.
571
BUILD AN APPLICATION
III
6048-4 ch20.F
10/19/99
3:20 PM
Page 572
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
BUILDCATION
3
CREATE CUSTOM TOOLBARS AND MENUS Create a Custom Toolbar–
Like any Microsoft program, Access includes a full complement of menus and toolbars. Sometimes, though, you might want a special toolbar button for your application: to open a commonly used form, for example. Or you might want to edit down and rearrange the existing toolbars and menus to include just those commands your users will need, to make it easier to use the database. You can do all these things in Access. You can add your own toolbar buttons, create your own custom toolbars, show and hide the predefined toolbars, create shortcut menus for your database objects, and decide which menus to show and which commands to place in each menu. This ability to customize the interface can help make your database application as user-friendly as possible. If you can’t find a built-in toolbar with all of the commands you’re looking for, you can create a new one. Although most toolbars are designed around a particular theme (file operations, formatting, or applying styles, for example), the best theme may be “frequently used commands.”
Show or Hide an Existing Toolbar– Whenever you create a database that will be used by someone other than yourself, you should keep in mind which commands your users need to have at their fingertips. If you’ve created a custom toolbar that could take the place of an existing toolbar, you can hide the prefabricated toolbar and display your own. Add Buttons to a Toolbar– The built-in toolbars in Access are well planned, but it’s likely that an existing toolbar will be missing one or two of the buttons you commonly use. When that’s the case, you can add that button to round out that toolbar’s selection. One of the best things you can do when you’re adding buttons to a toolbar is to check through the existing toolbars to see what buttons are available. Although you can create your own buttons, you’ll save time if you can locate an existing one.
Create a Custom Button–
?
572
The problem with the standard toolbars and buttons is that they’re all generic — they don’t relate directly to specific objects in your database.
6048-4 ch20.F
10/19/99
3:20 PM
Page 573
? Edit a Toolbar Button Image– Access comes with quite a few images for your buttons, from the standard icons used in the main Database window to denote macros, forms, reports, tables, and queries, to the familiar card suits and beyond. But if you’d rather create your own button image, you can do so using the Button Image Editor. The Button Image Editor lets you change each pixel of your button’s image. You can use any of the sixteen colors presented in a palette in the Editor window and check your work by looking at a preview. As always, if an existing button image includes elements of the one you’d like to create, you should assign that image to your button and make your changes using the existing image as a base.
Work with Custom Menu Bars– Just as you can create custom toolbars for your applications, you can create custom menu bars. You can make your Access application much easier to use by creating custom menu bars that make your commonly used commands easier to get at. There are 14 built-in menus. The standard Windows menu design calls for the File and Edit menus to appear as the first and second items in the standard menu bar. If you’re planning to replace the main menu bar, you should maintain design consistency by putting the File and Edit menus in their accustomed place. Access treats menu bars and toolbars the same way internally — the only difference is how they are displayed. So, you could use only menus and no toolbars, or only toolbars and no menus. But the safest option is to create both toolbars and menus for your application. That way, regardless of your present (and future) users’ preferences, you’ll have the system they can use most comfortably in place.
III
Create Shortcut Menus– If you want to add menus to your forms and reports without taking up space on your screen, you can use shortcut (or “pop-up”) menus. Shortcut menus appear when you rightclick a database object and usually contain the most common actions associated with an object. You can get some ideas about how shortcut menus are used by right-clicking objects in My Computer or Windows Explorer.
? 573
BUILD AN APPLICATION
For example, if you create a series of queries your users will run every day, you won’t find buttons to open those queries on any of the standard toolbars. You can create your own buttons quite easily; simply choose the object type you want to open via the button and pick the particular object (in this case a query) from the list presented.
6048-4 ch20.F
10/19/99
3:20 PM
Page 574
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
SHOW OR HIDE AN EXISTING TOOLBAR
oolbars are Access database objects that make it easy for you to open frequently used forms, reports, or queries, and to run macros and Visual Basic code modules with the click of a button. The standard distribution of Microsoft Access includes a
T
SHOW A TOOLBAR
⁄ Click Tools.
custom Database toolbar with buttons to perform tasks like creating new files, opening existing files, printing (or previewing) database objects, and creating new objects using Access’ built-in wizards. Although the Database toolbar is the only toolbar displayed in
¤ Click Customize.
Access’ default configuration, there are a wide variety of other toolbars available for you to display if you like. The toolbars Access places at your disposal include Macro Design, Alignment and Spacing, Query Design, and Datasheet Formatting.
■ The Customize dialog box appears. Note: If the Toolbars tab isn't in the foreground, click it now.
‹ Click the check box next to the toolbar you want to display. 574
Note: In this case, we clicked Alignment and Sizing.
6048-4 ch20.F
10/19/99
3:20 PM
Page 575
How do I make a toolbar appear with the default toolbars? To make your toolbar appear with the other toolbars (usually at the top of the screen), simply drag the toolbar to the top of the Database window. The toolbar will automatically dock, or park, in that area when it is in position.
■ The toolbar appears. HIDE A TOOLBAR
⁄ Open the Customize dialog box as you learned to do in the “Show a Toolbar” subtask.
¤ Click the check box next to the toolbar you want to hide.
How do I hide an undocked toolbar without going to the Customize dialog box? You can hide an undocked toolbar by clicking the Close box at the upper-right corner of the toolbar.
■ The toolbar disappears.
‹ Click Close. Note: The Customize dialog box disappears.
Note: In this case, we clicked Alignment and Sizing.
575
BUILD AN APPLICATION
III
6048-4 ch20.F
10/19/99
3:20 PM
Page 576
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
CREATE A CUSTOM TOOLBAR
ccess gives you a wide variety of prefabricated toolbars to choose from, although you may find that the functions you want to have in easy reach don’t all appear on the same toolbar. Rather than show more than one toolbar at a time, you can create a custom toolbar with the commands and
A
⁄ Click Tools.
576
documents you need. Another time you could build a custom toolbar is if you are creating a custom application for your users. Since it’s not always feasible to create a project (as you learned to do in Chapter 17), you can use toolbars to both empower and limit your users. By limiting which commands are
¤ Click Customize.
easily accessible, potentially in combination with user and group permissions that are discussed in Chapter 22, you can make it easy for your users to perform their tasks without worrying about accidentally modifying the application.
■ The Customize dialog box appears.
‹ Click New.
6048-4 ch20.F
10/19/99
3:20 PM
Page 577
How do I keep the toolbar from being moved or changed? You can prevent horizontal docking, vertical docking, or any changes in a toolbar’s position by clicking the toolbar’s name in the Customize dialog box, clicking the Properties button, and choosing an option from the drop-down menu next to Docking.
III
Can I dock a toolbar other places than the top of the screen? Unless you have changed the properties of a specific toolbar, you can dock your toolbars at any edge of the screen. Simply drag your toolbar to the desired edge; it will jump to the edge when it is in position. If you park a toolbar on the left or right edge of the screen, it will appear as a vertical (not horizontal) bar.
■ The New Toolbar dialog box appears.
ˇ Click OK.
■ Your new toolbar appears.
› Type a name for your toolbar in this space.
577
BUILD AN APPLICATION
I’d rather be able to move my toolbar around the window instead of docking it at the top of the screen. How do I do that? To move a toolbar from the default area, position the mouse pointer over the left edge of the toolbar. When the pointer changes to a four-way arrow, click the toolbar and, holding down the left mouse button, drag the toolbar to the desired position.
6048-4 ch20.F
10/19/99
3:20 PM
Page 578
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
ADD BUTTONS TO A TOOLBAR
fter you create a custom toolbar, you need to populate it with buttons and menus so your users can perform the tasks they need to do. You’ll learn how to add menus to a toolbar later in this chapter. You should add a button to your toolbar for every function your users will need to launch
A
⁄ Click Commands.
578
from within your database. If you like, you can tie specific toolbars to individual forms or reports. So, if your users needed to enter data and update the underlying tables from only one form, you could have the relevant toolbar appear in that form alone. You can also, if you like, add buttons to the standard toolbars that come with Access. There’s
Note: If your toolbar isn’t on the screen, follow the steps in task "Show or Hide a Toolbar," subtask "Show a Toolbar," to show the toolbar to which you want to add buttons.
quite a bit of overlap among the default toolbars — many of them include the Open, New, and Print buttons as their first three items. Take the time to browse through the standard toolbars; chances are you’ll find one that’s precisely what you need or can be turned into what you need with a few modifications.
■ The Commands pane appears. ¤ Click the category containing the command you want to add to your toolbar.
Note: In this case, we clicked Records.
6048-4 ch20.F
10/19/99
3:20 PM
Page 579
How do I reset a toolbar to its original state? You can reset a toolbar by opening the Customize dialog box, clicking the toolbar’s name, and clicking the Reset button.
■ The commands in the Records category appear in this pane.
‹ Drag the command you want to add to your toolbar onto the toolbar.
How do I delete a toolbar button? Deleting a button from a toolbar is simple: just drag the button off the toolbar.
■ The button appears on the toolbar.
Note: In this case, we chose Sort Ascending.
579
BUILD AN APPLICATION
III
6048-4 ch20.F
10/19/99
3:20 PM
Page 580
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
MOVE OR COPY A TOOLBAR BUTTON hen you’re creating a custom toolbar, or modifying an existing one, you should display all of the toolbars that you think might have buttons you can use with the toolbar you’re working on. Once you’ve got a clear picture of what preexisting buttons you have to choose from, you can finalize your design and start copying.
W
MOVE A BUTTON
⁄ Show both toolbars, as you learned to do in task “Show or Hide a Toolbar,” subtask “Show a Toolbar.”
580
If you’re creating a toolbar for working with database objects like forms, reports, and queries, you should strongly consider including the three basic buttons: New, Open, and Save. This is especially true if you’re replacing the standard Database toolbar and/or the menu bar in your application. You can also move buttons within a toolbar. Since most
¤ Click the button you want to move and, holding down the Alt key and the left mouse button, drag it to the destination toolbar.
default toolbars have a standard order for the first few buttons (New, Open, Save, Print, Print Preview, etc.), you should consider using that order in your custom toolbars to make it easier for your users to acclimate themselves.
■ The button moves to the destination toolbar.
6048-4 ch20.F
10/19/99
3:20 PM
Page 581
I held down the Alt key but the button didn’t copy to the destination toolbar. Why is that? You probably have the Customize dialog box closed. When you have the Customize dialog box open, hold down the Ctrl key to copy a button.
COPY A BUTTON
⁄ Show both toolbars, as you learned to do in task “Show or Hide a Toolbar,” subtask “Show a Toolbar.”
‹ Click the button you want to copy and, holding down the left mouse button (and the Ctrl+Alt keys), drag it to the destination toolbar.
How do I reposition a button on a toolbar? You can reposition a button on a toolbar by simply dragging it to the desired location on the toolbar.
■ The button appears on the destination toolbar.
¤ Press and hold down the Ctrl+Alt keys. 581
BUILD AN APPLICATION
III
6048-4 ch20.F
10/19/99
3:20 PM
Page 582
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
CREATE A CUSTOM TOOLBAR BUTTON
s you have seen earlier in this chapter, Access has a broad range of standard buttons you can use to include useful functions on your custom toolbars. You can, however, also create your own buttons. For instance, if there are a number of forms you want your
A
⁄ Follow steps 1–2 in task “Add Buttons to a Toolbar” to open the Commands page of the Customize dialog box. ¤ Click All Tables.
582
users to have easy access to, you can add buttons to open those forms to a toolbar. You can do the same for queries, reports, macros, and any other objects in your database. Access makes it easy for you to see lists of your database objects, either all at once or by
Note: In this example, we will create a button that opens the Products table in the Northwind database.
type. You can add as many buttons as you like to your toolbar. If you want to add more than a few objects, though, you might consider creating a toolbar for each object type.
■ The list of tables appears in this pane. ‹ Click the table you want to open and, holding down the left mouse button, drag it to the toolbar.
Note: In this case, we clicked Products.
6048-4 ch20.F
10/19/99
3:20 PM
Page 583
There are more buttons on my toolbar than can fit on the screen. How do I see the additional buttons? You can display the additional buttons by clicking the arrow button at the end of the toolbar.
■ The button appears on the toolbar.
› Click Close.
I don’t want to use the image Access put on my new toolbar button. How can I change it? See the next tasks, “Change and Reset a Button Image” and “Edit a Button Image.”
■ The Customize dialog box disappears.
583
BUILD AN APPLICATION
III
6048-4 ch20.F
10/19/99
3:20 PM
Page 584
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
CHANGE AND RESET BUTTON IMAGES
he standard button designs Access uses clearly communicate their function. For instance, buttons to open forms use the same icon as the Forms directory listing in the main Database window. If you like, you can choose or create a custom design for your toolbar button faces. Access has a wide range of alternate designs
T
CHANGE A BUTTON IMAGE
⁄ Follow steps 1–2 in task
for your buttons, from simple shapes to pictures of keys and other items, that can be used to identify a button’s function to your users. You should take care to ensure your button designs remain consistent throughout your database, especially if you tie specific toolboxes to individual forms and reports. It’s easy to
Note: In this case, we clicked the Page button.
“Add Buttons to a Toolbar” to open the Commands page of the Customize dialog box.
‹ Click Change Button Image.
¤ Right-click the button you
› Click the image you want to display on your button.
want to edit.
584
create and remember themes, though. For instance, you might use a button with a key as the trigger for the user to enter a password and get permission to open or change a database object. If you don’t like your choice, you can always revert to the original button design.
■ The new image appears on the button.
6048-4 ch20.F
10/19/99
3:20 PM
Page 585
I’d like to copy a button’s image for use in a form or report. How do I do that? You can copy a button’s image while the Customize dialog box is open by rightclicking the button you want to copy and clicking Copy Button Image from the shortcut menu that appears.
RESET A BUTTON IMAGE
⁄ Right-click the button you
¤ Click Reset Button Image.
How do I have Access use a word or phrase as my button’s “image?” You can have Access use a text phrase as your button image by opening the Customize dialog box, right-clicking the button in question, and clicking Text Only.
■ The button image resets.
want to reset.
585
BUILD AN APPLICATION
III
6048-4 ch20.F
10/19/99
3:20 PM
Page 586
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
EDIT A BUTTON IMAGE
ccess lets you pick from a wide variety of images for your button faces, although you may not be able find one you like. So, Access gives you an image editing tool that lets you create a button that meets your needs. Access gives you a 16-color palette to work with in editing your button. You can edit pixel by
A
⁄ Follow steps 1 and 2 in task “Add Buttons to a Toolbar” to open the Commands page of the Customize dialog box.
586
pixel, changing each dot as often as you like. Or, if you like, you can hold down the left mouse button and edit every dot the mouse pointer crosses. One trick you can use to make sure your onscreen design matches your vision is to find a design that includes an element that’s close to the pattern you
¤ Right-click the button you want to edit. ‹ Click Edit Button Image.
want to appear on your button and modify the rest of the button as needed. A preview of your design appears in the lower-right corner of the screen.
■ The Button Editor appears.
› Click the color of block you want to add to your design. ˇ Click the block you want to replace.
6048-4 ch20.F
10/19/99
3:20 PM
Page 587
Can I add more than one block at a time? You can add or modify more than one block at a time by holding down the left mouse button and sweeping the pointer over the blocks you want to modify.
How do I completely erase the design on the screen? To completely erase the design on the screen, click the Clear button.
How do I erase blocks in the previous design? To erase blocks, simply click the Erase block at the bottom of the window and edit the drawing normally.
■ The block changes to the color you selected.
Á Click OK.
■ The button appears with the new design.
Note: Repeat steps 4 and 5 to create your custom design.
587
BUILD AN APPLICATION
III
6048-4 ch20.F
10/19/99
3:20 PM
Page 588
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
CREATE A CUSTOM MENU BAR
ccess gives you a wide variety of prefabricated menus to choose from, although you may find that the functions you want to have in easy reach don’t all appear on the same menu. Rather than crowd your Database window, you can create a single menu with the commands you need.
A
⁄ Click Tools.
588
When you create a custom menu bar you should make sure you include the items your users need, but no more than are absolutely necessary. The goal behind creating a custom menu bar is to put a limited number of commands in an easily accessible space — adding unnecessary
¤ Click Customize.
commands to your menu bar could confuse your users. If you want, you can create submenus on your custom menu bar. You’ll learn how to do that later in this chapter.
■ The Customize dialog box appears.
‹ Click Menu Bar. › Click New.
6048-4 ch20.F
10/19/99
3:20 PM
Page 589
How do I show or hide a custom menu bar? To show or hide a custom menu bar, click the check box next to the menu bar’s name. If the box is checked, the menu will be shown; otherwise, it will be hidden.
■ The New Toolbar dialog box appears. ˇ Type a name for your menu in this space. Note: In this case, we typed “Application Menu.”
Note: Access treats menus and toolbars similarly, so it uses the same program elements to create toolbars and menus.
How do I replace the default menu bars with my custom menu bars? To replace a default menu bar with your own, simply hide the default menu bar and dock your own menu bar in its place.
■ Your menu bar appears.
Á Click OK.
589
BUILD AN APPLICATION
III
6048-4 ch20.F
10/19/99
3:20 PM
Page 590
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
ADD A BUILT-IN MENU TO A CUSTOM MENU BAR hen you create a custom application or attach a menu to a form or report, you can create the menu from scratch if you want. Alternatively, you could use the built-in menus that come with Access to augment your own custom menu bars.
W
⁄ Open the Customize dialog box as you learned to do in steps 1 and 2 of task “Create a Custom Menu.” ¤ Click the name of your menu.
590
There are 14 built-in menus available for you to use: File, Edit, View, Relationships, Insert, Query, Diagram, Format, Records, Filter, Run, Tools, Window, and Help. The File and Edit menus are standard Windows menus that should appear in every program; you should consider including
Note: If your custom menu is not displayed, click the check box next to its name.
‹ Click Properties.
them in your custom menu bars as well. The other built-in menus are optional, although they all fit well if used in the proper context. For instance, if you create a datasheet form, you might want to add the Filter menu so the user can limit the data on the screen.
■ The Toolbar Properties box appears. › Click the Type drop-down menu button. ˇ Click Menu Bar.
Note: If the Show on Toolbars Menu option is not checked, click it now.
Á Click Close.
6048-4 ch20.F
10/19/99
3:20 PM
Page 591
Can I add a built-in menu to a toolbar? Access treats toolbars and menus similarly; to add a menu to a toolbar, simply show the toolbar and add the menu as you learned to do in this task.
Can I add commands to a built-in menu? Yes, you can add and delete commands from built-in menus. See the task “Add an Item to a Menu,” later in this chapter.
■ The Toolbar Properties dialog box disappears.
Note: The Commands page appears.
■ The list of built-in menus appears in this area.
‡ Click Commands.
° Click Built-in Menus.
· Click the built-in menu
Note: In this case, we chose File. Note: The built-in menu appears on the menu bar.
you want to add and, holding down the left mouse button, drag it to the custom menu bar.
591
BUILD AN APPLICATION
III
6048-4 ch20.F
10/19/99
3:20 PM
Page 592
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
ADD A CUSTOM MENU TO A MENU BAR n addition to rearranging the existing Access menus on your custom menu bar, you can create entirely new custom menus to add. If you are creating a custom application for your users, a
I
⁄ Follow steps 1 and 2 in task “Add Buttons to a Toolbar” to open the Commands page of the Customize dialog box.
custom menu is especially useful because you can include just those commands users need. By limiting which commands are easily accessible, potentially in combination with user and group permissions discussed in
Note: If your menu bar is not displayed, click the Toolbars tab and click your menu bar's name in the list of items in the left pane of the Customize dialog box.
¤ Click New.
592
Chapter 22, you can make it easy for your users to perform their tasks without worrying about accidentally modifying the application.
■ New Menu appears in the right pane of the Customize dialog box.
‹ Click New Menu and, holding down the left mouse button, drag it to the menu bar.
6048-4 ch20.F
10/19/99
3:20 PM
Page 593
My new menu doesn’t have anything in it! How do I add commands? It’s easy. See the next task, “Add an Item to a Menu.”
■ The new menu appears on the menu bar. › Right-click your new menu.
ˇ Click the Name text box. Á Type a new name for the menu.
How do I delete a custom menu? You can delete a custom menu by opening the Customize window, clicking the name of the menu, and clicking Delete.
■ Your menu appears with the new name.
‡ Press Enter.
593
BUILD AN APPLICATION
III
6048-4 ch20.F
10/19/99
3:20 PM
Page 594
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
ADD AN ITEM TO A MENU
fter you create a custom menu, you need to add to it items your users can use to perform the tasks they need to do. You should add an item to your menu for every function your users will need to
A
⁄ Follow steps 1 and 2 in task “Add Buttons to a Toolbar” to open the Commands page of the Customize dialog box.
launch from within your database. If you like, you can tie specific menus to individual forms or reports. So, if your users needed to enter data and update the underlying tables from only one
¤ Click the category containing the item you want to add. Note: For this example, we clicked Macro Design.
form, you could have the menu with the functions to perform those tasks appear in that form alone. You can also, if you like, add menu items to the standard toolbars that come with Access.
■ The commands associated with Macro Design appear in this pane.
‹ Click the command you want to add to the menu and, holding down the left mouse button, drag it to the menu bar. Note: In this case, we chose Run Macro.
594
6048-4 ch20.F
10/19/99
3:20 PM
Page 595
I accidentally added the item to the main menu bar. How can I delete it and try again? To delete a menu item while the Customize dialog box is open, simply right-click the item and click Delete.
■ The menu name recesses and a blank drop-down list appears when the mouse pointer is in the proper position.
› Still holding down the left mouse button, move the mouse pointer onto the blank drop-down area.
Can I add a menu to another menu? You can create nested (or sub) menus by dragging the name of the menu you want to add in the same way you add a single command.
■ The item appears in the menu.
ˇ Release the left mouse button.
595
BUILD AN APPLICATION
III
6048-4 ch20.F
10/19/99
3:20 PM
Page 596
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
CREATE A SHORTCUT MENU epending on the amount of customizing you do with your forms and reports, you may not want to take up any more room with menus or toolbars docked at the edges of the screen. Access gives you the ability to create shortcut menus, also
D
⁄ Create a menu using the skills you have learned throughout this chapter.
called “pop-up” menus. Pop-up menus appear when you rightclick a database object. If you associate a pop-up menu with a control, such as a command button, the menu will appear when you right-click the control. If you associate the pop-up menu with a form or report, when you
¤ Click Toolbars.
right-click on a blank space of the form or report, the shortcut menu will pop up.
■ The Toolbars page of the Customize dialog box appears. ‹ Click the menu you want to make a shortcut menu.
596
Note: In this case, we clicked Application Menu.
› Click Properties.
6048-4 ch20.F
10/19/99
3:20 PM
Page 597
How do I display my shortcut menus so I can edit them? You can show your shortcut menus by opening the Toolbars page of the Customize dialog box and clicking the Shortcut Menus check box.
■ The Properties page appears. ˇ Click the Type drop-down menu button.
Note: If you are asked if you are sure you want to make the menu a shortcut menu, click OK.
Now I’ve got a shortcut menu, but how do I attach it to an object? You use the Properties dialog box for the object. See the next task, “Attach a Menu to a Form or Report,” for details.
■ The menu transforms into a shortcut menu and disappears.
‡ Click Close.
Á Click Popup.
597
BUILD AN APPLICATION
III
6048-4 ch20.F
10/19/99
3:20 PM
Page 598
20
CHAPTER 20: CREATE CUSTOM TOOLBARS AND MENUS
ATTACH A MENU TO A FORM OR REPORT hen you associate a pop-up menu with a control, such as a command button, the menu will appear when you right-click the control. If you associate the popup menu with a form or report, however, the menu will appear
W
⁄ Open the form or report in which you want your menu to appear in Design view, as you learned to do in the Chapter 11 task “Open a Form in Design View.”
598
when you right-click on a blank space of the form or report. Associate a shortcut menu with every object in your database if there are functions your users will need to access throughout the application. For instance, if you have created a
Note: In this case, we opened the Products form.
¤ Click the Properties button.
macro that updates the information in a table or query, you might want to make that macro available for your users whenever they are working in the database.
■ The Properties dialog box appears.
‹ Click Other.
6048-4 ch20.F
10/19/99
3:20 PM
Page 599
How do I designate a shortcut menu as the default for an entire Access database? To designate a shortcut menu as the default for your database, open the Tools menu, click Startup, click the drop-down menu button in the Shortcut Menu Bar text box, and select the name of the shortcut menu you want.
■ The Other page appears. › Click Menu Bar. ˇ Click the drop-down menu button.
Á Click the name of the menu bar you want to associate with this form or report.
My default shortcut menu doesn’t appear when I right-click a blank spot on my forms and reports.Why not? The default shortcut menu assignment doesn’t take effect until you close and reopen your database.
■ NorthwindCustomMenu Bar appears in the Menu box.
‡ Click the Close box to close the Properties dialog box.
Note: In this case, we chose NorthwindCustomMenuBar.
599
BUILD AN APPLICATION
III
6048-4 ch21.F
10/19/99
3:23 PM
Page 600
21
CHAPTER 21: CREATE SIMPLE VISUAL BASIC PROCEDURES
BUILD AN APPLICATION
3
CREATE SIMPLE VISUAL BASIC PROCEDURES
isual Basic for Applications is a powerful programming environment that allows you to create custom procedures that can be invoked from controls on a form or report. In this
V
Data Types– When you create a table to store your data, Access requires you to assign each field a data type so it knows how to handle the data in that field. When you create a Visual Basic for Applications (VBA) code module, you need to do the same. VBA has quite a few data types; the one you pick will depend on the type of data (number, character string, or a yes/no value) you want to store in the variable. 1/0
$15,000.00
1x1032
Y 800,000
chapter, you will learn a bit about the structure of Visual Basic before learning how to create procedures of your own.
working at a company for a number of years, for example), but the program itself does not change the constant value. (And if the constant did change, you’d only need to modify its value in the program once, where it was assigned initially.) By contrast, variables are usually calculated (or changed) by the program. One example of a variable would be the commission a sales rep earns on a particular sale. The code module would multiply the total value of the sale (itself a variable as it changes from sale to sale) by the commission (a constant) to derive the sales representative’s commission.
x=5
x = 5 (or 3, or 4)
7/12/39
Constants and Variables– In VBA code modules, as in any computer program, you work with two kinds of data elements: constants and variables. As the name implies, a constant is a value that doesn’t change in the course of a program. The constant’s value might be someone’s birthday, a state’s sales tax, or the commission a sales representative is paid for a sale to a customer. The constant’s value could change because of outside factors (a sales representative could move to a higher base commission after 600
Examine a Sample Procedure– Learning a programming language, like learning a spoken language, takes time. To get yourself comfortable with this new tongue, you should examine some sample code modules before you start creating your own. In particular, you should pay special attention to any comments the module’s programmer has included in the code. VBA comments, which are set off in the code by a single quotation mark ( ‘ ), are used to explain what’s being done in the code commented
6048-4 ch21.F
10/19/99
3:23 PM
Page 601
Private sub form _ Activate
Exit form_Activate View All Predefined VBA Procedures– When you want to create a new database object like a form or report, Access gives you the option of creating the object from scratch or with the help of a wizard. Like using wizards to create database objects, you can include the prebuilt VBA procedures in your own code modules. Within the editor, you can choose which type of procedures you want to view by clicking the type of object (for example, form, report, table, query, and so on) you want to affect with your VBA code. Once you’ve opened the interface, called the Object Browser, you can select which subset of procedures you’d like to view. The Object Browser’s interface is designed very much like the Contents tab in the Access Help system (described in Chapter 1). You pick the library of procedures you’d like to look at and then pick which class of procedures within that library contains the procedure you’d like to work with. Libraries contain all of the procedures connected with a particular object type (for example, queries),
while classes divide a library’s contents into procedures that perform specific tasks (like printing all or some of a report’s contents). III AC Apply filter AC Apply server filter AC Between AC Bound object frame
Create a Sample Procedure– Once you’ve taken the time to look through some procedures, read the comments in the code, and decide which task you’d like to perform using a VBA module, you should take the plunge and create a sample procedure. Clearly define what you want to accomplish with your code, find the procedures you need to make it happen, assemble the components in a module, and comment your work. Option Compare Database
Option explicit
601
BUILD AN APPLICATION
upon, what variables are being used, and what (if any) revisions have been made to the code since it was first put into production. When you write your own modules, you should also comment them; your comments will help anyone who has to revise the module later (even if that person is you; your memory might not be as good down the road as you hope it is now). Comments can be as long as you like. If they spill over onto a second line, all you need to do is close the first line with a single quotation mark and begin the second line with a single quotation mark and a space.
6048-4 ch21.F
10/19/99
3:23 PM
Page 602
21
CHAPTER 21: CREATE SIMPLE VISUAL BASIC PROCEDURES
FAMILIARIZE YOURSELF WITH VISUAL BASIC
isual Basic for Applications (VBA) allows you to write programs (sets of executable instructions) that Access can run when the program is called by an event that takes place in your database. In this chapter, you will learn how to write a program called by a control on a form. You can also write programs that are not attached to a particular object in your database. Programs written in VBA consist of two types of procedures: subroutines and functions. Subroutines and functions differ only in how they generate their output. A subroutine processes data but does not pass along a result for the rest of the program to use; a function does. For instance, you would use a subroutine to open a form but call a function to average the cost of a customer’s orders. (For once, form does not follow function.)
V
DATA TYPES When you write a VBA program, you tell Access what type of information it expects from each variable in the program. This assignment is just like when you learned to assign data types to the fields in your tables back in Chapter 3. VBA allows you to work with a number of different data types. The VBA data types are listed here: Byte: 0 to 255 Boolean: True or False Date: 1/1/100 to 12/31/9999 Integer: Whole numbers (that is, numbers without decimals) between –32,768 and 32,768 Long: Whole numbers between –2,147,483,648 and 2,147,483,648 String: Text up to about 64,000 characters Currency: Monetary amounts from –955,337,203,685.5808 to 955,337,203,685.5807 (up to four decimal places allowed) 602
Single: Real numbers (that is, numbers with decimal components) from –1.40 × 10-45 to 3.40 × 1038 Double: Real numbers from –4.94 × 10-324 to 1.79 × 10308 Variant: A generic data type that can hold any of the previous types USING CONSTANTS A constant is a data element with a value that doesn’t change within a program. You assign a value to the constant at the beginning of your program and, whenever you need to use it, you can simply use the constant’s name instead of the actual value. That way, just in case the value of the constant did change (like if a state increased its sales tax), you would only need to modify your program once. String constants (that is, constants with the data type string) are written in quotes: “Arthur Dent” Date constants #8/2/68#
are surrounded by number signs:
Constants may be defined in a program using a command of this type: Const Birthday = #8/2/68# Where Const tells VBA you want to create a constant, Birthday is the name of the constant,
the expression after the equals sign is the value assigned to the constant.
and
6048-4 ch21.F
10/19/99
3:23 PM
Page 603
USING VARIABLES
Dim PaymentReceived As Date In that command, Dim (short for
“dimension”) tells VBA you want to create a variable, PaymentReceived is the name of the variable, and As Date defines the data type. You can make your code easier to read by naming your variables in a way that lets anyone examining your code know the variable’s data type without checking the variable’s definition. The conventional prefixes are as follows:
Boolean: bool
Byte: byt
Currency: cur
Date: dte
Double: dbl
Integer: int
Long: lng
Single: sng
String: str
Variant: var
III
Using this naming system, the previous command would be written: Dim dtePaymentReceived As Date
603
BUILD AN APPLICATION
A variable, on the other hand, will change in value as a program executes. To create a variable, you need to use a command like the following:
6048-4 ch21.F
10/19/99
3:23 PM
Page 604
21
CHAPTER 21: CREATE SIMPLE VISUAL BASIC PROCEDURES
EXAMINE A SAMPLE PROCEDURE
he best way to learn a new skill is to examine others’ work while you study the basics of your new tasks. Perusing grammar texts is one way to learn French, but there’s no substitute for conversing with a native speaker. When you look at a sample Visual Basic procedure, pay special attention to any comments included in the program. Programmers add comments to make their code more readable,
T
⁄ Click Modules.
604
both for themselves and for others who may need to examine, extend, or modify their programs. Comments in Visual Basic programs are identified by a single quotation mark ( ‘ ) and a space. When Access sees a single quotation mark followed by a space, it knows the rest of that line is meant as a comment, not program instructions, and skips to the next line. If your comment runs over to another line, simply
¤ Double-click Utility Functions.
begin the next line with the single quote and a space and write out the rest of your comment. Comments can take up as many lines as you need. Other elements of a Visual Basic program that bear examining are the declarations and data type definitions. Declarations tell Access how to handle program data and whether it should require the programmer to define a variable before using it in the program.
■ The Microsoft Visual Basic Editor appears containing the contents of the Utility Functions module.
2
6048-4 ch21.F
10/19/99
3:23 PM
Page 605
21
CHAPTER 21: CREATE SIMPLE VISUAL BASIC PROCEDURES
CLOSE THE VISUAL BASIC EDITOR
he Visual Basic Editor is a handy program to keep open, but you should consider closing it whenever you have finished editing your code. Since the Visual Basic Editor is a separate program, it takes up more memory than most database objects. Just as you should close
T
⁄ Click the Close box.
any unneeded forms and reports to save memory, you should shut down the Visual Basic Editor when you don’t need it. You can close the Visual Basic Editor in a number of ways. The simplest method is to click the Close box in the upper-right corner of the Editor window,
though you can also use the Close and Return to Microsoft Access option under the File menu. If you prefer to use the keyboard, the shortcut to close the Editor is Alt+Q.
■ The editor disappears.
605
BUILD AN APPLICATION
III
6048-4 ch21.F
10/19/99
3:23 PM
Page 606
21
CHAPTER 21: CREATE SIMPLE VISUAL BASIC PROCEDURES
VIEW ALL PREDEFINED VBA PROCEDURES
ccess makes your Visual Basic programming job a lot easier by including all of its predefined procedures in the Object Browser. If you don’t know (or can’t remember) the exact procedure you should use for a task, you can use the Object Browser to locate the one you need. The Object Browser interface is very much like the interface for
A
⁄ Click Modules.
Access’ Help system, described in Chapter 1. Just as you can browse the contents of the Help system by opening “books” (described in task “Getting Help: Using the Contents Tab”), you can view the contents of each class of actions. Visual Basic procedures are organized into libraries and classes. A library contains all of the procedures for a particular database object or group of
¤ Click New.
objects. A class is a subset of a library; each class contains the procedures associated with a particular task, such as finding a file or manipulating a form.
■ The Microsoft Visual Basic Editor appears. Note: You may want to maximize your Code window to make its contents more legible. For instructions, see task “Maximize a Window” in Chapter 1.
606
‹ Click the Object Browser button.
6048-4 ch21.F
10/19/99
3:23 PM
Page 607
How do I limit my view to the contents of a single library? You can limit your view in the Object Browser to a specific library by clicking the drop-down menu button in the Project/Library list box and clicking the library you want to view.
■ The list of classes appears.
Note: In this case, we clicked AcCloseSave.
If I know the procedure I want, is there a faster way to find it? Use the Search function. Just enter a string to search for in the box below the Project/Library list box and click the binoculars button.
■ The list of procedures in class AcCloseSave appears.
› Click a class.
607
BUILD AN APPLICATION
III
6048-4 ch21.F
10/19/99
3:23 PM
Page 608
21
CHAPTER 21: CREATE SIMPLE VISUAL BASIC PROCEDURES
ADD A PREDEFINED PROCEDURE TO A MODULE nce you’ve located the procedure you want to add to your Visual Basic program in the Object Browser, it’s easy to copy it over. Simply click the procedure, click the Copy to Clipboard button on the toolbar (or choose the Copy option from the Edit menu), and
O
⁄ Open the list of predefined VBA procedures as you learned to do in task “View All Predefined VBA Procedures.”
608
paste the procedure name into your program. Copying a procedure name over directly is much easier and accurate than keeping track of all of the procedures you might use and typing in their names from memory. While you can only copy one procedure at a time,
you’ll save time in the long run by ensuring the procedure names are spelled properly. The Object Browser’s interface makes it easy for you to find the procedure you want. Simply follow the steps in task “View All Predefined VBA Procedures” to locate the procedure you want.
¤ Click the procedure you want to add to your module.
■ The procedure appears in
Note: For this example, we clicked acSaveYes.
‹ Click the Copy to
this space. Clipboard button.
› Click Window. ˇ Click Northwind – Module 1 (Code).
6048-4 ch21.F
10/19/99
3:23 PM
Page 609
How do I show the class I had open before the one I have open now? You can press the Go Back button to move to the class you were viewing before the one currently in the window. The Go Forward button will move you toward the most recently opened class one item at a time.
■ The module appears. Á Click Edit.
‡ Click Paste.
Can I search for modules by all or part of their names? You can search for modules by entering the string you want to search for in the box below the Project/Library list box and clicking the Search button.
■ The procedure name appears in the module.
609
BUILD AN APPLICATION
III
6048-4 ch21.F
10/19/99
3:23 PM
Page 610
21
CHAPTER 21: CREATE SIMPLE VISUAL BASIC PROCEDURES
CREATE A SAMPLE PROCEDURE ow that you’ve studied Visual Basic’s grammar and vocabulary, it’s time you started speaking the language. Any language class worthy of the name starts its students in easy situations where they can apply their knowledge effectively. Access has a similar capacity in that it makes it simple for you to create your first procedure.
N
⁄ Open a form in Design view. Note: For this example, we opened the Customers form from the Northwind sample database.
610
Just like in the Chapter 16 task “Invoke Controls from Macros: Create a Source Control,” Access lets you use the wizards to create your controls. Once you have created the control to launch your Visual Basic procedure, you can have Access create the procedure for you automatically. Another nice feature of Visual Basic is that, when you build a
¤ Create a command button as you learned to do in the Chapter 13 task “Create a Command Button.” Note: Make sure the Control Wizards button is the toolbox is deselected.
procedure through a wizard, Access creates simple errorhandling routines for your object. If something unexpected happens, which it sometimes will, your procedure will probably know how to handle it.
■ The command button appears. Note: If the Control Button Wizard started, click Cancel to close it.
‹ Right-click the command button.
› Click Build Event.
6048-4 ch21.F
10/19/99
3:23 PM
Page 611
How do I modify a procedure created by a wizard? You can modify any procedure by opening it in the Visual Basic Editor and adding, changing, or deleting statements. You should be careful when changing procedures generated by wizards as improper changes could cause them to malfunction.
■ The Choose Builder dialog box appears.
ˇ Click Code Builder.
Á Click OK.
How do I view an event associated with a control? You can view an event associated with a control by right-clicking the control and clicking Build Event from the menu that appears.
■ The Visual Basic Editor appears with the basic statements needed to create a procedure.
‡ Click between the left and right parentheses in the code fragment following Private Sub.
Note: The insertion point (represented by a blinking cursor) appears between the parentheses.
° Click the Object Browser button. CONTINUED
611
BUILD AN APPLICATION
III
6048-4 ch21.F
10/19/99
3:23 PM
Page 612
21
CHAPTER 21: CREATE SIMPLE VISUAL BASIC PROCEDURES
CREATE A SAMPLE PROCEDURE CONTINUED nce you’ve created a command button, opened the Code Builder, and selected the Object Browser, all you have left to do is arrange the procedures you want to include in your VBA module. Remember that procedures in the Object Builder are organized
O
■ The Object Browser appears. · Click the class you want to pick your procedure from. Note: In this case, we clicked AcPrintRange.
612
by libraries and classes. A library contains all the procedures associated with a particular object (like a form). The classes include sets of related actions on each object. If you choose the All Libraries option in the Object Builder, you can pick from all the classes
‚ Click the procedure you want to add to your code module. — Click the Copy to the Clipboard button.
± Click the Close box.
available in Access. Be careful with All Libraries, though. If you choose a procedure that doesn’t apply to the object with which you’re working, your module could have unexpected results (or no results at all).
■ The Object Browser disappears.
Á Click Edit.
ª Click Paste.
6048-4 ch21.F
10/19/99
3:23 PM
Page 613
Code appears in the Visual Basic Editor when I open the Code Builder.Why? If you’d previously added any VBA code to the database object you’re working in now, that code will appear in the editor.
■ The procedure you selected appears in the code module.
£ Click File.
¢
Click Close and Return to Microsoft Access.
What’s the difference between a module and a procedure? A module is a collection of procedures, like a macro group is a collection of macros.
° ¤ Click the Properties
The Visual Basic Editor disappears. button.
BUILD AN APPLICATION
III
Note: Event Procedure, representing the code module you just created, appears in the OnClick property. You can launch the procedure by clicking the button while viewing the form in Form view.
¦ Click the Event tab.
613
6048-4 ch22.F
10/19/99
3:27 PM
Page 616
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY 2000
4
DATABASE ADMINISTRATION AND SECURITY ven when your database application is complete, your work still isn’t done. Maintaining the database involves backing up your data, in case of computer failure or other unforeseen occurrences; creating user accounts and setting access privileges, so that you specify the only people who can perform potentially dangerous operations on the database; and creating replicas of
E
Back Up and Restore Databases– Maintaining current backup copies of databases is the only way to ensure your company’s data isn’t lost from a power surge, virus, or natural disaster like a fire or earthquake. Each backup copy of your data should include the date of the backup in the file’s title. Windows 95/98’s long filename conventions give you the freedom to name your files in most any way you want. You should take advantage of that capability to note the database’s name, the date the backup was performed, and the operator that performed it.
DB
the database, so that traveling users can access and add data without compromising the original information. By taking administration and security tasks seriously, you ensure the integrity of information in your database, so that your users can reply on your data’s accuracy and make good decisions.
them a copy of any data they need to take with them. But you might not want to give each representative a complete copy of a database, since you don’t want users changing the database structure. You can, however, create an uneditable version of the database for roaming users. These versions are called replicas. The difference between a replica and a copy (which you learned how to make in Chapter 1) is that your user can’t change the structure of the replica, although new content can be added. You can replicate a few tables, forms, or queries to give your representatives the minimal functionality they need on the road. For example, if your sales representatives were out taking orders from existing customers, you would only need to replicate a New Order table and a Contacts table, in case a customer changed the individual responsible for placing orders.
Archive CD
DB
Creating Database Replicas– If you work for an organization that sends representatives on the road, you should give 616
BD
6048-4 ch22.F
10/19/99
3:27 PM
Page 617
Document a Database–
DB
XQ
IV
Enter your decryption key.
Create a User Account– DB
10 tables 8 forms 8 reports Details following
Encrypt and Decrypt Databases– In most cases, the way Microsoft Office programs interact is a great strength of the suite. For example, you can use Microsoft Word to open just about any file that is stored in text format. However, while using a text editor to modify a database can be useful in some circumstances, such as if you attempted to import a text file into an Access table but there was a stray comma in the text that threw off your import, you usually don’t want users to open your databases in any program other than Access. You can prevent users from opening your databases with programs other than Access by encrypting them. Encrypting a database doesn’t make it impossible to open in Access or provide any sort of password protection, but it
Whenever you create a database, you should strongly consider creating user accounts for anyone who needs to use it. By creating user accounts and assigning each user permissions within your database, you can make it difficult for unauthorized users to change any information in your database. Some of the more common jobs your users might have are to back up your database, add new data, run a stock set of queries at the end of every business day, or to act as a substitute administrator when you are out of the office. By defining each user’s role and putting them in the appropriate user groups, you can ensure these tasks can only be initiated by users you trust to perform them.
User
cfrye
Password
******
617
COLLABORATE USING ACCESS 2000
It’s possible to keep track of every object in a small database in your head, but once you add complexity in the form of macros, Visual Basic code, or even by increasing the number of objects in your database, keeping a mental log becomes impossible. The Documenter creates a report containing the name of each object, its components (the fields it contains, the fields’ data types, the actual Visual Basic code, etc.), and where the object can be found.
does ensure users won’t be able to modify your file without going through Access (and any user permissions you’ve established).
6048-4 ch22.F
10/19/99
3:27 PM
Page 618
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
BACK UP A DATABASE ne of the most important duties of a database administrator is to make sure none of your data is lost due to accidents or power failures. There are quite a few software packages available to archive your records; one such program is the Backup utility that’s included with most Windows95/98 distributions. If possible, you should create more than one backup copy of your databases. Floppy disks are well suited for storing copies of
O
⁄ Click Start. ¤ Click Programs.
small databases, though you may need to use removable hard drives, tapes, or compact discs for larger files. If your computer is attached to a network, you could put one copy of your database on another machine on the network. How often you should back up your database depends on how often you update its contents. If your database is relatively static, you might want to back it up every week. If the contents are updated more frequently, such as
‹ Click Windows Explorer.
a running account of customer orders or other transactions, you should update the backups at least once a day.blan Establish an offsite storage plan if the databases are particularly critical to your organization. Keeping a copy of your database on CD-ROM in another location protects you against damage from fires, floods, and other disasters that could strike your home facility.
■ Windows Explorer appears.
› Open the directory containing Office. Note: Under the standard installation, this directory will be C:\Program Files\Microsoft Office\Office\.
618
6048-4 ch22.F
10/19/99
3:27 PM
Page 619
How do I back up specific objects in a database? You can back up specific database objects by creating a blank database and exporting objects to the new database. For instructions on how to export database objects, see the Chapter 7 task “Export Objects to Another Access Database.”
■ The directory appears.
Á Click File.
ˇ Click system.mdw.
‡ Click Send To.
Note: system.mdw is the workgroup file that contains the permissions and accounts for your database.
° Click 3_ Floppy (A).
My file is too large to fit on a floppy disk. How do I compress it? There are a number of good file compression utilities available as freeware and shareware. You can find them at popular software archive sites like Tucows (http://www.tucows.com).
■ Windows Explorer copies the system.mdw file to the A drive.
Note: To back up your main database, follow the steps presented above to copy your database to another drive.
619
COLLABORATE USING ACCESS 2000
IV
6048-4 ch22.F
10/19/99
3:27 PM
Page 620
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
RESTORE A DATABASE n the event you need to restore a database from a backup copy, Windows makes it easy for you to do so. You can simply start Windows Explorer, locate the backup file, and copy the archive to its new location. When you restore a database, you should make sure you are copying the most recent backup of the information onto your system. If you do accidentally copy an older version of your database onto your system, you should follow the directions in
I
⁄ Click Start. ¤ Click Programs.
620
the Chapter 10 task “Create a Make-Table Query” to find every entry made after you restored the database. If your database supports users at other locations, create a plan for notifying them the database needs to be restored, delivering the backup database to them, and ensuring the data is identical when they begin work with the new database. One way to ensure your systems are all in synch is to create a blank database that is similar in structure to the production
‹ Click Windows Explorer.
database. When you notify your users of a problem, they can simply switch to the blank database and, when the workday has ended, ship you the databases with their recent transactions. You can combine the information from those databases into your master database, generate another set of backups, and ship them back out to your users.
■ Windows Explorer
› Double-click 31/2 Floppy
appears.
(A:).
6048-4 ch22.F
10/19/99
3:27 PM
Page 621
I want to save the bad copy of the file I’m restoring. How do I avoid overwriting it when I restore from backup? You can ensure you don’t write over the bad copy of your database by either changing its name before you restore from backup or by copying the backup file over under a different name.
■ The contents of the A drive appear in this area. ˇ Click system.mdw. Á Ctrl+click the database file (in this case, address). Note: You need to back up the system.mdw file to preserve the accounts and permissions for your database.
My restored database won’t open or is acting strange.What might have gone wrong? You might have forgotten to restore the system.mdw from backup in addition to the database file.
‡ Click Edit.
■ The directory appears.
° Click Copy.
‚ Click Edit.
· Open the directory containing Office.
— Click Paste.
Note: If you are asked if you want to replace the existing system.mdw file, click Yes.
Note: This directory is usually C:\Program Files\Microsoft Office\Office\.
621
COLLABORATE USING ACCESS 2000
IV
6048-4 ch22.F
10/19/99
3:27 PM
Page 622
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
REPLICATING A DATABASE any organizations have users that need to take their databases on the road with them. Since it’s not practical for those users to wait until they can establish an Internet connection to the home base whenever they need to update their copy of a database,
M
⁄ Click Tools. ¤ Click Replication. ‹ Click Create Replica.
622
Access allows them to add their information locally and update the central database later. Replicating a database is similar to making a backup copy in that an exact duplicate of the original database is created, although there is one important difference. When you replicate a
Note: If you are asked if you want to close the database to continue, click Yes.
database, the replica’s structure is fixed and cannot be modified. By fixing the replica’s structure, Access ensures it will be able to synchronize the replica’s contents with the contents of the source database.
■ The Create Backup dialog box appears. › Click Yes.
Note: If you want to proceed without creating a backup copy of your database, click No. However, we strongly recommend you do create the backup copy.
6048-4 ch22.F
10/19/99
3:27 PM
Page 623
How do I change the structure of a replica to reflect the new structure of my source database? You will need to create a new replica of your source database whenever you change its structure. Keep in mind that, so long as there are replicas of your databases with information that has not been folded into the source database, you will need to maintain the source’s original structure to use Access’ synchronization feature.
■ The Location of New Replica window appears. ˇ Type a name for your replica in this space.
Á Click OK. Note: You can use the navigation controls to pick a new location to save your replica.
How do I allow my users to modify the structure of their copy of a database? If you want users to be able to modify the structure of their databases, you should copy the database instead of replicating it.
■ The Location of New Replica window disappears.
‡ The database objects in the Design Master copy of your database appear.
623
COLLABORATE USING ACCESS 2000
IV
6048-4 ch22.F
10/19/99
3:27 PM
Page 624
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
CREATE A PARTIAL REPLICA
reating a replica of a database is an easy way to allow your mobile users to take a copy of the database with them and add new data when needed, with no danger of damaging the underlying database structure. There may be times, whether due to hard drive space
C
⁄ Click Tools. ¤ Click Replication.
624
limitations or your organization’s needs, that you will want to send subsets of your master database out with your users. One case might be if a member of your marketing staff was out locating potential customers. Since that individual would not need to take orders, you could send them out with only the customer
‹ Click Partial Replica Wizard.
contact elements of your master database. You do this by making a partial replica of the database.
› Click “Create a new partial replica.”
ˇ Click Next.
6048-4 ch22.F
10/19/99
3:27 PM
Page 625
I want to determine which records will be added to my partial replica based on the contents of more than one table. How do I do that? If you want to create a partial replica based on criteria that would encompass more than one table under your database’s current structure, you will need to combine the information into a single table using a Make-Table query, as you learned to do in Chapter 10.
■ The next Partial Replica Wizard screen appears. Á Type the name and location for your partial replica in this space.
‡ Click Next.
How do I modify an existing partial replica? You can tell Access you want to modify an existing partial replica by clicking the radio button next to “Modify an existing partial replica” on the first Partial Replica Wizard screen.
■ The next Partial Replica Wizard screen appears. ° Click the “Table to filter” drop-down menu button.
COLLABORATE USING ACCESS 2000
IV
· Click the table name containing the values you want to use to filter your partial replica. Note: In this case, we selected the Household table. CONTINUED
625
6048-4 ch22.F
10/19/99
3:27 PM
Page 626
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
CREATE A PARTIAL REPLICA n past versions of Access, it was extremely difficult and time-consuming to creating a partial replica. In essence, you had to run a series of make-table queries to generate the desired subset of your information and copy those tables into a separate database. The Partial Replica
I
626
Wizard makes the process much easier. As you step through the wizard, Access asks you which tables you would like to include in your partial replica. Once you have made those selections, you can define any criteria you want Access to use in selecting records
CONTINUED to include in your partial replica. Some criteria you might use would be orders from a subset of your customers, orders placed after a certain date, products that need to be reordered, and customers assigned to a specific representative.
6048-4 ch22.F
10/19/99
3:28 PM
Page 627
Can I mix AND and OR criteria? You can mix AND and OR criteria by adding parentheses to the expression to group the criteria. For instance, if you wanted to add records that met criteria A and either criteria B or C, you would write the expression as A AND (B OR C).
IV
How do I tell Access to add records that meet one of two or more criteria? If you want Access to include any record that meets at least one of a number of criteria you define, you should add the first criteria, click Paste, then click the OR radio button in the left pane of the Wizard screen, define your next criteria, and click Paste.
627
COLLABORATE USING ACCESS 2000
How do I tell Access to only add records that meet more than one criterion? You can have Access require that records meet more than one criterion by clicking the AND radio button in the left pane of the Wizard screen, defining your additional criteria, and clicking Paste.
6048-4 ch22.F
10/19/99
3:28 PM
Page 628
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
DOCUMENT A DATABASE ven the simplest databases contain a lot of objects. Trying to keep track of Visual Basic code modules, tables, queries, and macros without documentation can confuse even the most experienced database administrator. A detailed picture makes it easier for you and your coworkers to work with your database successfully.
E
⁄ Click Tools. ¤ Click Analyze.
Access provides an easy-to-use tool for documenting your database. You just tell Access which elements of the database you want to document, all the way down to individual forms and reports if you like, and the Documenter does the rest. The Documenter generates a report that contains a detailed portrait of every object you selected. The portrait includes the
‹ Click Documenter.
name of each object, its properties, and the date it was modified last. Run the Documenter when you have settled on a database design that won’t change significantly in the future. If you should need to add objects to your database, you can select them in the Documenter window and generate a report that just includes the new objects.
■ The Documenter window appears. Note: Click the All Object Types tab if it is not currently selected.
628
■ Every object in your database appears in this area. › Click Select All.
6048-4 ch22.F
10/19/99
3:28 PM
Page 629
How do I document only certain elements of my database? You can select which elements of your database to document by clicking the tab with the name of the object type you want to document. If you only want to document a subset of the objects of that type, click the check box next to the name of each object you want to document.
■ Every object in the list activates.
ˇ Click OK.
How do I clear the list of choices in the current window? You can clear the list of choices in the current window by clicking Deselect All.
■ A report containing information on every object you selected appears.
Note: If you document your entire database, this report will be quite large and will take a very long time to appear.
629
COLLABORATE USING ACCESS 2000
IV
6048-4 ch22.F
10/19/99
3:28 PM
Page 630
22
2
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
ENCRYPT A DATABASE n most cases, the purpose of creating a database is to make information accessible to a broad range of users. There may be times, however, when you want to limit how users can get at the data and other objects in your database.
I
⁄ Click Tools. ¤ Click Security.
If left unencrypted, users can open your Access database files using other programs. Other programs with the capability to open Access files include word processors, spreadsheets, and other database programs. Encrypting an Access database
‹ Click Encrypt/Decrypt Database.
prevents anyone from opening the file in any program other than Access. That is, they might be able to open one of your files, but they will not be able to work encrypt with it.
■ The Encrypt/Decrypt Database window opens. › Double-click the name of the database you want to encrypt.
Note: You can encrypt any database other than the one you currently have open.
ˇ Type a name for the encrypted database in this space. Á Press Save.
630
6048-4 ch22.F
10/19/99
3:28 PM
Page 631
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
DECRYPT A DATABASE ncrypting a database is a handy way to ensure anyone without a copy of Access can’t look over your data, although it does make the database run significantly slower than it would in its unencrypted state. Once you’ve received an Access database in encrypted
E
⁄ Click Tools. ¤ Click Security.
form, you should decrypt it before working with it. Even though the database could, in theory, be examined or modified from other programs, you can take steps to ensure the database remains secure while you have it on your machine. You’ll learn about establishing permissions for users and groups
‹ Click Encrypt/Decrypt Database.
of users later in this chapter. If your data is at all sensitive, you should take steps to ensure that each individual and group has only the permissions they need. Encrypting and decrypting databases is merely the first step in that process.
■ The Encrypt/Decrypt Database window opens. › Double-click the database you want to decrypt.
ˇ Enter a name for the decrypted database in this space. Á Click Save.
631
COLLABORATE USING ACCESS 2000
IV
6048-4 ch22.F
10/19/99
3:28 PM
Page 632
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
CREATE USER ACCOUNTS
n important element of database administration is determining how much freedom users should have to view or change objects in your database. You’ll learn about assigning permissions to different types of users in the next task. This task shows you
A
⁄ Click Tools. ¤ Click Security.
how to establish accounts for individual users. Assigning user accounts is a great way to make sure you can keep track of which users can make which changes to your applications. If you are administering a database in a financial planning firm, for
‹ Click User and Group Accounts.
instance, establish an account for each sales representative. Not only would they be able to account for their activities by entering their sales information, your staff could account for every order when they count up at the end of the year.
■ The User and Group Accounts window appears.
Note: If the Users tab is not selected, click it now.
› Click New.
632
6048-4 ch22.F
10/19/99
3:28 PM
Page 633
How do I assign a password to a user? To assign a password to a user, simply select the user’s name from the list of users, click the Change Logon Password tab, and type in the old password, followed by the new password twice. You type in the new password twice to verify its spelling.
■ The New User/Group dialog box appears.
Á Type the user's Personal ID in this space.
ˇ Type the user's name in this space.
Note: The administrator assigns each user's Personal ID.
How do I remove a user’s password? You can remove a user’s password by clicking the Clear Password button. You need to have Administrator privileges to do so.
■ The new user account appears.
‡ Click OK.
633
COLLABORATE USING ACCESS 2000
IV
6048-4 ch22.F
10/19/99
3:28 PM
Page 634
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
CREATE A NEW USER GROUP
dding specific permissions for every database user would be a tedious process. Instead of forcing you to precisely define what every user should have access to, you can define permissions by group and add users to those groups. Access automatically defines two user groups in a database:
A
⁄ Click Tools. ¤ Click Security.
634
administrator and users. Administrators are able to perform any database function, whereas members of the user group are able to open the database but not make any changes. If you want, you can limit nonadministrative users to reading data, adding new data,
‹ Click User and Group Accounts.
modifying (but not deleting) existing data, or deleting data. You can also give users access to the database design, though without the ability to delete elements or modify the design.
■ The User and Group Accounts window appears.
› Click Groups.
6048-4 ch22.F
10/19/99
3:28 PM
Page 635
■ The Groups window appears.
ˇ Click New.
How do I see permissions for my new group? Click Tools ➮ Security ➮ User and Group Permissions. Then pick an object type and select or deselect the checkboxes next to the different permissions.
■ The New User/Group dialog box appears.
‡ Type an identifier for the group in this space.
Á Type the name of your new group in this space.
Note: In this case, we typed the group's name again.
° Click OK. Note: Your new group name appears in the group list.
635
COLLABORATE USING ACCESS 2000
IV How do I delete a user group? You can delete a user group by clicking the Group tab, selecting the group from the list accessed by clicking the drop-down menu button, and clicking the Delete button.
6048-4 ch22.F
10/19/99
3:28 PM
Page 636
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
ADD A USER TO A GROUP
reate individual user accounts for everyone who needs access to your database. Although you can, if you like, assign permissions to individual users, it is usually easier to define a group’s permissions and add users to the appropriate group. Users can be members of more than one group, so you won’t need
C
⁄ Click Tools. ¤ Click Security.
636
to create a special group if you want a user to have permissions from two groups. For instance, if a member of your sales force served as backup database administrator, you could make that user a member of a backup administrator group as well as the sales group. You should take care not to assign permissions to users that do not need them in their
‹ Click User and Group Accounts.
everyday functions. If special circumstances arise and you need to assign a user additional privileges, you might consider creating a different account for that user and, when the need is gone, change the password to the special account (or delete it entirely).
■ The User and Group Accounts window appears.
ˇ Click the user you want to add to a group.
› Click the User Name drop-down menu button.
Note: In this case, we clicked Curtis Frye.
6048-4 ch22.F
10/19/99
3:28 PM
Page 637
How do I change the object type I’m assigning permissions for? First click Tools ➮ Security ➮ User and Group Permissions. You can pick different object types by clicking the drop-down menu button next to Object Type and selecting the object type you want to assign permissions for. The permissions available to be assigned will change depending on the object type you’ve selected.
■ Information for the user you clicked appears in the window.
‡ Click Add. Note: In this case, we clicked Data Entry.
How do I specify the permissions I want this user or group to have? You can pick the permissions for this group by clicking the check boxes next to the specific permission, such as Read Data, Update Data, or Read Design.
■ The new group appears in the Member Of pane.
Á Click the name of the group you want to make this user a part of.
637
COLLABORATE USING ACCESS 2000
IV
6048-4 ch22.F
10/19/99
3:28 PM
Page 638
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
USE THE USER-LEVEL SECURITY WIZARD f you want to create a series of user accounts and user groups after you have created your database, you can do so with the User-Level Security Wizard. This wizard walks you through the process, explaining every step and asking you for just as much information as it needs to create your accounts and groups.
I
⁄ Click Tools. ¤ Click Security.
638
When you secure a database, Access creates a workgroup ID (WID) number for the database and associates both your name and your company’s name with the file. You have the choice of modifying your existing workgroup file, which you should do if you are updating the security in a database, or creating a new file. You should create a
‹ Click User-Level Security Wizard.
new file whenever you create a new database. Just as in the “Create a New User Group” task, you can define which database objects users will be able to read, update, modify, and delete.
■ The User-Level Security Wizard appears.
› Click Next.
6048-4 ch22.F
10/19/99
3:28 PM
Page 639
How do I display specific types of objects within my database? You can display a specific type of object by clicking the tab corresponding to that object type.
How do I remove security from every object listed in the central pane? You can remove restrictions from every object in the list by clicking Deselect All.
How do I single out which database objects I want to make secure? You can secure individual objects (like tables, macros, or queries) in your database by displaying objects of that type and ensuring the check box next to the object’s name is clicked.
■ The next User-Level Security Wizard screen appears. ˇ Type your name in this space.
Á Type your organization's name in this space. ‡ Click Next.
■ The next User-Level Security Wizard screen appears.
° Click Select All, if not already selected. · Click Next.
Note: If the All Objects tab isn't in front, click it now. CONTINUED
639
COLLABORATE USING ACCESS 2000
IV
6048-4 ch22.F
10/19/99
3:28 PM
Page 640
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
USE THE USER-LEVEL SECURITY WIZARD CONTINUED
ne of the most powerful and sensitive parts of your database is the Visual Basic code module area. Since the code you write can be complex and integral to the security and efficiency of your database, Access allows you to password protect your code. Access comes with a number of predefined user groups, such
O
640
as Backup Operators, Full Data Users, New Data Users, Project Designers, and Read-Only Users. Descriptions of each of these groups appear in the Wizard window when they are selected from the list. Users can be members of more than one group, so you won’t need to create a special group if you want a user to have
permissions from two groups. For instance, if a member of your sales force served as your backup database administrator, you could make that user a member of a backup administrator group as well as the sales group.
6048-4 ch22.F
10/19/99
3:28 PM
Page 641
How do I assign object-specific permissions to the users group? You can activate the objects by clicking the radio button next to “Yes, I would like to grant some permissions to the Users group.” Then, select those object-specific permissions.
IV
When should I give the users group some permissions? If every one of your database users will need to perform some basic task, like updating data, you can add that permission to the group here.
CONTINUED
641
COLLABORATE USING ACCESS 2000
When should I use the predefined groups in the User-Level Security Wizard and when should I create my own? One instance when you could create a custom group is if you want to add permissions for one or two members of a group without extending those privileges to every member of the group.
6048-4 ch22.F
10/19/99
3:28 PM
Page 642
22
CHAPTER 22: DATABASE ADMINISTRATION AND SECURITY
USE THE USER-LEVEL SECURITY WIZARD: ADD USERS TO GROUPS hen you reach the final steps of the User-Level Security Wizard, Access allows you to assign users to groups. Take care to assign users to only the groups they absolutely need to be part of. Adequate database security protects the integrity of the underlying data and prevents
W
642
users from accidentally modifying objects or attempting tasks they shouldn’t. The final step of the UserLevel Security Wizard is to create an unsecured backup copy of your database. As you learned in the task “Back Up a Database, presented earlier in this chapter, you should make backup copies
of your databases frequently. Backing up your database in unsecured form is also important; if you forget the password to the database, you can fall back to the last unsecured archive.
6048-4 ch22.F
10/19/99
3:28 PM
Page 643
How do I add users to a group, rather than assign a group to a user? You can add users to a group by clicking the radio button next to “Select a group and assign users to the group.”
How do I delete a user from the list? You can remove a user by clicking the user’s name and clicking the Delete User from List button.
643
COLLABORATE USING ACCESS 2000
IV
6048-4 ch23.F
10/19/99
3:30 PM
Page 644
23
CHAPTER 23:PUBLISH ONTHE WEB USING DATA ACCESS PAGES
PUBLISH ON THE WEB USING DATA ACCESS PAGES
D
ata access pages are a new feature in Access 2000. In previous versions of Access you could publish ypublishour data to the Web,
Create Data Access Pages Using the Wizard– Data access pages make it easy to publish data on an intranet or the Internet via the World Wide Web. The data access pages (sometimes referred to as pages) give your users a window into your database. Through the data access pages, Web or intranet users can view, modify, add, or delete data in your tables, run queries, and even work with your data in spreadsheets or pivot tables. As with most other database objects, Access has a wizard that walks you through the data access page creation process. You pick the object on which to base your page, pick the fields to display, determine how you want the data to appear on the page, and name the page. Access takes over the process at that point, automatically creating the page and positioning your fields on it. Data access pages aren’t stored as part of the database. Access creates a separate HTML file, stored outside the database, and links to that file from the main Database window.
but only as a static document. Data access pages make it possible for you and your users to interact with your data over a corporate intranet or the Internet. Create Data Access Pages in Design View– As it does with other types of objects in your database, Access allows you to create data access pages from the ground up in Design view. While in Design view, you can add fields, include many of the controls you encountered in Chapter 13, change your page’s appearance, and facilitate data entry. If you want to add a large number of fields to your data access page, use the wizard to add the fields, perhaps choose a template to give your page the look you want, and establish a sort order for the data displayed on the page. But you don’t have to accept the wizardgenerated page just as it comes out. You can customize and shape it similarly to how you would a form or report. Sales Company Contact
Product
Sales
644
6048-4 ch23.F
10/19/99
3:30 PM
Page 645
Edit Existing Data Access Pages–
Contacts
IV
Company Last name Tilden Manf. A. Winters McEvoy
Contacts Name Str address City
Group Fields on a Data Access Page– When you create your data access pages, you can go beyoeditingnd choosing which fields appear on the page. You can also specify how Access will group your data. As you learned in Chapter 12, “Create Reports,” you can assign grouping levels to change how your data is presented. For instance, if your data access page presented quarterly sales data for a number of years, you could group that data by your sales representatives’ last names, the quarter the sales were made in, or the year the sales were made. You can also assign secondary grouping levels to further specify how you want your data to be displayed. To continue the sales example, you could set the employees’ last name as the primary grouping level and the year as the secondary grouping level. Under that grouping strategy, your page would show an employee’s name, followed by the first year in the table, and the representative’s sales for each quarter in that year. The first year would be followed by the quarterly results from the second year, until the final quarter of the final
Add and Remove Group Captions– Whether you create your data access page with a wizard or in Design view, when you add a field to the page you add a label with the field’s name. It’s often easy for you, as the page’s creator, to remember which fields are used for which data and what importance a group has within the database’s overall design. You can use group captions to make that message clear to your users. Group captions give you room to describe the data in a group, note how a particular grouping changes the emphasis (and perhaps the message) of the data, and summarize any conclusions the data supports. If the grouping strategy you choose significantly impacts how a user will interpret your data, you should consider creating a page with every grouping strategy you want to illustrate. You could note the presence of the other pages in a group caption and comment on how each strategy affects how your data is perceived.
97
98
99
00
Comp A B C CONTINUED
645
COLLABORATE USING ACCESS 2000
Once you’ve created a Data Access page, you can open it in Design view and modify its look, change the fields presented, and add controls. You can also remove controls or change them — for example, you could change a text box to a list box or combo box if the values to be entered for the field the box represented would always be chosen from a constant set of values.
year in the table is reached. Access would then repeat the process with the sales of the next representative.
6048-4 ch23.F
10/19/99
3:30 PM
Page 646
23
CHAPTER 23:PUBLISH ONTHE WEB USING DATA ACCESS PAGES
PUBLISH ON THE WEB USING DATA ACCESS PAGES CONTINUED Calculate Values on a Data Access Page–
When you create a data access page, it’s often based on a table or query in your database. If your table or query doesn’t contain a value you’d like to display on your data access page, and it would be impractical to add the field to your table or query, you can always create a new field on the data access page to calculate the value you need. Just like when you calculate values in a query, which you learned to do in Chapter 10, you can use the built-in summary functions or build your own custom calculations.
Contacts Company Last name
Listed by company, then by the contact’s last name.
Add a Pivot Table to a Data Access Page– You can make your data access pages even more powerful and flexible by presenting your data in pivot tables. Pivot tables, discussed in Chapter 15, allow your users to change how the data in a table is displayed. In a way, pivot tables are an extension of the grouping capability that comes with data access pages. Like grouping, pivot tables show your data according to the order of fields you establish in the original table. Unlike grouping levels, however, your users can change the grouping hierarchy on the fly. Sales Kiwi
$500
Lime
$420
Papaya
$80
Total
1000
646
6048-4 ch23.F
10/19/99
3:30 PM
Page 647
Add a Worksheet Control to a Data Access Page– Comp
Year
1997
Q
0
1
2
3
IV
647
COLLABORATE USING ACCESS 2000
Access and Excel are in many ways similar. Both programs maintain data inExpression worksheets (actually a datasheet in Access, but a datasheet is a form of worksheet) and allow you to sort, filter, and perform calculations on your data. That last point, calculations, is the best reason to add a worksheet control to a data access page. Although it’s possible to create most any calculation you like in Access with the Expression Builder, Excel is much better suited to working with financial and numerical data. A good rule of thumb is that if you’d like to include the results of a crosstab query (described in Chapter 10) in a data access page, you should consider using a worksheet control instead.
Sales
6048-4 ch23.F
10/19/99
3:30 PM
Page 648
23
CHAPTER 23:PUBLISH ONTHE WEB USING DATA ACCESS PAGES
CREATE A DATA ACCESS PAGE USING THE WIZARD ata access pages extend your ability to make your data available over local area networks, intranets, and the Internet. Just as when they have a copy of a database on their computer, users can add, update, and search your Access databases through data access pages.
D
⁄ Click Pages.
648
When you create a data access page, you are actually creating a Web page that stands apart from the Access database it’s linked to. Access places a shortcut to the page in the Pages area of the main Database window; the page itself exists as a separate document elsewhere on your computer.
¤ Double-click “Create data access page by using wizard.”
You can create a data access page from scratch, but Access does include a wizard that can take you through the process step by step, ensuring you don’t miss any chances to add useful features to your page.
■ The Page Wizard appears. ‹ Click the Tables/Queries drop-down menu button.
› Click the table or query you want to base your data access page on. Note: In this case, we clicked Table: Products.
6048-4 ch23.F
10/19/99
3:30 PM
Page 649
How do I add fields from more than one table or query to my data access page? To add fields from more than one table or query, you’ll need to combine the records into a single object by writing a new query.
How do I remove all of the fields I’ve added to the Selected Fields list? You can clear the Selected Fields list by clicking the Clear All Fields button.
How do I remove a field from the Selected Fields list? You can remove a field from the Selected Fields list by clicking the field name and then clicking the left arrow button.
■ The fields in the table or query you selected appear in this area.
ˇ Click the Select All Fields button.
■ All of the fields in the Products table appear in the Selected Fields pane.
Á Click Next.
CONTINUED
649
COLLABORATE USING ACCESS 2000
IV
6048-4 ch23.F
10/19/99
3:30 PM
Page 650
23
CHAPTER 23:PUBLISH ONTHE WEB USING DATA ACCESS PAGES
CREATE A DATA ACCESS PAGE USING THE WIZARD CONTINUED ata access pages are a powerful tool for distributing data across networks, but they’re not a magic bullet. You still need to have a plan when you present data to your users. Grouping fields in pages allows you to establish a scheme and have Access follow it automatically.
D
■ The next Page Wizard screen appears. Note: The first field, Supplier ID, appears as the grouping criteria for the page.
650
You can establish as many grouping levels as you like, although if you use more than one level of grouping, your data access page will only be available as a read-only document. The Data Access Page Wizard also lets you establish a sort order for your pages. You can sort on as many as four separate
‡ Click the left arrow button.
fields, with each sort in either ascending or descending order. The order you enter the fields in the screen determines their precedence in the sort, although you can also apply filters and use grouping levels to produce the record order you want.
■ The SupplierID field moves to the same level as the other fields.
° Click Next.
6048-4 ch23.F
10/19/99
3:30 PM
Page 651
How do I change the priority of the grouping levels I’ve chosen? You can change the priority of your grouping levels by clicking the field name in the Preview pane and clicking either the left or right arrow button. The Preview pane will immediately reflect your changes.
How do I add grouping levels? If you want to use a field to group the data on your page, click the name of the field and click the right arrow button. The field name will appear in the top section of the Preview pane.
■ The next Page Wizard screen appears.
‚ Click the name of the field you want to sort by.
■ The Checkered Flag screen appears.
· Click the drop-down menu button in the first field text box.
Note: In this case, we selected ProductName.
± Type a title for your page in this space.
— Click Next.
Click the radio button next to “Open the page.”
Note: Your data access page appears. To learn how to work with the page, see the tasks in the rest of this chapter.
Á ª Click Finish.
651
COLLABORATE USING ACCESS 2000
IV
6048-4 ch23.F
10/19/99
3:30 PM
Page 652
23
2
CHAPTER 23:PUBLISH ONTHE WEB USING DATA ACCESS PAGES
CREATE A DATA ACCESS PAGE IN DESIGN VIEW
he Data Access Page Wizard is a versatile tool for creating data access pages, but you might want to create a page from scratch. When you’re viewing your pages in the main Access window, you can double-click the “Create access page in Design view” icon to
T
⁄ Click Pages.
652
generate an editable data access page. Creating a data access page in Design view is very similar to creating a form or report in Design view. For instance, you can include a wide range of controls in your page, such as list boxes, combo boxes, radio buttons,
¤ Double-click “Create data access page in Design view.”
check boxes, and control buttons. Your users can use those controls to enter data more efficiently, eliminate spelling errors, and comment on their work.
■ The data access page appears.
Note: For instructions on adding fields to a data access page, see task “Add Fields to a Data Access Page,” presented later in this chapter.
6048-4 ch23.F
10/19/99
3:30 PM
Page 653
23
CHAPTER 23:PUBLISH ONTHE WEB USING DATA ACCESS PAGES
EDIT AN EXISTING DATA ACCESS PAGE
egardless of whether you build a data access page with the wizard or from scratch in Design view, youj683 may need to edit your page’s design after it’s been created. Access makes it easy for you to do so.
R
⁄ Click Pages.
Unlike opening a page in Design view, which can be done in exactly the same way as opening a form or report in Design view, editing an existing Web page allows you to work with pages beyond those stored in the database you currently
¤ Double-click “Edit Web page that already exists.”
have open. The screen that appears contains navigation controls that allow you to reach onto any drive in your computer, or to other machines on a network, to open a page for editing.
■ The Locate Web Page dialog box appears.
Note: In this case, we clicked Products.
‹ Click the name of the data access page you want to edit.
› Click Open. Note: The data access page appears in Page view.
653
COLLABORATE USING ACCESS 2000
IV
6048-4 ch23.F
10/19/99
3:30 PM
Page 654
23
CHAPTER 23:PUBLISH ONTHE WEB USING DATA ACCESS PAGES
ADD FIELDS TO A DATA ACCESS PAGE hen you’re building or editing a data access page, it’s very likely that you will need to change the first design at some point. Changes in database structure, data collection requirements, user needs, and design objectives can all influence your pages’ design.
W
⁄ Create a new page, as illustrated in task “Create a data access page in Design view.” Note: If the Field List dialog box doesn't appear, click the Field List toolbar button.
654
When you open a data access page in Design view, you can click the Field List toolbar button to get a list of the fields in every table and query in your database. Then, unlike in the Data Access Page Wizard, you can add fields (or entire objects) from any table or query.
¤ Click the plus sign next to the type of object you want to view. Note: In this case, we clicked Tables.
There may be times when you should make creating a data access page a two-step process. You can use the wizard to create the basic page you want (without creating a custom query) and then add fields as you want.
■ The list of tables in your database appears.
Note: In this case, we clicked Customers.
‹ Click the table you want to add to your data access page.
› Click Add to Page.
6048-4 ch23.F
10/19/99
3:30 PM
Page 655
How do I add specific fields from a table or query? To add a specific field, click the plus sign next to the name of the table or query containing the field. The list of fields in that object will appear. Click the name of the field you want to add and then click the Add to Page button.
■ The Layout Wizard appears.
ˇ Click the radio button next to Individual Controls.
Can I place selected fields directly onto the page? If you’d rather place an item directly onto the page, you can click the name of the field and, holding down the left mouse button, drag it to the desired spot.
■ The fields appear on the page.
Á Click OK.
655
COLLABORATE USING ACCESS 2000
IV
6048-4 ch23.F
10/19/99
3:30 PM
Page 656
23
CHAPTER 23:PUBLISH ONTHE WEB USING DATA ACCESS PAGES
GROUP FIELDS ON A DATA ACCESS PAGE ou have a lot of choices when you create a data access page, from which fields you want to display to how the page will look visually. Another important piece of the puzzle is to determine how the records on your pages will be ordered. Field groupings determine that order. When you group fields, you set the criteria Access will use to
Y
⁄ Click the field you want to use as a grouping criteria. Note: Make sure you click the field, not the field's label. Note: For this example, we clicked CategoryID.
656
determine how much info is displayed on a page, what order the pages will appear in, and which elements of your database will be emphasized over the others. For example, if you ran a sporting goods store and had broken your inventory into team sports, individual sports, training equipment, and clothing, you should probably divide your data
¤ Click the Promote button.
access pages along those lines as well. Depending on the size of your inventory and the number of items in various categories, you could group your fields at a second level by including the specific sport in the category (for example, Team_Sport.Baseball).
■ The promoted field appears in a separate section at the top of the page. ‹ Click the next field you want to promote.
Note: In this case, we clicked SupplierID.
› Click the Promote button.
6048-4 ch23.F
10/19/99
3:30 PM
Page 657
How do I specify the number of records in a group to display on a page? Limit the number of records from a group that will appear on a page by clicking the Sorting and Grouping toolbar button and setting the DataPageSize property to the number of records you want to appear on a page.
■ The field appears above the unpromoted fields, but below the field you promoted before it.
ˇ Click the top-level field (CategoryID).
How do I have Access display every record available at a particular level? To display every record available, set the DataPageSize property to All.
IV
I’ve limited the number of records displayed on a page. How do I let my users move to the next set of records? You can let your users move among your records by adding a Record navigation bar from the Toolbox. Simply click the Record Navigation icon and click the spot on the page you’d like the navigation bar to appear.
■ The fields appear on the same level.
Á Click the Demote button.
657
COLLABORATE USING ACCESS 2000
How do I allow a user to expand or collapse grouping levels? You can allow a user to expand or collapse a grouping level by placing an Expand control in that group’s body. Add the Expand control by opening the toolbox, clicking the Expand control’s icon, and clicking the spot on the form you want the control to appear.
6048-4 ch23.F
10/19/99
3:30 PM
Page 658
23
CHAPTER 23:PUBLISH ONTHE WEB USING DATA ACCESS PAGES
ADD AND REMOVE GROUP CAPTIONS
roperly chosen field names alert database users and data access page viewers to which data is being presented. Where field names can sometimes fall short is when you want or need to explain how a specific grouping affects the data on display. Caption sections also give you room to introduce your data, the
P
⁄ Create a data access page. Note: For this example, we created our page based on the Products table and promoted the CategoryID field.
658
fields, and the picture the information paints. You could also provide some background as to how you collected the data, what you took into account when you summarized it, and any conclusions you’ve drawn. You can, of course, remove a caption section whenever you want. If you find a caption isn’t needed for a data set, or if you’d
¤ Click the Sorting and Grouping button.
just prefer to let the data stand on its own, you can remove the caption with a few clicks of the mouse.
■ The Sorting and Grouping dialog box appears.
› Click Caption Section.
‹ Click the group record
ˇ Click the Caption Section drop-down menu button.
source you want to add a caption to.
Á Click Yes.
Note: In this case, we clicked Products-CategoryID.
6048-4 ch23.F
10/19/99
3:30 PM
Page 659
How do I change the font, size, and appearance of my caption text? You can modify the appearance of your caption text by opening the caption’s Propertichanging text appearancees dialog box, clicking the Format tab, and modifying the FontFamily, FontSize, FontStyle, FontVariant, and other related values.
■ “Yes” appears in the Caption Section property box.
‡ Close the Sorting and Grouping box by clicking the Close box.
How do I add text for my caption? Just click the caption section and type.
■ A caption section appears above the field you specified.
Note: We added a caption to the caption section using the skills presented in the Chapter 13 task "Add a Label."
659
COLLABORATE USING ACCESS 2000
IV
6048-4 ch23.F
10/19/99
3:30 PM
Page 660
23
CHAPTER 23:PUBLISH ONTHE WEB USING DATA ACCESS PAGES
CALCULATE A VALUE FOR ONE RECORD
he most common use for data access pages is to present the contents of a database. Tak1e the sample Northwind database as an example. You could easily create data access pages to make the contents of the Products table available to any users on your
T
⁄ Add the fields containing the data you need to calculate your value. Note: In this case, we added OrderID, ProductID, UnitPrice, and Quantity.
660
corporate intranet or, if you wanted, to potential customers accessing your site over the Internet. Access lets you go beyond simple display, however. You can create controls that derive their values from the other data on the page. Calculate sums, averages,
¤ Click the Bound HTML control. ‹ Click where you want the upper-left corner of the control to be located.
minimums, maximums, and standard deviations using the built-in functions, or build your own custom calculations to use in the target control.
■ The Bound HTML control appears.
› Click the Properties button.
6048-4 ch23.F
10/19/99
3:30 PM
Page 661
How do I calculate values other than sums? If your page has two or more group levels, you can create a bound HTML control, open the Properties dialog box, and select the type of aggregate or summary calculation you want to use from the TotalType drop-down menu.
Access reported an error when I opened a page with a calculated field on it.What might have gone wrong? If you deleted a field called by the calculation in the Bound HTML control, Access will report an error. You should restore the field to the page or modify your calculation.
■ The Properties box appears.
Note: For this example, we typed SubTotal: [UnitPrice]*[Quantity]
■ The Properties box disappears.
Note: If the Data tab isn’t selected, click it now.
Note: If the field’s text area is too small, you can make it larger using the skills from the Chapter 13 task "Resize a Control."
° Click View.
ˇ Click ControlSource. Á Type the expression to calculate your value.
· Click Page view. Note: The field you created appears, with a prediscount subtotal of the cost of the items on the screen.
‡ Click the Close box. 661
COLLABORATE USING ACCESS 2000
IV
6048-4 ch23.F
10/19/99
3:30 PM
Page 662
23
CHAPTER 23:PUBLISH ONTHE WEB USING DATA ACCESS PAGES
ADD A PIVOT TABLE TO A DATA ACCESS PAGE ivot tables present the data from tables and queries in an easily understood and flexible package. You can rearrange your data to emphasize any aspect of the dynaset you like. When you move a field name in a pivot table, it rearranges the data based on where you put it on an axis. On the horizontal access, the order of the fields denotes how the data columns
P
⁄ Follow steps 1–4 in task “Add Fields to a Data Access Page” to identify the table or query containing the data for your pivot table to your data access page.
662
are arranged. For instance, if you use the Category Name and Product Name fields to arrange your data, the columns will start with the first product in the first category (in alphabetical order) and continue until the last product name in the last column is reached. Adding pivot tables to data access pages combines two of the most powerful tools in Access;
Note: In this case, we will use the Supplier Analysis query, which we used as an example in Chapter 15.
¤ Click Add to Page.
not only can your users get to your data over an intranet or the Internet, they can rearrange and filter the data to get the precise picture they want.
■ The Layout Wizard appears. ‹ Click Pivot Table List.
› Click OK.
6048-4 ch23.F
10/19/99
3:31 PM
Page 663
How do I move a field from the Filter area to the Detail area? To move a field from the Filter area to the Detail area (or body) of the pivot table, click the name of the field and click the Move to Detail button.
■ A pivot table based on the table or query you chose appears on your data access page.
ˇ Click the Close box to close the Field List dialog box.
How do I move a field to the Row area? You can move a field to the Row area by clicking the name of the field and clicking the Move to Row Area button.
IV
How do I move a field to the Column area? To move a field to the Column area, click the name of the field and click the Move to Column Area button.
■ The Field List dialog box disappears.
663
COLLABORATE USING ACCESS 2000
How do I move a field to the filter area? You can move a field to the Filter area, which corresponds to the Page area in the Pivot Table Wizard, by clicking the name of the field and clicking the Move to Filter Area button.
6048-4 ch23.F
10/19/99
3:31 PM
Page 664
23
CHAPTER 23:PUBLISH ONTHE WEB USING DATA ACCESS PAGES
ADD A WORKSHEET CONTROL TO A DATA ACCESS PAGE
s we mentioned in Chapter 15, pivot tables aren’t native Access objects — they are Excel objects you can add to your database if you also have Excel installed on your computer. You can extend the interaction between Access and Excel even farther, using data access pages
A
⁄ Open a data access page in Design view, as you learned to do in task “Create a Data Access Page in Design View.”
664
as a base. Office 2000 allows you to insert a worksheet control directly into a data access pages, allowing you and your users to take advantage of Excel’s features. For instance, you can create AutoSum cells, which take the values from fields you select and input their sum in the cell you choose. Access updates the
Note: You could also edit an existing page.
¤ Click the Toolbox button.
target cell in the data access page whenever any of the summed values changes. You can also use more complicated formulas to sum up data and, if you want, export worksheet control data directly to an Excel document.
■ The Toolbox appears. ‹ Click the Worksheet icon. › Click on the spot in the data access page that will serve as one corner of the worksheet.
ˇ Holding down the left mouse button, drag the pointer until the box is the desired size of your worksheet. Á Release the left mouse button.
6048-4 ch23.F
10/19/99
3:31 PM
Page 665
How do I get help in working with a worksheet control? You can get help on worksheet controls by opening the Office Assistant and asking how to “add a worksheet to a data access page.”
IV
How do I enter data into a worksheet control? You can enter data into a worksheet control directly or import it from an HTML table.
■ The worksheet control appears. Note: You can enter data into the spreadsheet or copy it from an existing Access datasheet as you learned to do in Chapter 7.
‡ Click the Save button.
■ The Save As Data Access Page dialog box appears.
° Type a name for your page in this space. · Click Save.
665
COLLABORATE USING ACCESS 2000
How do I export my worksheet control data to an Excel document? You can export your data to Excel by clicking the Export button. An Excel worksheet will open in read-only mode; from there, you can save the worksheet as an Excel document.
6048-4 ch23.F
10/19/99
3:31 PM
Page 666
23
CHAPTER 23:PUBLISH ONTHE WEB USING DATA ACCESS PAGES
ADD A BACKGROUND PICTURE TO A DATA ACCESS PAGE
he first consideration in creating a data access page should be the content, though you should also consider using background images if they do not make your page’s contents any harder to read. You can use any picture file you like as a background for your data access page. The standard
T
⁄ Create a data access page in Design view, as you learned to do in task “Create a Data Access Page in Design View.” Note: You could also edit an existing page.
666
Access distribution contains a few background images that are used in its sample forms, reports, and data access pages, although you can also buy background patterns (sometimes referred to as textures) commercially. You can use images stored in any of the standard picture formats, such as JPEG, GIF, PCX,
¤ Click Format. ‹ Click Background. › Click Picture.
or BMP, though if you want to export your design to a standard HTML page, you will need to store the image as either a JPEG or a GIF. If your image is smaller than the page, it will repeat to fill up the entire background.
■ The Insert Picture dialog box appears. ˇ Click the picture you want to add.
Á Click OK.
6048-4 ch23.F
10/19/99
3:31 PM
Page 667
Can I play a sound file while a user is accessing my page? To play a sound file while your page is displayed, open the Format menu, click Background, and click Sound. A dialog box will appear — simply locate the sound file on your machine and click OK.
IV
How do I make my page’s background a solid color? You can make your page’s background a solid color by opening the Format menu, clicking Background, and clicking Color. You can pick a color from the palette that appears.
■ The picture appears and repeats, if necessary, in the background.
‡ Click the Close box to close the page.
■ The data access page disappears.
Note: If you are asked if you want to save your changes, do so.
667
COLLABORATE USING ACCESS 2000
Does Access have a set of themes I can use for my data access pages? You can preview and select a pregenerated theme by opening the Format menu, clicking Theme, and making your selection from the list that appears. When you’ve found the theme you want, click OK.
6048-4
pp.F
10/19/99
4:04 PM
Page 668
APPENDIX USING THE CD-ROM he CD-ROM included in this book is packed with useful software, including both applications you can use
T
with Access and some great general-purpose programs. The disc also includes an electronic version of the book that you can
view and search using Adobe Acrobat Reader.
SYSTEM REQUIREMENTS
useful software applications. To use most of the programs, you must accept the license agreement provided with the program. Make sure you look at any “Read Me” files provided with each program; these files often include important late-breaking information, such as compatibility updates and known problems. And remember that when you install a program, you should close all open programs on your computer. The next sections describe each item on the CD and how to install it.
PDF Version of the Book
You can use this disc on any computer with a CD-ROM drive and the Windows operating system. To get the most out of the disc, you should have a 486 or Pentium computer with at least 32MB of RAM. You should have at least 200MB of free hard disk space, and your system should be able to display at least 256 colors. Use the My Computer or Windows Explorer window to display the contents of the CD-ROM. Note: If you have trouble viewing the directory structure of the CD-ROM, or if the directory names are truncated (example: \directo~), your CD-ROM drive is currently using 16-bit drivers instead of the necessary 32-bit drivers. Please contact your CD-ROM drive vendor for information on upgrading the CD-ROM drivers. INCLUDED SOFTWARE The Programs folder on the CD-ROM contains a number of 668
PeerDirect
This program translates relational databases to and from a variety of different formats, including Access, Paradox, Microsoft SQL, Oracle, Informix, and others. A trial version of the program is included on the CD; if you like the software and wish to continue using it, you must purchase the licensed version. To install PeerDirect, open its folder in the Programs folder, then double-click the pd.exe file. Follow the instructions on your screen.
The CD-ROM contains an electronic version of this book that you can view and search using the Adobe Acrobat Reader program. You will find the PDF book files named by chapter in the folder named PDF Book. You cannot print the pages or copy text from the Acrobat files. A full, free version of Adobe Acrobat Reader 3.01 is also included on the disc. (For instructions on installing Acrobat Reader, see the Acrobat Reader section later in this appendix.) Once Acrobat Reader is installed, just open a chapter file to read it. You can go through the pages using the Forward and Back buttons at the top of the Reader window. To search for a specific word or phrase in the chapter, click the Find button (with the picture of binoculars). If your computer seems slow when using the electronic book, you might want to copy the book files to your hard drive. Having a local copy of the documents helps speed things up.
6048-4
pp.F
10/19/99
4:04 PM
Page 669
EarthLink Network Internet SignUp Offer
If you are not yet connected to the Internet, you can use the CD-ROM to set up an account and start using the EarthLink Network Internet service. This special package contains both the Internet Explorer 4.0 and Netscape Navigator 4.5 browsers. Once signed up to EarthLink, you can choose to install and use Microsoft Internet Explorer 5, also included on this CD-ROM. To install one of the included browsers and open an Internet account, first open the EarthLink folder on the CD-ROM. Then follow the appropriate steps below: To install Microsoft Internet Explorer 4.0 and set up an Internet account, open the EarthLink MSIE4 folder. Doubleclick Setup.exe and then follow the instructions on your screen. To install Netscape Navigator 4.5 and set up an Internet account, open the EarthLink Netscape folder. Double-click Setup.exe and then follow the instructions on your screen.
Paint Shop Pro
Paint Shop Pro is a graphics program you can use to edit and create pictures. This disc contains version 5.01 of Paint Shop Pro. You may use the program free of charge for 30 days. If you wish to continue using the program, you must then purchase the licensed version. To install the program, first open the Paint Shop Pro folder, located in the Programs folder. Then, double-click Psp501ev.exe and follow the instructions on your screen. WinZip
WinZip compresses files to make it easier and faster to transfer information from one computer to another. This disc contains version 7.0 of WinZip. You may use the program free of charge for 21 days. To continue using the program, you must pay a registration fee. To install WinZip, first open the WinZip folder, located inside the Programs folder. Then, doubleclick winzip70.exe and follow the instructions on your screen.
Adobe Acrobat Reader
CleanSweep
Adobe Acrobat Reader enables you to view an electronic version of the book. To install Acrobat Reader, open the utilities folder on the CD-ROM, and then open the Acrobat Reader folder. Double-click the Acrobat Reader.exe file and then follow the instructions on your screen.
CleanSweep finds files that can be removed to free up space on your hard drive. This disc contains version 4.02 of CleanSweep. You may use the program free of charge for 15 days. If you wish to continue using the program, you must then purchase the licensed version.
To install CleanSweep, first open the CleanSweep folder, located inside the Programs folder. Then, double-click cs4trial.exe and follow the instructions on your screen. Norton Utilities
Norton Utilities includes several components to help you with computer maintenance tasks. This disc contains a trial version of Norton Utilities. If you wish to continue using the program, you must then purchase the licensed version. To install the program, first open the Norton Utilities folder, inside the Programs folder. Then double-click nu3_trybuy.exe and follow the instructions on your screen. TalkWorks Pro
You can use TalkWorks Pro to bring professional voice and fax messaging to your home or office. This disc contains a trial version of TalkWorks Pro. To continue using the program, you must purchase the licensed version. To install the program, open the TalkWorks Pro folder, located within the Programs folder, and double-click Twtrybuy.exe. Then, follow the instructions on your screen. RealPlayer
RealPlayer speeds up the delivery of audio and video files from the Internet. This disc 669
6048-4
pp.F
10/19/99
4:04 PM
Page 670
APPENDIX contains a full version of RealPlayer G2. To install the program, open the RealPlayer folder, located in the Programs folder, and doubleclick rp32_50.exe. Then, follow the instructions on your screen.
670
Microsoft FrontPage
Microsoft FrontPage 2000 is the latest version of a popular Web site creation and management tool. It allows you to easily design and maintain your own Web site. A trial version of the software is included on the CD. If you like the
program and wish to continue using it, you must then purchase the licensed version. To install the program, open the FrontPage folder, located in the Programs folder, and doubleclick setup.exe. Then, follow the instructions on your screen.
6048-4
pp.F
10/19/99
4:04 PM
Page 671
6048-4 EUL .F
10/19/99
4:03 PM
Page 684
IDG BOOKS WORLDWIDE, INC. END-USER LICENSE AGREEMENT READ THIS. You should carefully read these terms and conditions before opening the software packet(s) included with this book (“Book”). This is a license agreement (“Agreement”) between you and IDG Books Worldwide, Inc. (“IDGB”). By opening the accompanying software packet(s), you acknowledge that you have read and accept the following terms and conditions. If you do not agree and do not want to be bound by such terms and conditions, promptly return the Book and the unopened software packet(s) to the place you obtained them for a full refund. 1. License Grant. IDGB grants to you (either an individual or entity) a nonexclusive license to use one copy of the enclosed software program(s) (collectively, the “Software”) solely for your own personal or business purposes on a single computer (whether a standard computer or a workstation component of a multiuser network). The Software is in use on a computer when it is loaded into temporary memory (RAM) or installed into permanent memory (hard disk, CD-ROM, or other storage device). IDGB reserves all rights not expressly granted herein. 2. Ownership. IDGB is the owner of all right, title, and interest, including copyright, in and to the compilation of the Software recorded on the disk(s) or CD-ROM (“Software Media”). Copyright to the individual programs recorded on the Software Media is owned by the author or other authorized copyright owner of each program. Ownership of the Software and all proprietary rights relating thereto remain with IDGB and its licensers. 3.
Restrictions On Use and Transfer.
(a) You may only (i) make one copy of the Software for backup or archival purposes, or (ii) transfer the
684
Software to a single hard disk, provided that you keep the original for backup or archival purposes. You may not (i) rent or lease the Software, (ii) copy or reproduce the Software through a LAN or other network system or through any computer subscriber system or bulletin-board system, or (iii) modify, adapt, or create derivative works based on the Software. (b) You may not reverse engineer, decompile, or disassemble the Software. You may transfer the Software and user documentation on a permanent basis, provided that the transferee agrees to accept the terms and conditions of this Agreement and you retain no copies. If the Software is an update or has been updated, any transfer must include the most recent update and all prior versions. 4. Restrictions on Use of Individual Programs. You must follow the individual requirements and restrictions detailed for each individual program in the Appendix, “Using the CD-ROM,” of this Book. These limitations are also contained in the individual license agreements recorded on the Software Media. These limitations may include a requirement that after using the program for a specified period of time, the user must pay a registration fee or discontinue use. By opening the Software packet(s), you will be agreeing to abide by the licenses and restrictions for these individual programs that are detailed in the Appendix, “Using the CD-ROM,” and on the Software Media. None of the material on this Software Media or listed in this Book may ever be redistributed, in original or modified form, for commercial purposes. 5.
Limited Warranty.
(a) IDGB warrants that the Software and Software Media are free from defects in materials and workmanship under normal use for a period of
6048-4 EUL .F
10/19/99
4:03 PM
Page 685
sixty (60) days from the date of purchase of this Book. If IDGB receives notification within the warranty period of defects in materials or workmanship, IDGB will replace the defective Software Media. (b) IDGB AND THE AUTHOR OF THE BOOK DISCLAIM ALL OTHER WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE SOFTWARE, THE PROGRAMS, THE SOURCE CODE CONTAINED THEREIN, AND/OR THE TECHNIQUES DESCRIBED IN THIS BOOK. IDGB DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED IN THE SOFTWARE WILL MEET YOUR REQUIREMENTS OR THAT THE OPERATION OF THE SOFTWARE WILL BE ERROR FREE. (c) This limited warranty gives you specific legal rights, and you may have other rights that vary from jurisdiction to jurisdiction. 6.
Remedies.
(a) IDGB’s entire liability and your exclusive remedy for defects in materials and workmanship shall be limited to replacement of the Software Media, which may be returned to IDGB with a copy of your receipt at the following address: Software Media Fulfillment Department, Attn.: Master Access 2000 Visually, IDG Books Worldwide, Inc., 7260 Shadeland Station, Ste. 100, Indianapolis, IN 46256, or call 1-800-762-2974. Please allow three to four weeks for delivery. This Limited Warranty is void if failure of the Software Media has resulted from accident, abuse, or misapplication. Any replacement Software Media will be warranted for the remainder of the original warranty period or thirty (30) days, whichever is longer. (b) In no event shall IDGB or the author be liable for any damages whatsoever (including without limitation damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising from the use of or inability to use the Book or the Software, even if
IDGB has been advised of the possibility of such damages. (c) Because some jurisdictions do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation or exclusion may not apply to you. 7. U.S. Government Restricted Rights. Use, duplication, or disclosure of the Software by the U.S. Government is subject to restrictions stated in paragraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause of DFARS 252.227-7013, and in subparagraphs (a) through (d) of the Commercial Computer—Restricted Rights clause at FAR 52.227-19, and in similar clauses in the NASA FAR supplement, when applicable. 8. General. This Agreement constitutes the entire understanding of the parties and revokes and supersedes all prior agreements, oral or written, between them and may not be modified or amended except in a writing signed by both parties hereto that specifically refers to this Agreement. This Agreement shall take precedence over any other documents that may be in conflict herewith. If any one or more provisions contained in this Agreement are held by any court or tribunal to be invalid, illegal, or otherwise unenforceable, each and every other provision shall remain in full force and effect.
685