1 / 15

Access Macros

Access Macros. ISYS 562. Why Use Macro? . In Microsoft Access, you can accomplish many tasks by using macros. Macros are an easy way to take care of simple details such as opening and closing forms and running reports because there's little syntax to remember. . To create a macro.

Jims
Download Presentation

Access Macros

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Access Macros ISYS 562

  2. Why Use Macro? • In Microsoft Access, you can accomplish many tasks by using macros. Macros are an easy way to take care of simple details such as opening and closing forms and running reports because there's little syntax to remember.

  3. To create a macro • In the database windows, click Macros/New • Add an action to the macro. • In the lower part of the window, specify arguments for the action, if any are required. • To add more actions to the macro, move to another action row and add action. • Microsoft Access carries out the actions in the order you list them.

  4. Macro’s Actions • OpenForm, OpenReport • TransferDatabase, TransferSpreadsheet • OutputTo • CopyDatabaseFile, CopyObject • FindNext, FindRecord • RunCode, RunCommand, RunSQL, RunApp, RunMacro • SendObject • SetValue

  5. Macro Condition • You can use any expression that evaluates to True/False or Yes/No in a macro condition. The macro will be executed if the condition evaluates to True. • Example: [Forms]![employee]![empID]="E1" • To add a condition: • At macro design view: • View/Condition

  6. Examples of Macro’s Conditions

  7. Macro Group and Macro Name • Macro group is collection of related macros that are stored together under a single macro name. • To create a macro group (name): • Click the macro name button or right-click macro window’s title. • In the Macro Name column, type a name for the first macro in the macro group and add the action you want the macro to carry out. • Add other macros you want to include in the macro group.

  8. How a Macro Group Runs • When you run a macro group, Microsoft Access executes each macro, starting from the first action, until it encounters a StopMacro action, another macro group name, or no further actions. • When you save the macro group, the name you specify is the name of the group of macros. This name is displayed in the list of macros and macro groups in the Database window. Whenever you refer to a macro in a macro group, use this syntax: • macrogroupname.macroname

  9. Convert Macro to VB • Tools/Macro/Convert macros to VB

  10. Other situations you must use macros • Make global key assignments. • AutoKeys macro • Carry out an action or a series of actions when a database first opens. • AutoExec macro

  11. Assign an action or set of actions to a key AutoKeys Macro • You can assign an action or set of actions to a specific key or key combination by creating an AutoKeys macro group When you press the key or key combination, Microsoft Access carries out the action. If you assign an action to a key combination that is already being used by Access (for example, CTRL+C is the key combination for Copy), the action you assign this key combination replaces the Access key assignment.

  12. Steps to Create AutoKeys Macro • In the Database window, click Macros under Objects. • Click New. • Click Macro Names on the toolbar. • In the Macro Name column, type the key or key combination to which you want to assign the action or set of actions • Add the action or set of actions you want the key or key combination to carry out. For example, you could add a RunMacro action that runs the Print Current Record macro when CTRL+P is pressed. • Repeat steps 4 and 5 for any other key assignments you want to make. • Save the macro group with the name AutoKeys.

  13. Examples of Key Combinations These key combinations are a subset of the syntax used in the SendKeys statement in Microsoft Visual Basic.

  14. AutoKeys Example

  15. Control how an Access file looks and behaves when it opens • 1. Set startup options • On the Tools menu, click Startup. • Select the options or enter the settings you want to use. • Or • 2. Create a macro that runs when an Access file first opens • Create a macro containing the actions you want to run when you open the database. • Save the macro with the name AutoExec.

More Related