Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA vs Macros - pros and cons?

Status
Not open for further replies.

jazminecat

Programmer
Jun 2, 2003
289
US
Hi all - I'm looking for some input on updating a database we have. I didn't build it, and the developer used a lot of macros. I use VBA almost exclusively. I seem to remember hearing at one point that access wasn't going to support macros in an upcoming version - that was some time ago - is there any truth to this and if so, what's the story.

Are there any advantages to keeping the macros, or does vba run faster, cleaner, etc? Just trying to get the big picture, so that we can decide if converting all these macros to vba is something we need to do or not, and why. Thanks!!
 
IMHO, Macros have two big disadvantages; they're no where near as flexible as VBA and there is no error checking possible in Macros! Hands down, VBA is the way to go!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Your instinct is right. Get rid of the macros. The advantages of macros are these:

1. Less Flexible
2. No Error Handling
3. People with little or no knowledge of what's happening can open them up and muck things up for you.

VBA is far far FAR superior. As you are already using VBA, there is no sense in writing new macros

Depending how many they are, you might not need to re-write, but every time one needs modification I would re write it as a VBA routine if possible.


Oh yeah, the only real advantage I see for macros is that they can be set to automatically run.

Hope this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Forgot to add, there is a built in function for converting Macros to VBA code: Tools > Macros > Convert Macros to VBA.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Agree with the above sentiments, there are no "Pros" to using macros.

 
From the context, I'm pretty sure Alex meant to say disadvantages of macros. I agree with all of the above.

Some one here said:
Friends don't let friends use macros!

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
How are ya jazminecat . . .

The only macro I've ever used is [blue]AutoExec[/blue] and thats because VBA doesn't have an eqivalent counterpart. Now isn't that something . . . [blue]macro's have one thing VBA does not![/blue]

TheAceMan1 said:
[blue]I believe its the much greater control we have over what we do with our code that makes VBA the only way to fly! . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
In addition to the AceMan's proviso about the AutoExec macro, I would add that the AutoKeys macro can also be useful for creating custom shortcut keys (read more here).

Other than that, it's VBA all the way.... unless you're using a really old version of Access (97 and below) in which case you need to make sure any custom menus aren't based on macros, as that's how they were done back then.

Basically, if you're using A2000 and above, you should never need more than at most 2 macros - AutoExec and AutoKeys.
 
Yes, I did mean disadvantages. I was just telling a friend last night that maybe one day Al Gore will invent an internet that can properly convey sarcasm (can you tell this one gets me a lot ;-) )

Ignorance of certain subjects is a great part of wisdom
 
Excellent! Thanks for all the responses here. I really appreciate and value the opinions on this site, and this reinforced what I was already suspecting. Thanks all!
 
on the other hand, in some cases we all use "Macros", albeit implicitly in the "DOCmd.*" ... even the ubiquitous "Help" command tells you this ...




MichaelRed


 
Access 2007 introduces error handling in macros...
Far too late, in my opinion...
I'll NEVER use macros again, except for AutoKeys - when needed.
AutoExec can be skipped by Startup Options...
The reason for not having a VBA AutoExec is the 'security' fears of M$

And...friends indeed don't let friends use macros...

HTH

[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top