Macros have become one of the most recent functions added to Microsoft Access, it allows execute an action just before or just after adding, deleting, or updating table data. Therefore, it has been transformed into a tool very useful when working on this program.
It is important to mention that working with macros is not an easy task, since it usually has its complications, but once you manage to apply them you will notice all the benefits that this option can give youespecially when you are working with a fairly large database.
According to this and the importance of power handle all the tools that this software offers, here we are going to show you how you can start create your own data macros in an Access table from scratch, To do this, follow in detail everything that we will teach you below.
What are data macros and what are they for in Microsoft Access?
Data macros are became one of the new features of Microsoft Access 2010, they are intended to allow run tasks before or after performing an action on a table. In the same way it allows to apply a little logic to events that occur within tables, as is adding, deleting or updating data. In this way, it can be said that macros are managed from the table tab.
While viewing a table in a view datasheet and macros do not appear in the option “Macros”. And it is that this tool allows to carry out different actions such as validating the data of a table and checking the precision of the same. Currently they can be found two main data macros, the first one is about handle table events and those that are executed as responses to be called by name they are also known as named data macro.
Learn step by step how to create a data macro in Microsoft Access
Taking into account everything mentioned above in the post and knowing what are data macros and what are they for, the next thing will be to show you step by step how you can start create them in Access. This process can be done in two ways, either from macros for events and macros for named data.
To do this, they follow each of the methods that we are going to teach you below:
Dominated by events
The first method we will teach you is about data macros by events, in this case table events they end up being produced every time add, delete, or update data in a table. So here you can program a macro so that this is adjusted immediately once any of these occur events or once a modification or deletion event takes place.
In order to create a macro called by events, you simply have to follow each of the steps that we will teach you below:
- In the Access navigation bar you must double click on the table where you want add the data macro.
- Now in the group of “Past events” or “Later events” depending on the case, you must select the event in which you want to add the macro. In the case that you want add a macro to run after remove any record from table, then you must select the option of “After deleting.”
- In this case Access starts the macro generator, in the case that previously one has been created for said event, then the system will show you a notice indicating that there is already an existing one.
- Then you must add the actions what do you want me to know run through the macro.
- Finally, you must save the action and close the macro so that this is applied in due course.
Naming data macro
The process for create these naming data macro is easier and faster to perform, they are associated with a specific table and not with a specific event as happened in the previous case. In this case you can call a Named data macro from any other standard macro or data macro.
In addition, the process of creating it is easier, to do this, follow each of the following steps:
- At navigation panel you must click on the table you want to add the named data macro to it.
- Now in the tab “Table” and in the section “Macros with names” you must select the option “Named macros” and then “Create named macro.”
- The window of the “Macro generator” so you can start add the corresponding actions.
Steps to manage the data macros you create in Microsoft Access
In this case the only important thing is not to know how to create them, but also how to manage them. And it is that data macros usually do not appear in the macro navigation pane, This means that you must use the commands of the “Options” found in the datasheet view the table or in design view. This allows create, edit, rename, and delete macros as required.
In accordance with all this, here we are going to teach you how to manage macros in Microsoft Access, to do this, follow each of the methods that we will teach you below:
Edit event macro
The first method we teach you is manage event macros.
To do this, you need to follow each of these steps:
- The first thing will be to select the table that contains the data macro that you want to edit, in this case the event.
- Now in the tab “Table” you will find the sections of “Past events” or “Later events”, there you must select the event of the macro you want to edit. In this case you can select the edition of the macro that is executed after deleting a record from the table, to do this, click on the option “After deleting.”
- The “Macro generator” and then start editing the macro you have selected.
Edit macro names
To edit the name macros you will simply have to execute each of the steps that we will indicate below:
- Here you must click on the table to open it in the datasheet view.
- Now in the tab “Table” you must go to the section of “Named macros” and there select the option “Macro with name”, In the options that appear there you must select the option of “Edit named macro ”.
- Then in the submenu you must click on the data macro you want to edit.
- The “Macro generator” so that you can start editing the macro you have selected.
Modify macro name
Another aspect that you can modify is the name of the macro.
To do this, you must perform these steps:
- To carry out this procedure you must go to navigation panel and there double click on any of the table to open it in the datasheet view,
- Again you must go to the tab “Table” and there select the option “Macro with name” from the section of “Macro with name”.
- In the options that appear there you must select “Rename / Delete macro”.
- Then the dialog box will appear “Data macro manager”, there you must select the option “Rename” located right next to the macro you want to rename.
- Here you must write the new name you want to give it, and once it is defined you must click on “To accept”.
Delete a macro
Finally, we are going to explain how can you delete a macroPlease note that this process is completely similar to the one mentioned above.
To do this, follow these steps:
- Again you must access the file “Table” and there go to the section of “Named macros” and select the option “Macros with names.”
- In the drop-down menu that appears there you must select the option “Rename / Delete macro”.
- The dialog box will automatically start “Data macro manager” this time you must click on the option “Remove” you will be right next to the macro you want to delete.