Transcript Document

Exploring Microsoft
Office Access 2010
Chapter 10
Customizing a Database with
Macros
1
Objectives
•
•
•
•
•
Understand the purpose of macros
Create embedded macros using Wizards
Create macros using the Macro Builder
Assign macros to events
Use SQL conditions to control macro
actions
2
Customization in Access
• Customization needed when additional
functionality required
• Access provides two methods of
Customization
• Visual Basic for Applications
– User creates code using VBA
• Macros
– Automates tasks
3
Macros
• Two types of Macros in
Access
– Embedded – belongs to a single
object or control
– Standalone – used with more
than one control
• Control – object in Access (textbox, list
box)
• Macro Group
• Group of macros stored in a single
macro object
Copyright © 2008 Pearson Prentice Hall. All rights reserved.
4
Creating an Embedded Macro
Button
• Click Design tab
• Click Button
Command Button Wizard
– Controls Group
• Command Wizard begins
Copyright © 2008 Pearson Prentice Hall. All rights reserved.
5
Creating an Embedded Macro
Choose a category
•
•
•
•
•
Choose an action
Choose object that the action will
be performed upon
Choose the appropriate category
Choose action that you want to perform
Click Next
Select the object you wish to use
Click Next
Copyright © 2008 Pearson Prentice Hall. All rights reserved.
6
Creating an Embedded Macro
Specify how the button should work
open an object
Specify Text or graphic for the button
• Specify action when form is opened
– Screen varies by object and action
• Specify text or graphic
• Click Next
Copyright © 2008 Pearson Prentice Hall. All rights reserved.
7
Creating an Embedded Macro
Completed button
Finish
• Provide a name for the button
• Click Finish
Copyright © 2008 Pearson Prentice Hall. All rights reserved.
8
Creating Standalone Macros
using the Macro Builder
Macro
Macro Builder
• Click the Create tab
• Click Macro
– Other group
– Macro Builder launches
Copyright © 2008 Pearson Prentice Hall. All rights reserved.
9
Creating Standalone Macros
using the Macro builder
2. Argument appears here
Select Action
1. Provide Argument
• Select Action
• Provide Arguments when necessary
– Value that provides information for action
• Run or Copyright
Close
and Save macro
© 2008 Pearson Prentice Hall. All rights reserved.
10
Assigning Events
Property Sheet
Events
Choose object that the
event is assigned to
• Event
– Action triggered by user or system
• Assign an Event
– Right-click, select properties
– Choose
property-Event tab, Control list
Copyright © 2008 Pearson Prentice Hall. All rights reserved.
11
Running a Macro
• Design view
– Click the Run
button
• Form, Report or
Table view
Button in Form
View
– Click button or
perform assigned
Navigation Pane
event
• Navigation Pane
– Double-click
Copyright © 2008 Pearson Prentice Hall. All rights reserved.
12