Saturday, 12 January 2019

Microsoft Access Macros – Macros

Macros 

A macro is a sequence of actions that can be carried out on a single click.  It can be used to automate repetitive tasks that have be carried out frequently or so that others who do not necessarily know the sequence of tasks can carry out the task.

A macro does not have to be just one sequence of instructions, if choices and loops can also be programmed into the process.

The commands that can be used in a macro are listed as a set of actions that you can choose from.  The parameters that can be applied to a command are listed as action arguments.

An alternative to Microsoft macros is to use VBA, (Visual Basic for Applications), this is a simpler version of the programming language of Visual Basic.  The advantage of using VBA is that Access can be programmed to do anything you wish.  The disadvantage is that you need to know the language – whereas with macros you are choosing from a list with help in providing the information for the arguments.

Before writing a macro, you need to know the sequence of actions that need to be carried out.  In a simple macro instructions are carried out step by step until a blank row is encountered.

Creating a stand alone Macro 


1. Click on the create ribbon.

2. Click on Macro button.

This gives a choice of three types of macros (modules allows you to program in VBA).

3. Click on Macro.





This allows you to create your macro by choosing the commands required from the drop down at the end of the action box.  More commands can be added on the consecutive rows.

An alternative way of adding the commands is by typing the first letter of the command required – this selects the first command that’s starts with that letter.  You could now click on the drop down arrow to see the list from that point onwards or keep on adding more letters to make sure the correct command is selected.

When a command is selected more information might need to be provided.  This can be done in the arguments section that becomes available in the bottom half of the screen when a macro command is selected.




Here further information can be added about the action.

In this case which form is to be opened, which view it is to be seen in, whether any restrictions are to be applied as to what data is to be seen and what is to be allowed with the data.  There are three options.


Add – will only allow you to add new data.

Edit – will allow you to change existing records but not to add any more.

Read Only – will not allow any changes or any new records to be added.

This then allows the same form to be used in various ways in different macros.

Different actions will ask for distinct arguments that only apply to that particular action and there are also some actions that require no arguments at all.













No comments:

Post a Comment