your image

Macros

access-programmers
Related Topic
:- MS Access

Macros

What is a macro?

A macro is a stored series of commands that carry out an action or a string of actions. This feature can be used to add functionality or automate simple tasks, such as performing an action when the user clicks a command button.

Why use macros?

You do not need to know how to program to use macros!

Macros can perform a number of the common tasks that you can also use Visual Basic code to perform. With some research, non-programmers can quickly set up a macro and dramatically increase database productivity.

Limitations of macros

Macros functions are limited. You might find yourself searching for some help developing a custom VB code. Macros lack programming loops and advanced coding logic.

Macros are not meant to be a permanent solution, and they take up more space than VB code. Luckily, you can use this function to develop prototype VBA code.

Most professional Access developers use the VBA programming language for a richer and more powerful development environment. Over time, you’ll want to switch your Macro over to a VB code.

Using Visual Basic code rather than macros gives you much more flexibility and power. Visual Basic provides much more functionality than macros such as returning values or iterating through record sets.

Examples of macros

The following Macro contains examples of:

  • Variable declaration
  • Referencing cells in a Worksheet
  • Select Case Statement

 

Developing Macros

If you do not have a programming background, you can use the macro feature to automate simple tasks through a series of drop down selections that Access has provided.

Macros allow you to easily chain commands together such as running queries, importing or exporting data, opening and closing forms, previewing and printing reports, etc. Macros support basic ‘IF condition’ logic and the ability to call other macros. Macros can also contain sub-macros which are similar to subroutines.

In Access 2007, macros are significantly enhanced with the inclusion of error handling and temporary variable support. Access 2007 also introduces embedded macros that are essentially properties of an object's event. This eliminates the need to store macros as individual objects.

Comments