VBA and Macros - MS Access

Access has grown up with two different approaches to programming: using macros and using VBA programming code. Macros are designed to be an easy to use programming environment in which people without VBA programming skills can add functionality to an application. Although macros are easy to use, managing macro code, debugging the code, and error handling are more challenging. Although error handling for macros in Access 2010 has been vastly improved, and debugging using local and temporary variables has been added, it is unlikely that these enhancements alone will encourage those using VBA to move away from the standard. Access 2010 has received a significant reworking of the Macro Editor and the macro environment, which includes the addition of Data Macros and support for macro programming in web objects (where VBA is not supported).

Access Basic

Access started out with a language called Access Basic, which evolved from the even more primitive language of BASIC. VBA was a later step that was initially incorporated into Excel and then extended into the other Microsoft Office products.

Because VBA needs to be universal to the entire Office family of products, it cannot incorporate directly all the features of Access into the language. This is why some of the most commonly encountered actions in Access, such as opening a form, do not have an obvious VBA function but use the DoCmd object.

Converting Macros to VBA

Macros can be converted to VBA. To do this, locate the macro in the Navigation window, and then on the File tab, in BackStage view, save the object as VBA code, as shown in Figure.

Converting a macro to VBA code.

Converting a macro to VBA code.

When converting the macro, you are also given options to add error handling and include macro comments.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

MS Access Topics