Module vs Macro?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am very much a novice. I am trying to learn how to program my database, and I have a question, (probably a dumb one to y'all), but need to know before I continue. Could someone tell me why a module would be better than a macro? I have quite a few macros performing tasks now. As far as I have gotten so far, macro and module seem to do the same things??

I appreciate any input. Thanks

Helen
 
The primary issue with macros is that errors are not handled. If you are
developing a database that will be or may be used by others, that is a big
problem. Macros also have less capability...you can do a lot more in code,
i.e., create objects, se recordsets, etc.. There isn't any good way to
document macros...i.e., you can put comments in code explaining why
something is being done.

Do yourseleft a favor and avoid using macros...you be better off in the long
run.

--
Paul Overway
Logico Solutions, LLC
www.logico-solutions.com


Helen Allen said:
I am very much a novice. I am trying to learn how to program my database,
and I have a question, (probably a dumb one to y'all), but need to know
before I continue. Could someone tell me why a module would be better than
a macro? I have quite a few macros performing tasks now. As far as I have
gotten so far, macro and module seem to do the same things???
 
Helen,

There is nothing wrong with using Macros; they have been available in Access
since its earliest versions. Macros are one reason why MS Access is so
popular with non-programmers - they can have their databases perform
functions without knowing how to write VBA code. Modules (or more
specifically the VBA code in them) is why Access has become so popular among
developers - it is possible to perform some extremely sophisticated,
complicated processes in Access using VBA code, Windows API calls, etc.

One reason why many programmers recommend against macros is that, over time,
a successful database will need to have additional functionality or
processes added to it - simply because users like the database and want it
to do more! At some point, the processes in the database become more
sophisticated and the number of actions performed by the macros start
increasing. Often, that is where the trouble starts because, if a process
run by a macro with multiple actions fails, it can be difficult to
next-to-impossible to debug it. With code in a module, one can determine
exactly the line which has failed which makes it much easier to find and fix
problems. Also, I think it is safe to say that there are things that one
can do with code that cannot be done with a macro.



--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Helen Allen said:
I am very much a novice. I am trying to learn how to program my database,
and I have a question, (probably a dumb one to y'all), but need to know
before I continue. Could someone tell me why a module would be better than
a macro? I have quite a few macros performing tasks now. As far as I have
gotten so far, macro and module seem to do the same things???
 
In addition to the other fine comments,

My first database (Access 1.1) was all macro driven.
Code was "scary".
Once you realize that "logic is logic" you should be comfortable writing
code.
As you said, they do the same thing (to a point).

So begin learning code and graduate to the ranks of developer.
Hint - use a wizard and read the code from top to bottom.
If you jump over a blcok of code an error handler?) then ask why. There is a
good reason!
Once you "get it" it isn't so bad .
--
Joe Fallon
Access MVP



Helen Allen said:
I am very much a novice. I am trying to learn how to program my database,
and I have a question, (probably a dumb one to y'all), but need to know
before I continue. Could someone tell me why a module would be better than
a macro? I have quite a few macros performing tasks now. As far as I have
gotten so far, macro and module seem to do the same things???
 
Thanks all, very helpful. Question for Joe, you said: "Hint - use a wizard and read the code from top to bottom." What Wizard? Where do I find it? The regular Access Wizards do not cover Code in my version. Thanks!
 
Helen Allen said:
Thanks all, very helpful. Question for Joe, you said: "Hint - use a
wizard and read the code from top to bottom." What Wizard? Where do I
find it? The regular Access Wizards do not cover Code in my version.
Thanks!

When you use the command button wizard to create a button (for example)
that opens a report the wizard is assigning a coded procedure to that
button for you. You can examine that code afterwards to see what is going
on.

The only problem is that the code written by the wizards sucks for the most
part. It can get you started though.
 
Back
Top