Jump Start VBA Skills with MS Access Macros - Converting this macro to VBA code
(Page 4 of 5 )
Right click on the macro and from the drop-down click on Save As. In the dialogue, using the drop-down, change Save Macro 'MyBeep': as Module.

In the message that follows, keep the defaults and click Convert. This will add automatic error handling code block to the VBA Code as well as the comments that were inserted earlier in the designer.

This gives you an audio alert followed by a new set of screens with a congratulatory massage feed back --"Conversion Finished!" -- as shown. (The congratulatory screen was turned off for this picture).

Now you have a VBA program which does the same thing as the macro under the Project - Macro. The project window of the Microsoft Visual Basic editor has all of the Microsoft Access Class objects, modules, and class modules in the acwztool set node and the macro program that you just converted.
Let's look at what you have created now and later -- much later -- look at the other aforementioned objects. Double click Converted Macro-MyBeep, this opens up the code window as shown. As you can see, the macro was converted to a function with the same name you gave earlier for the macro. The function calls the 'beep' procedure, which does the beeping through the hardware interface. You can also see the error handling code automatically added.
The logos below the menu bar help you to switch between Access, VB editor and graphic user designer pages quite easily. You can also use the icons to run, stop or pause the macro. Please refer to earlier Access tutorials to get a good handle on the menu objects and navigational possibilities. The editor window also gives you access to all the 'debugging' tools for looking through your programs.
Another utility of great value in learning VBA is the online help. Just remember the 'F1' key. It will open up the help file at the location highlighted prior to hitting the 'F1' key. Let's highlight 'beep' and hit 'F1'. This opens up the following page which describes what 'Beep' does.

This was too easy. Let's create a slightly more elaborate macro and see a lot more of VBA in the second macro.
Next: Creating the second macro >>
More Microsoft Access Articles
More By Jayaram Krishnaswamy