Summary of Access 97 Macro Actions
This is a list of macro actions organized in the following functional categories:
Opening and Closing Tables, Queries, Forms, and Reports
|
Macro Action |
Purpose |
|
|
Close |
Closes specified or active window for a table, query, form, or report. |
|
|
OpenForm |
Opens a form in Form, Datasheet, or Design view, or in Print Preview. Can apply filter or Where condition. |
|
|
OpenModule |
Opens a module in Design view and displays the named procedure. |
|
|
OpenQuery |
Opens a query in Datasheet, Design view or in Print Preview. If an Action query, updates performed. To specify parameters for an Action query, use the RunSQL action. |
|
|
OpenReport |
Opens a report in Print Preview (the default), prints the report, or opens the report in Design view. For Print and Print Preview, can also specify a filter or Where condition. |
|
|
OpenTable |
Opens a table in Datasheet or Design view or in Print Preview. |
|
|
RunSQL |
Executes the specified SQL Insert, Delete, Select...Into, or Update statement. Can refer to form controls in the statement to limit the affected records. |
|
Actions that can Print Data
|
Macro Action |
Purpose |
|
OpenForm |
Can also open in Print Preview. Can specify a filter or Where condition. |
|
OpenQuery |
Can also open in Print Preview. |
|
OpenReport |
Prints a report or opens a report in Print Preview. Can specify a filter or Where condition. |
|
OpenTable |
Can also open in Print Preview. |
|
OutputTo |
Outputs the named table, query, form, report, or module to Excel (XLS), Word (RTF), or Notepad text (TXT) file, and optionally starts the application to edit the file. For forms, the data output from the form’s Datasheet view. For reports, Access outputs all controls containing data (including calculated controls) except memo, OLE, and subform or subreport controls. |
|
PrintOut |
Prints the active datasheet, form, or report. Can specify a range of pages, the print quality, the number of copies, and collation. Use an Open action first if you want to apply a filter or Where condition. |
Testing Conditions and Controlling Action Flow
|
Macro Action |
Purpose |
|
CancelEvent |
Cancels the event that caused this macro to be executed. Can’t use CancelEvent in macros that define menu commands, in OnClose for a report, or in macros triggered by the AfterUpdate, OnCurrent, OnEnter, or OnPush event. |
|
DoMenuItem |
Executes a command on a standard Access menu. Can use DoMenuItem in a macro that defines a custom menu to make selected Access menu commands available in the custom menu. |
|
Quit |
Closes all Access windows and exits Access. |
|
RunCode |
Executes a Access Basic function procedure. Other actions following this action execute after the function completes. (Note: To execute a Access Basic sub procedure, call that procedure from a function procedure. |
|
RunMacro |
Executes another macro. Actions following this action execute after other macro completes. |
|
StopAllMacros |
Stops all macros, including any macros that called this macro. |
|
StopMacro |
Stops the current macro. |
Setting Values
|
Macro Action |
Purpose |
|
Requery |
Refreshes the data in a control that is bound to a query (such as a list box, combo box, subform, or a control based on an aggregate function such as DSum). When other actions (such as inserting or deleting a row in the underlying q uery) might affect the contents of a control that is bound to a query, use Requery to update the control values. Use Requery without an argument to refresh the data in the form or datasheet |
|
SendKeys |
Places keystrokes into the keyboard buffer. If you intend to send keystrokes to a modal form or dialog box, you must execute SendKeys before opening the modal form or dialog box. |
|
SetValue |
Changes the value of any updateable control or property. For example, can use SetValue to calculate a new total in an unbound control or to affect the Visible property of a control (which determines whether you can see that control). |
Searching for Data
|
Macro Action |
Purpose |
|
ApplyFilter |
Restricts the information displayed in a form or report by applying a named filter or query or SQL WHERE clause to the underlying table or query of the form. |
|
FindNext |
Finds the next record that meets the criteria previously set or by FindRecord in the Find dialog box. |
|
FindRecord |
Finds a record that meets the search criteria. Can specify in the macro action all the parameters available in the Find dialog box. |
|
GoToRecord |
Moves to a different record and makes it current in the specified table, query, or form. Can move to the first, last, next, or previous record. When you specify "next" or "previous," can move more than one record. Can a lso go to a specific record number or to the new-record placeholder at the end of the set. |
Building a Custom Menu and Executing Menu Commands
|
Macro Action |
Purpose |
|
AddMenu |
Adds a drop-down menu to a custom menu bar for a form or report. This is the only action allowed in a macro referenced by a Menu Bar property. Each AddMenu macro action must have a name that corresponds to the menu name on the menu bar of the custom menu. The argument to AddMenu specifies the name of another macro that contains all the named commands for the menu and the actions that correspond to those commands. An AddMenu action can also refer to another macro that uses an AddMenu action to build submenus. |
|
DoMenuItem |
Executes a command on one of the standard Access menus. Use this macro within a custom menu bar to make selected Access menu commands available in the custom menu. |
Informing the User of Actions
|
Macro Action |
Purpose |
|
Beep |
Causes a sound. |
|
MsgBox |
Displays a warning or informational message and optionally produces a sound. You must click OK to dismiss the dialog box and proceed. |
|
SetWarnings |
When enabled, causes an automatic Yes or OK response to all system warning or informational messages while a macro runs. Does not halt the display of error messages. Use this macro with Echo set to Off to avoid displaying the messages. |
Controlling Display and Focus
|
Macro Action |
Purpose |
|
Echo |
Controls the display of intermediate actions while a macro runs. |
|
GoToControl |
Sets the focus to the specified control. |
|
GoToPage |
Moves to the specified page in a report or form. |
|
Hourglass |
Sets the mouse pointer to an hourglass icon while a macro runs. |
|
Maximize |
Maximizes the active window. |
|
Minimize |
Minimizes the active window. |
|
MoveSize |
Moves and sizes the active window. |
|
RepaintObject |
Forces the repainting of the window for the specified object. Forces recalculation of any formulas in controls on that object. |
|
Requery |
Refreshes the data in a control that is bound to a query (such as a list box, combo box, subform, or a control based on an aggregate function such as DSum). When other actions (such as inserting or deleting a row in the underlying q uery) might affect the contents of a control that is bound to a query, use Requery to update the control values. Use requery without an argument to refresh the data in the active object (form or datasheet). |
|
Restore |
Restores a maximized or minimized window to its previous size. |
|
SelectObject |
Selects the window for the specified object. Restores the window if it was minimized. |
|
SetWarnings |
When enabled, causes automatic Yes or OK response to all system warning or informational messages while a macro runs. Does not halt the display of error messages. Use with Echo set to Off to avoid displaying the messages. |
|
ShowAllRecords |
Removes any filters previously applied to the active form. |
|
ShowToolbar |
Shows or hides any of the standard toolbars or any custom toolbar. |
Renaming, Copying, Deleting, Importing, and Exporting Objects
|
Macro Action |
Purpose |
|
CopyObject |
Copies any object in the current database with a new name or with any specified name in another Access database. |
|
DeleteObject |
Deletes any table, query, form, report, macro, or module. |
|
OutputTo |
Outputs the named table, query, form, report, or module to a Excel (XLS), Word (RTF), or Notepad text (TXT) file, and optionally starts the application to edit the file. For forms, the data output is from the form’s datasheet view. For rep orts, Access outputs all controls containing data (including calculated controls) except memo, OLE, and subform or subreport controls. |
|
Rename |
Renames the specified object in the current database. |
|
SendObject |
Outputs a table datasheet, query datasheet, form datasheet, data in text boxes on a report, or a module listing to a Excel format (XLS), Rich Text Format (RTF), or text (TXT) and embeds the data in an electronic mail message. Can specify t o whom the message is to be sent, the message subject, additional message text, and whether the message can be edited before it is sent. You must have electronic mail software installed that conforms to the Mail Application Programming Interface (MAPI) st andard. |
|
TransferDatabase |
Exports data to or imports data from another Access, dBASE ®, Paradox®, FoxBASE® |
|
TransferSpreadsheet |
Exports data to or imports data from Excel or Lotus ® 1-2-3® spreadsheet files. (Note: Can import spreadsheet data from Excel versions 3 and 4, but cannot export Access data to these types of files.) |
|
TransferText |
Exports data to or imports data from text files. |
Running Another Application for MS-DOS or Windows
|
Macro Action |
Purpose |
|
RunApp |
Starts another application for MS-DOS or Windows. |