Learning to use the MS Access macro

Jan 15
09:27

2010

Paul Barnett

Paul Barnett

  • Share this article on Facebook
  • Share this article on Twitter
  • Share this article on Linkedin

The MS Access macro will take your database into a new dimension. You can write powerful automation features without having to learn any complex programming code.

mediaimage
Normal 0 false false false EN-GB X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Arial; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

The general features of MS Access allow us to create some great systems. However,Learning to use the MS Access macro Articles there will be times when we want to do something which goes beyond what can be achieved with the basic functionality. The MS Access macro will take your database into a new dimension.

 

Some people may find the idea of programming or learning VBA program code off putting. To some it can be challenging, rewarding even, to others a chore best avoided. There is a way around this though.

 

MS Access macros offer a halfway house between general functionality and fully blown programming. Essentially, behind the scenes macros are VBA program code, but to the user they appear as one line action statements. For example we could use a macro to open a form. The macro action would be called ‘OpenForm’. We just pass it the name of the form to open in the macro designer and voila, we have just written an automation statement without any program code. We could do the same with a report.

 

We would write an MS Access macro to automate routine tasks that we perform again and again. A good example is importing data. To save us going up to the menus and selecting the various options, we could write a macro to take care of it.

 

A macro consists of actions. We can add a series of actions to a single macro. We can also write a macro condition. For example, our macro condition could determine which button was clicked on the form and perform the correct macro action that is needed.

 

Although an MS Access macro has limited debugging features, it does allow us to step through each line to pinpoint what went wrong. You cannot recover from the error easily as is the case with VBA programming.

 

Some people use a macro for practically everything in their applications, although this is not recommended. Whilst they are very powerful tools it is better to use them sparingly and only for certain tasks.

 

A very well known MS Access macro is called ‘AutoExec’. This is the first thing that gets run when a database is opening. You might add a macro action to open a form and move to a certain record. You could then name the whole macro ‘AutoExec’ and the actions inside it would get run as soon as the database opens.

 

By using the MS Access macro you will not only add greater power to your applications, but you will also experience a whole new way of doing things.