Event-Driven Programming Using Macros

Learn: What is event-driven programming? What is a trigger? How do I design a trigger? How does the macro editor in Access work? How do I attach a macro to an event? What is the SetValue action? How is it used? How do I make the execution of particular macro actions conditional? What is a switchboard and how do I create one for my application? How to I make things happen when the application is opened? What are the advantages and disadvantages of event-driven programming? (pdf file, install Acrobat Reader to read this tutorial.)

Sponsored Links:

Related Topics

Convert Macros to VBA
I have a database that is highly driven by macros. I have been working on rewriting the VBA where I know how. I ran the performance analyzer on a few macros and it said to use the convertto VB tool and I did that and it converted it to VB and I am not sure how to use the VB code for example where do I put it now or does it automatically use it?

For example I have a macro that is run as autoexec when the database opens, and others that run after a button on a form is clicked.

Should I just be copying the code into the correct object event like the click event, etc?


Basics to Advanced Tutorial
These tutorials are in Adobe Acrobat PDF format. You can download them individually or as a set. To view the files, you need the Acrobat Reader, which Adobe provides at no charge. Topics included: Introduction to Microsoft Access, Tables, Relationships, Basic Queries Using QBE, Basic Queries using SQL, Creating Basic Forms, Parameter Queries, Advanced Forms, Action Queries,
An Introduction to Visual Basic, Event-Driven Programming Using Macros,
Subforms, Data Access Objects, Advanced Triggers, Combo Box Controls


Programming with Access 2007
Macros in Access can be considered like a simplified programming language that can be used to increase the functionality of the data base. For example, it can enclose a macro to a command button in a form, so the macro is executed when clicking in the button. The macros contain actions that make tasks, like opening a report, executing a query or to close the data base. Almost all the operations of data bases that normally are made manually can automate by means of macros, thus saving time.


Programming Access 2007
Macros in Access can be considered like a simplified programming language that can be used to increase the functionality of the data base. For example, it can enclose a macro to a command button in a form, so the macro is executed when clicking in the button. The macros contain actions that make tasks, like opening a report, executing a query or to close the data base. Almost all the operations of data bases that normally are made manually can automate by means of macros, thus saving time.


Macros
This week we'll discuss, for those of you unfamiliar with programming, one of the more conceptually complex aspects of Microsoft Access. We'll start with a discussion of events: what they are and how Access uses them. Then, we'll move on to a lengthy discussion of macros, including what they do and how you design and use them. TOC: Macros; Debugging;
Getting Fancy with Macros.


Create a macro
In Microsoft Office Access 2007, macros can be contained in macro objects (sometimes called standalone macros), or they can be embedded into the event properties of forms, reports, or controls. Embedded macros become part of the object or control in which they are embedded. Macro objects are visible in the Navigation Pane, under Macros; embedded macros are not.


Automate applications with macros in Access 2007
In Microsoft Office Access 2007, you can define a macro to execute just about any task you would otherwise initiate with the keyboard or the mouse. This article introduces you to the unique power of macros in Office Access 2007 — their ability to automate responses to many types of events without forcing you to learn a programming language. The event might be a change in the data, the opening or closing of a form or a report, or even a change of focus from one control to another.


Improve Functionality with Macros
Access 2007 readers knowledgeable in creating applications with wizards and macros can easily learn how to make their applications more professional using the power of VBA programming.


Delete macros after conversion to VBA?
I have a slooow Database. Everytime I go from one form to another (through buttons) it takes longer and longer as time goes (still developing database). So I tried converting my macros ( only bout 10 or so) into VBA through the setup they have on the wizard. My question is, now that I converted to VBA, can I delete the macros? If not then what is the point of converting to VBA other than more flexibility of programming.


MS Access 2013: Create a Macro
Microsoft Access provides the ability for you to create macros. A macro refers to a set of actions that can be run automatically, and on demand. Macros are usually configured to run whenever a particular event occurs. You specify what that event is when you create the macro. You could make a macro run when a user presses a certain key, or you could make a macro run everytime your database is opened.


Allow Code To Run . .
I would like to find a simple way to help my users enable their macros. I currently have a database that displays a form as soon as the database is opened. The issue is the form will not work unless Macros are enabled.

I would like to have a form with instructions on how to enable macros. Once the user open the database, if macros are enabled, the form with the instructions will be set to hide, and the regular form will be made visible.

In Excel there is a "Workbook" open event, is there such a thing in Access? Also, how can I prevent the user from accessing the Access optoins and changing the "Display Form" field?


