Ch06 Access

2,114 views

Published on

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,114
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
163
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Ch06 Access

  1. 1. Automating Database Processing<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />1<br />Chapter 6<br />“An organization’s ability to learn, and translate that learninginto action rapidly, is the ultimate competitive advantage.”—Jack Welch<br />
  2. 2. Chapter Introduction<br />Design and implement user-friendly menu<br />Called switchboard<br />Macros<br />Automate repetitive tasks<br />Conditions<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />2<br />
  3. 3. Tools Covered in This Chapter<br />AutoExec macro<br />AutoKeys macro<br />Macro window<br />Startup dialog box<br />Switchboard Manager<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />3<br />
  4. 4. Level 1 Objectives: Automating Tasks with Switchboards and Macros<br />Create a well-designed switchboard to provide a user interface for a database<br />Automate tasks by creating basic macros<br />Specify what happens when a database opens<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />4<br />
  5. 5. Understanding Switchboards<br />Switchboard <br />Special kind of form <br />Appears when database opened<br />Lists options for working with database objects<br />Select up to eight objects to list on switchboard<br />Determine what action Access should take when users select option<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />5<br />
  6. 6. Understanding Switchboards (continued)<br />Typical switchboard buttons<br />Open forms reports and other objects <br />Open other switchboards that list additional database objects <br />Close switchboard<br />Open the Navigation Pane<br />Close Access<br />Main switchboard<br />Large number of database objects<br />Launches other switchboards<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />6<br />
  7. 7. Typical Switchboard Design<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />7<br />
  8. 8. Designing a Switchboard<br />Switchboard Manager<br />Tool to design and customize switchboard<br />Create main switchboard<br />Add buttons<br />Specify button properties<br />Access creates switchboard form<br />Only one switchboard per database<br />Can contain many pages<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />8<br />
  9. 9. Creating a Switchboard <br />Open Switchboard Manager<br />Switchboard Manager dialog box<br />Use five buttons on Switchboard Manager dialog box to perform tasks<br />Create secondary switchboards first<br />Verify new form creation<br />Switchboard item table <br />Keeps track of switchboard items commands and arguments <br />Should be altered only through Switchboard Manager<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />9<br />
  10. 10. Switchboard Manager Buttons<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />10<br />
  11. 11. Edit Switchboard Item Dialog Box<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />11<br />
  12. 12. Switchboard Commands<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />12<br />
  13. 13. Formatting a Switchboard<br />By default Access switchboards share same layout and design <br />Including background colors and placement of title<br />Switchboard Manager doesn’t provide options for modifying switchboard design<br />Format switchboard in form design view<br />Do not change command buttons or properties<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />13<br />
  14. 14. Understanding Basic Macros<br />Macro <br />Action or series of actions <br />Save time and ensure accuracy<br />Usually assigned to key, key combination, or button<br />Composed of series of actions organized in sequence in which they should be performed<br />Create macro<br />Using Macro window<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />14<br />
  15. 15. Common Macro Actions<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />15<br />
  16. 16. Creating a Macro<br />Create Access macro in Macro window<br />Select the Create tab, and then click the Macro button in the Other group<br />Action column <br />List actions macro performs<br />Click list arrow in action column<br />Access provides over 50 different actions<br />Comment column<br />Document action by describing what task it performs<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />16<br />
  17. 17. Creating a Macro (continued)<br />Action arguments pane<br />Provide additional information for performing macro action<br />Arguments needed vary depending on selected action chosen<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />17<br />
  18. 18. Running a Macro<br />In Macro window <br />Click the Run button in the Design tab<br />Click Run Macro on the Database Tools Ribbon, click the list arrow and select the macro, and then click OK<br />In the Navigation Pane, click Macros, right-click the macro name, and then click Run<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />18<br />
  19. 19. Macro Design Toolbar<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />19<br />
  20. 20. Editing a Macro<br />Use Macro window<br />Rearrange order of actions <br />Drag action line to new position<br />Insert new action between two existing actions <br />Right-click row <br />Click insert rows<br />Delete action<br />Right-click row <br />Click delete rows<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />20<br />
  21. 21. Setting Startup Options<br />Startup options<br />Access performs when database opens<br />Use Startup dialog box<br />Bypass Startup Options<br />Press and hold down shift key when opening database<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />21<br />
  22. 22. Specifying Startup Options in the Startup Dialog Box<br />Options<br />Display form<br />Display navigation pane<br />Allow full menus<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />22<br />
  23. 23. Startup Dialog Box<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />23<br />
  24. 24. Creating a Splash Screen<br />Splash screen<br />Displays when database opens<br />Contains<br />Logo<br />Text<br />Can only display splash screen or switchboard automatically<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />24<br />
  25. 25. Creating a Splash Screen (continued)<br />AutoExec<br />Special macro<br />Runs when database opens<br />Before startup dialog box options<br />Can use to display splash screen<br />Create splash screen form<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />25<br />
  26. 26. Creating an AutoExec Macro<br />Create macro that contains actions Access should perform when database opened<br />Save macro using name AutoExec<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />26<br />
  27. 27. Level 1 Summary<br />Switchboard <br />Special kind of form <br />Appears when database opened<br />Macro<br />Use to automate repeated actions<br />Startup options dialog box<br />Splash screen<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />27<br />
  28. 28. Level 2 Objectives:Creating Advanced Macros<br />Consolidate automated tasks by creating a macro group<br />Create buttons that can perform a series of actions<br />Troubleshoot macros<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />28<br />
  29. 29. Understanding Macro Groups<br />Macro group <br />Two or more macros placed within same macro file<br />Consolidate related macros <br />Manage large numbers of macros<br />Only group name displayed as macro object in database window<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />29<br />
  30. 30. Creating a Macro Group<br />Logical to organize similar macros within group<br />To create Click the Create tab and then click the Macro button<br />Click the Macro Names button on the Design tab. Access adds the Macro Name column to the left of the Action column<br />In the Macro Name column, enter the name of a macro<br />In the Action column, enter the corresponding actions for the macro<br />Enter comments as needed in the Comment column, and set arguments as needed in the Action Arguments pane<br />Save the macro group, using the “mcr” prefix in the object name<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />30<br />
  31. 31. Running the Macros in a Macro Group<br />Run particular macro within group<br />Click the Run Macro button in the Macro group on the Database Tools Ribbon<br />Select the list arrow to choose the macro name<br />Click the macro name<br />Click OK<br />Switchboard Manager and many property sheets<br />Specify name of macro to run<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />31<br />
  32. 32. Running the Macros in a Macro Group<br />Run macro object<br />Enter or select name<br />Run only one macro in macro group<br />Use special notation mcrGroupName.mcrMacroName<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />32<br />
  33. 33. Creating an AutoKeys Macro Group<br />AutoKeys macro group <br />Assign macro action or set of actions to key or key combination<br />Macro name column<br />Type key or key combination <br />Use special syntax<br />SendKeys action <br />Sends keystrokes to Access or to another active program<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />33<br />
  34. 34. Examples of Key Combinations for the Autokeys Macro Group<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />34<br />
  35. 35. Modifying the Switchboard to Run Macros<br />Modify switchboard to include <br />Macro group listing macros that open queries<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />35<br />
  36. 36. Specifying Conditions and Events for Macros<br />Specify conditions for performing macro actions <br />Assign macro to control<br />Event-driven programming<br />Running macro when user interacts with object<br />Event <br />State condition or occurrence that Access recognizes<br />Event property<br />Specifies how object responds when event occurs<br />Set to macro name to run macro when even occurs<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />36<br />
  37. 37. Assigning a Macro to a Control<br />Create macro or macro group that performs series of actions<br />Assign macro to control<br />Add command button to form by opening form in Design view<br />Attach macro with desired actions to command button<br />Using On Click property<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />37<br />
  38. 38. Specifying Conditions in a Macro<br />Where condition argument<br />Refer to controls on form that are not currently active<br />Use control’s complete name<br />Format<br />[Forms]![formName]![controlName]<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />38<br />
  39. 39. Troubleshooting Macros<br />Macros containing arguments<br />Especially error prone<br />Error types<br />Syntax error<br />Logic error<br />Run-time error<br />Troubleshooting tools<br />Single step through execution of macro, using debug window<br />Print macro code<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />39<br />
  40. 40. Printing Macros<br />Open Documenter dialog box <br />Select macro<br />Click options button to select details of macro to print<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />40<br />
  41. 41. Single Stepping a Macro<br />Runs macro one action at time <br />Pausing between actions<br />Make sure actions appear in correct order and with correct arguments<br />Use Single Step button<br />Macro Single Step dialog box<br />Buttons<br />Step<br />Halt<br />Continue<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />41<br />
  42. 42. Using Breakpoints and the Debug Window<br />Breakpoint<br />Code inserted in macro<br />Signals where to stop macro<br />Examine values of actions controls, and arguments macro using in debug window<br />Debug window <br />Shows macro as it appears in VBA code<br />Examine details of macro code in debug window<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />42<br />
  43. 43. Using Breakpoints and the Debug Window (continued)<br />Immediate pane<br />Displays current value of controls and arguments<br />Display using ? operator<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />43<br />
  44. 44. Level 2 Summary<br />Macro group<br />Conditions for macros<br />Assign macro to control<br />Debug macros<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />44<br />
  45. 45. Level 3 Objectives:Macro Conditions<br />Display message boxes under specified conditions<br />Run a macro when a form opens or a report prints<br />Use a macro to validate data<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />45<br />
  46. 46. Exploring Macro Conditions<br />Macro conditions <br />Logical expressions that result in true or false answer<br />Depending on outcome <br />Macro can perform one set of actions or another<br />Enter macro conditions <br />Open condition column in Macro window<br />By clicking Conditions button<br />If condition true <br />Access performs corresponding action in action column<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />46<br />
  47. 47. Exploring Macro Conditions<br />Perform more than one action if condition true <br />Enter conditional statement in condition column <br />Select actions in action column in order <br />Enter ellipsis (…) for each subsequent action associated with condition in condition column<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />47<br />
  48. 48. Exploring Macro Conditions (continued)<br />SetValue action<br />Change property of object by disabling, updating, hiding, or displaying control<br />Arguments <br />Item<br />Expression<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />48<br />
  49. 49. Assigning a Macro to an Object Event<br />Assign macro to object <br />By specifying macro name in event property of object<br />Event categories<br />Report<br />Section<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />49<br />
  50. 50. Report Events<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />50<br />
  51. 51. Report Section Events<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />51<br />
  52. 52. Using Message Boxes with Forms<br />Form events can also trigger macros<br />Use to <br />Validate data <br />Set values <br />Navigate between forms<br />Filter, find, and print records<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />52<br />
  53. 53. Form Events<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />53<br />
  54. 54. Using Message Boxes with Forms<br />MsgBox command<br />Opens message box <br />Displays warning or informational message<br />MsgBox ("message" sum of button and icon values "title")<br />Returns value depending on which button clicked<br />Create condition that checks to see which button users click<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />54<br />
  55. 55. Using Message Boxes with Reports<br />When conditions in macro references name of control from source <br />Source must be open when condition tested<br />Can hide window while macro tests condition<br />MsgBox action<br />Opens message box and displays warning or informational message<br />Similar to using MsgBox command<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />55<br />
  56. 56. Using Message Boxes with Reports (continued)<br />MsgBox action arguments <br />Message <br />Beep <br />Type<br />Title<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />56<br />
  57. 57. Validating Data with Macros<br />Validation field properties have limits<br />Validate data using more than one rule and more than one validation message<br />Create macro<br />Domain aggregate functions<br />Calculate statistics for set of records (recordset) or domain, from table or query<br />Dcount function<br />Dcount(expression, table or query, condition)<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />57<br />
  58. 58. Common Domain Aggregate Functions<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />58<br />
  59. 59. Level 3 Summary<br />Conditional expressions in macros<br />Assign macros to events<br />Message boxes<br />Msgbox command<br />Msgbox action<br />Validate data with macros<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />59<br />
  60. 60. Chapter Summary<br />Switchboard<br />Provides main menu for Access application<br />Macro <br />Automates repetitive tasks<br />Can use conditional expressions<br />Associate with command buttons or other controls<br />Debugger<br />Find errors in macros by stepping though each statement<br />Succeeding in Business with Microsoft Office Access 2007: A Problem-Solving Approach <br />60<br />

×