Converting Access macros to VBA

Microsoft Access contains two main ways of automating non-trivial tasks: macros and Visual Basic for Applications. The former is an Access specific way of building up multiple commands to be run on your database in what is probably a relatively easy way if you just need a simple task doing. The latter is a programming language that you can use throughout the Microsoft Office suite and beyond. Harder to learn, but infinitely more flexible and useful. So much so that rumours had been heard that at some point macros will be phased out of Access.

Not yet though. Nonetheless, to the more conventional programmers they may be fairly cryptic and are certainly limited in scope. So what happens if you inherit an old-skool database full of macros but you want to speak VBA?

Well it so happens that many of the macro functions are directly available in VBA, using the docmd object. You certainly can replicate the effects of any macros in VBA. Better yet, get Access to do it for you. It actually turns out to be trivial to get Access to convert your macros into full-on VBA code.

Simply press F11 to get to the database window if you're not already there. Click on the macros section to see a list of all your macros. Right click on the macro you wish to convert and click Save As. Drop down the "As what?" box to reveal "Module". Choose out of the couple of simple options it gives you and hit OK. Wham bam there you go: the VBA equivalent of your macro, readable and editable to your heart's content.


Comments

thx

thanks very much for your information, it is very useful for me ....

i will always check back...

:)