VBA or Macros
I am building my database base on a template I got off of the Microsoft Access Website and it includes a combination of embedded macros and event procedures, VBA.

At this point I am not having too much problem editing either to get what I need to done, but that does not mean that I understand either very well at this time. However I am really trying to think about this database from a macro point of view and do things the right way the first time and not just what works just for the moment. I want to plan for this database to be upscaleable and to probably work on a network which may mean that the backend will reside on an SQL server. I am trying to learn and understand VBA, which I will take any reference recommendations on, but at this point both VBA & Macros are just greek to me.

So the question is should I be trying to convert all of the embedded macros to VBA or visa versa? Or is everything OK the way it is and if it ain't broke don't fix? What are your


Microsoft Access Macros
The following articles contain useful information about using macros in Microsoft Access 97 and converting macros to Visual Basic for Applications code.
Macros are very useful for automating simple tasks, such as carrying out an action when the user clicks a command button. You don't 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. However, using Visual Basic code instead of macros gives you much more flexibility and power, and there are many things you can only do in code, such as returning values or iterating through recordsets.


Open Macro in Design View Command Button
I have created a database that uses macros to send reports out to specific locations. The issues I have is I have the database extension as .accdr with short cut keys disabled to a point it prevents users from tampering with the programming and the data.

What I need to do is create a button on the administrator's page that will take the admin user to the macros section to allow them to update email addresses for reports as people come and go.


Refresh subform in access 2010
I have a calendar UI written in Access 2010 using only macros so I can eventually publish it on the web. It displays records in a TODO list. Each day on the monthly calendar has a subform based on a query with a where criteria which is a TempVar set by macros.

The temporary variables are being set by macros fired when either the parent form is first loaded, or when the user selects a new date from a control on the parent.

The first time the UI displays it all works very nicely, but I cannot get it to refresh the subforms when the user selects a new date. If I go out of the form and back in, the last date set shows, so the TempVars are being properly set.

How do I refresh the subforms from a macro fired by an AfterUpdate event (or any other event)on the parent's control?


Refresh subform in access 2010
I have a calendar UI written in Access 2010 using only macros so I can eventually publish it on the web. It displays records in a TODO list. Each day on the monthly calendar has a subform based on a query with a where criteria which is a TempVar set by macros. The temporary variables are being set by macros fired when either the parent form is first loaded, or when the user selects a new date from a control on the parent. The first time the UI displays it all works very nicely, but I cannot get it to refresh the subforms when the user selects a new date. If I go out of the form and back in, the last date set shows, so the TempVars are being properly set. How do I refresh the subforms from a macro fired by an AfterUpdate event (or any other event) on the parent's control?


Using Macros to Automate Data Entry
As you will have seen in the previous topic, we can use Macros to Require Data Entry and to inform users of any errors made in the data entry routine. We can also use Microsoft Access Macros to speed up the process of data entry. We can use a macro to remove the need for a user to enter the same data over and over for each record, we can use a macro to automate this process.
A Microsoft Access macro is a database object that allows us to automate repetative tasks without having to write complex programming routines. In Access, these tasks that the macro performs are know as macro actions.


Introduction to macros
This article explains what macros are and how they can save you time by automating tasks that you perform often. It explores the fundamentals behind creating and using macros and also touches on improvements to macros in Microsoft Office Access 2007.
In this article: What is a macro? Understand macros; New macro features in Office Access 2007; Create a macro; Run a macro.


Access Web 2010: Problems with Data Macros
Some time ago I published an Access database on a Web site Office 365 and found to work properly. The problem is that currently, all data macros are no longer visible from macros in forms. As an example, I have a product form with a button that performs an action on the record in the table "Products". Pressing the button runs the onClick event, and this in turnexecutes the data macro Products.CanUpdateProduct and Access displays the error "Can not start CanUpdateProduct macro."

I made a copy of the database to run locally and the problem is something different, "macros do not allow data queries that contain linked tables, action queries and database references."

This I think may be related to a configuration database that prevents access to data macros, or tables are locked but can not find anything that allows me to correct this misconception.


Microsoft Access Macros vs. VBA - Why Use Macros?
Macros have been used as development tool since the early days of the Microsoft Office product line. Microsoft Access macros incorporate generalized database functions using existing Microsoft Access capabilities. Errors in a macro can be easily resolved by using the Microsoft supplied Help function. The ease with which you can generate Macros makes Macro development seem easier to accomplish...