You Can Create a Macro
-
Upload
atif-ahmad -
Category
Documents
-
view
219 -
download
0
Transcript of You Can Create a Macro
-
8/13/2019 You Can Create a Macro
1/6
You can create amacro (macro: An action or set of actions that you can use to automate tasks.) to perform
a specific action or amacro group (macro group: A collection of related macros that are stored together
under a single macro name. The collection is often referred to simply as a macro.)to perform a series of
actions.
Create a macro
1. In the Database indo (Database indo: The indo that appears hen you open an
Access database or an Access pro!ect. It displays shortcuts for creating ne database ob!ects and
opening e"isting ob!ects.)#click Macros under Objects.
$. Click the Newbutton on the Database indo toolbar.
%. Add an action (action: The basic building block of a macro& a self'contained instruction that can
be combined ith other actions to automate tasks. This is sometimes called a command in other
macro languages.)to the macro.
o
1. In the *acro indo (*acro indo: The indo in hich you create and modify
macros.)#click the first empty ro in the Actioncolumn. If you ant to insert an action (action:
The basic building block of a macro& a self'contained instruction that can be combined ith
other actions to automate tasks. This is sometimes called a command in other macro
languages.)beteen to action ros (action ro: A ro in the upper part of the *acro indo
in hich you enter macro names# actions# conditions# and comments associated ith a
particular macro or macro group.)# click the selector for the action ro !ust belo the ro here
you ant to insert the ne action# and then click Insert Row on the toolbar.
2. In the Actioncolumn# click the arro to display the action list (action list: The list
that appears hen you click the arro in the Action column of the *acro indo.).
%. Click the action you ant to use.
4. In the loer part of the indo# specify arguments for the action# if any are re+uired.
,oraction arguments (action argument: Additional information re+uired by some macro actions.
,or e"ample# the ob!ect affected by the action or special conditions under hich the action is
carried out.)hose settings are adatabase ob!ect (database ob!ects: An Access database
http://appendpopup%28this%2C%27acmacro_1%27%29/http://appendpopup%28this%2C%27acmacro_1%27%29/http://appendpopup%28this%2C%27defmacrogroup_2%27%29/http://appendpopup%28this%2C%27defmacrogroup_2%27%29/http://appendpopup%28this%2C%27defmacrogroup_2%27%29/http://togglediv%28%27divexpcollasst_1%27%29/http://appendpopup%28this%2C%27defdatabasewindow_3%27%29/http://appendpopup%28this%2C%27defdatabasewindow_3%27%29/http://appendpopup%28this%2C%27defdatabasewindow_3%27%29/http://appendpopup%28this%2C%27defdatabasewindow_3%27%29/http://appendpopup%28this%2C%27defaction_4%27%29/http://appendpopup%28this%2C%27defaction_4%27%29/http://appendpopup%28this%2C%27defaction_4%27%29/http://appendpopup%28this%2C%27defaction_4%27%29/http://togglediv%28%27divexpcollasst_2%27%29/http://appendpopup%28this%2C%27defscriptwindow_5%27%29/http://appendpopup%28this%2C%27defscriptwindow_5%27%29/http://appendpopup%28this%2C%27defscriptwindow_5%27%29/http://appendpopup%28this%2C%27defaction_6%27%29/http://appendpopup%28this%2C%27defaction_6%27%29/http://appendpopup%28this%2C%27defaction_6%27%29/http://appendpopup%28this%2C%27defaction_6%27%29/http://appendpopup%28this%2C%27defaction_6%27%29/http://appendpopup%28this%2C%27defactionrow_7%27%29/http://appendpopup%28this%2C%27defactionrow_7%27%29/http://appendpopup%28this%2C%27defactionrow_7%27%29/http://appendpopup%28this%2C%27defactionlist_8%27%29/http://appendpopup%28this%2C%27defactionlist_8%27%29/http://appendpopup%28this%2C%27defactionlist_8%27%29/http://appendpopup%28this%2C%27defactionargument_9%27%29/http://appendpopup%28this%2C%27defactionargument_9%27%29/http://appendpopup%28this%2C%27defactionargument_9%27%29/http://appendpopup%28this%2C%27defactionargument_9%27%29/http://appendpopup%28this%2C%27defactionargument_9%27%29/http://appendpopup%28this%2C%27defdatabaseobjects_10%27%29/http://appendpopup%28this%2C%27defdatabaseobjects_10%27%29/http://appendpopup%28this%2C%27defdatabaseobjects_10%27%29/http://appendpopup%28this%2C%27defmacrogroup_2%27%29/http://appendpopup%28this%2C%27defmacrogroup_2%27%29/http://togglediv%28%27divexpcollasst_1%27%29/http://appendpopup%28this%2C%27defdatabasewindow_3%27%29/http://appendpopup%28this%2C%27defdatabasewindow_3%27%29/http://appendpopup%28this%2C%27defdatabasewindow_3%27%29/http://appendpopup%28this%2C%27defaction_4%27%29/http://appendpopup%28this%2C%27defaction_4%27%29/http://appendpopup%28this%2C%27defaction_4%27%29/http://togglediv%28%27divexpcollasst_2%27%29/http://appendpopup%28this%2C%27defscriptwindow_5%27%29/http://appendpopup%28this%2C%27defscriptwindow_5%27%29/http://appendpopup%28this%2C%27defaction_6%27%29/http://appendpopup%28this%2C%27defaction_6%27%29/http://appendpopup%28this%2C%27defaction_6%27%29/http://appendpopup%28this%2C%27defactionrow_7%27%29/http://appendpopup%28this%2C%27defactionrow_7%27%29/http://appendpopup%28this%2C%27defactionrow_7%27%29/http://appendpopup%28this%2C%27defactionlist_8%27%29/http://appendpopup%28this%2C%27defactionlist_8%27%29/http://appendpopup%28this%2C%27defactionargument_9%27%29/http://appendpopup%28this%2C%27defactionargument_9%27%29/http://appendpopup%28this%2C%27defactionargument_9%27%29/http://appendpopup%28this%2C%27defdatabaseobjects_10%27%29/http://appendpopup%28this%2C%27acmacro_1%27%29/ -
8/13/2019 You Can Create a Macro
2/6
contains ob!ects such as tables# +ueries# forms# reports# pages# macros# and modules. An
Access pro!ect contains ob!ects such as forms# reports# pages# macros# and modules.)name#
you can set the argument by dragging the ob!ect from theDatabase indo (Database indo:
The indo that appears hen you open an Access database or an Access pro!ect. It displays
shortcuts for creating ne database ob!ects and opening e"isting ob!ects.)to the action-s
Object Nameargument bo".
. Type a comment for the action. Comments are optional.
4. To add more actions to the macro# mo/e to another action ro (action ro: A ro in the upper
part of the *acro indo in hich you enter macro names# actions# conditions# and comments
associated ith a particular macro or macro group.)and repeat step %. *icrosoft Access carries out
the actions in the order you list them.
Create a macro group
If you ant to group se/eral relatedmacros (macro: An action or a set of actions you can use to automate
tasks. *acros are recorded in the 0isual 1asic for Applications programming language.)in one place rather
than keeping track of them separately# you can organi2e them as a macro group.
1. In the Database indo (Database indo: The indo that appears hen you open an
Access database or an Access pro!ect. It displays shortcuts for creating ne database ob!ects and
opening e"isting ob!ects.)#click Macros under Objects.
$. Click the Newbutton on the Database indo toolbar.
3. Click Macro Names on the toolbar# if it isn-t already selected (selected: A toolbar button
alays has a border around it hen it-s selected# e/en hen the pointer is not resting on the button.).
3. In the Macro Namecolumn# type a name for the first macro in the macro group.
. Add theactions (action: The basic building block of a macro& a self'contained instruction that
can be combined ith other actions to automate tasks. This is sometimes called a command in other
macro languages.)you ant the macro to carry out.
o
http://appendpopup%28this%2C%27defdatabaseobjects_10%27%29/http://appendpopup%28this%2C%27defdatabaseobjects_10%27%29/http://appendpopup%28this%2C%27defdatabasewindow_11%27%29/http://appendpopup%28this%2C%27defdatabasewindow_11%27%29/http://appendpopup%28this%2C%27defdatabasewindow_11%27%29/http://appendpopup%28this%2C%27defdatabasewindow_11%27%29/http://appendpopup%28this%2C%27defdatabasewindow_11%27%29/http://appendpopup%28this%2C%27defactionrow_12%27%29/http://appendpopup%28this%2C%27defactionrow_12%27%29/http://appendpopup%28this%2C%27defactionrow_12%27%29/http://togglediv%28%27divexpcollasst_3%27%29/http://appendpopup%28this%2C%27ofdefmacro_13%27%29/http://appendpopup%28this%2C%27ofdefmacro_13%27%29/http://appendpopup%28this%2C%27ofdefmacro_13%27%29/http://appendpopup%28this%2C%27defdatabasewindow_14%27%29/http://appendpopup%28this%2C%27defdatabasewindow_14%27%29/http://appendpopup%28this%2C%27defdatabasewindow_14%27%29/http://appendpopup%28this%2C%27defdatabasewindow_14%27%29/http://appendpopup%28this%2C%27ofselected_15%27%29/http://appendpopup%28this%2C%27ofselected_15%27%29/http://appendpopup%28this%2C%27defaction_16%27%29/http://appendpopup%28this%2C%27defaction_16%27%29/http://appendpopup%28this%2C%27defaction_16%27%29/http://appendpopup%28this%2C%27defaction_16%27%29/http://appendpopup%28this%2C%27defaction_16%27%29/http://togglediv%28%27divexpcollasst_4%27%29/http://appendpopup%28this%2C%27defdatabaseobjects_10%27%29/http://appendpopup%28this%2C%27defdatabaseobjects_10%27%29/http://appendpopup%28this%2C%27defdatabasewindow_11%27%29/http://appendpopup%28this%2C%27defdatabasewindow_11%27%29/http://appendpopup%28this%2C%27defdatabasewindow_11%27%29/http://appendpopup%28this%2C%27defactionrow_12%27%29/http://appendpopup%28this%2C%27defactionrow_12%27%29/http://appendpopup%28this%2C%27defactionrow_12%27%29/http://togglediv%28%27divexpcollasst_3%27%29/http://appendpopup%28this%2C%27ofdefmacro_13%27%29/http://appendpopup%28this%2C%27ofdefmacro_13%27%29/http://appendpopup%28this%2C%27defdatabasewindow_14%27%29/http://appendpopup%28this%2C%27defdatabasewindow_14%27%29/http://appendpopup%28this%2C%27defdatabasewindow_14%27%29/http://appendpopup%28this%2C%27ofselected_15%27%29/http://appendpopup%28this%2C%27ofselected_15%27%29/http://appendpopup%28this%2C%27defaction_16%27%29/http://appendpopup%28this%2C%27defaction_16%27%29/http://appendpopup%28this%2C%27defaction_16%27%29/http://togglediv%28%27divexpcollasst_4%27%29/ -
8/13/2019 You Can Create a Macro
3/6
-
8/13/2019 You Can Create a Macro
4/6
6"amples of macro conditions
You can use anye"pression (e"pression: Any combination of mathematical or logical operators# constants#
functions# and names of fields# controls# and properties that e/aluates to a single /alue. 6"pressions can
perform calculations# manipulate characters# or test data.)that e/aluates to True7,alse or Yes78o in a macro
condition (condition: 9art of the criteria that a field must meet for searching or filtering. ome conditions
must be used ith a /alue& for e"ample# the field Author ith the condition equals ith the /alue ;ane.). The
macro ill be e"ecuted if the condition e/aluates to True (or Yes).
Tip
To cause *icrosoft Access to temporarily ignore an action (action: The basic building block of a macro& a
self'contained instruction that can be combined ith other actions to automate tasks. This is sometimes
called a command in other macro languages.)# enter ,alse as a condition. Temporarily ignoring an action
can be helpful hen you are trying to find problems in a macro.
Use this expression To carry out the action if
[City]="Paris" Paris is the City value in the field on the form from which the macrowas run.
DCount("[OrderID]", "Orders"!# $here are more than # entries in the OrderID field of the Orders
ta%le.
DCount("&", "Order Details","[OrderID]='orms[Orders][OrderID]"!
$here are more than three entries in the Order Details ta%le forwhich the OrderID field of the ta%le matches the OrderID field on theOrders form.
[)hi**edDate] +etween -'e%-//01nd -2ar-//0
$he value of the )hi**edDate field on the form from which themacro is run is no earlier than -'e%-//0 and no later than -2ar-//0.
'orms[Products][3nitsIn)toc4]5# $he value of the 3nitsIn)toc4 field on the Products form is less thanfive.
Is6ull(['irst6ame] $he 'irst6ame value on the form from which the macro is run isNull (Null7 1 value you can enter in a field or use in e8*ressions or9ueries to indicate missin: or un4nown data. In ;isual +asic, the
Null 4eyword indicates a Null value. )ome fields, such as *rimary4ey fields, canen([PostalCode]5!#
$he value in the Country field on the form from which the macro isrun is 'rance, Italy, or )*ain, and the *ostal code isn
-
8/13/2019 You Can Create a Macro
5/6
2s:+o8("Confirm chan:es?",0=0 @ou clic4 OKin a dialo: %o8 in which the MsgBoxfunction dis*lays"Confirm chan:es?". If you clic4 Cancelin the dialo: %o8, 2icrosoft1ccess i:nores the action.
You might often ant to look at related records on to forms at the same time. ,or e"ample# hile looking at
a customer record on a Customers form# you might ant to open an
-
8/13/2019 You Can Create a Macro
6/6
4. After selecting the fields from the first table or record source in the ,orm =i2ard# repeat step
to select another table or record source# and pick fields that you ant to include in your second form.
@. =hen you ha/e selected all the re+uired fields# click Next.
. In the second screen of the i2ard# click Lined !orms# and then click Next.
B. ,ollo the instructions in the i2ard. The i2ard creates the to related forms& each form
contains fields from one of the record sources.