Why use modules

G

Guest

Hi all,

Can someone point me to information or give me an idea as to the
advantages/diadvantages of using modules in my Access database. I've done a
reasonable amount of coding for forms and events and while researching some
information on automating outlook messages, tasks and reminders I'm trying to
work out the dos and don'ts on using modules or can I just code this in to
the cmdSave button which will be saving the information I need to put into
the email messages. Also is there a naming convention Module 1 doesn't seem
to informative.

Thanks in advance
 
G

Guest

As far as naming I like to start my modules with mod and then a fitting
description of what is inside unless it is a class module then cls works
good. There always seems to be a need for at least one module to store Public
Functions and Global Variables if nothing else... so these would go into
modFunctions etc... If you have a lot of functions and routines of a specific
nature then you may choose to place them in their very own module such as
modAccounting would contain the common functions for all of your accounting
forms or a specific process etc... and then there are Class Modules Hope
this helps! Take Care & God Bless ~ SPARKER ~
 
D

David C. Holley

1. How you name your subs, functions, variables, modules, children is
entirely up to you, however keep in mind what my old prof used to say -
"The true cost of software developement is NOT how much is costs to
bring the application online, it is how much it costs to debug or revise
the code afterward." The point being that at some point you or someone
else is going to have go into your code and understand what it does. To
that end, name everything in such a manner that its clear as to what it
does. (I personally use prefixes to my field names & variables to
indicate the type as in txtName tells me that the field is a TEXT type.
lngTransportId tells me that the variable is DIM'd as LONG.)

2. The decision to spin out a procedure from an object's module to a
free standing module depends on its purpose and expected use. I for one
have a module named OUTLOOK FUNCTIONS that contains all my
subs/functions that are my Access-Outlook interface. Although the subs
are only called from one specific form, I wrote them in a manner so that
they can be called from any form. I did that to make things easier if I
needed to call them from other forms.

3. Now that I think of it, I've gotten into the habit that the only code
in my forms/objects is code that is specific to those objects (requery a
control, calling subs that need to run on form events, etc.). All others
(form validation, Outlook/Word automation, functions, etc.) are in
modules to allow for flexibility.

4. Never name your
 
M

Marshall Barton

Teewan said:
Can someone point me to information or give me an idea as to the
advantages/diadvantages of using modules in my Access database. I've done a
reasonable amount of coding for forms and events and while researching some
information on automating outlook messages, tasks and reminders I'm trying to
work out the dos and don'ts on using modules or can I just code this in to
the cmdSave button which will be saving the information I need to put into
the email messages. Also is there a naming convention Module 1 doesn't seem
to informative.


In addition to the reasons others have provided. It is
important to note that public functions in a standard module
are the only VBA items that are accessible just about
everywhere (SQL, control source expressions, toolbar
buttons, form/report modules, ...)
 
L

Larry Linson

Can someone point me to information
or give me an idea as to the advantages/
diadvantages of using modules in my
Access database.

You use modules to contain variables, constants, and procedures. You have
been using the class Modules associated with Forms and Reports, apparently,
for this purpose. But if you have any of the above that need to be
accessible beyond just one Form or one Report, you will need the separate
Modules, in Access' terminology Standard Modules to contain those. There are
also Class Modules, but I don't think that is what you were asking about --
you'd use those if you wrote some of your own Classes.
Also is there a naming convention Module 1
doesn't seem to informative.

The most widely-used and most widely-accepted naming convention for Access
is the Reddick VBA Naming Convention. You'll find it detailed in Greg
Reddick's website, http://www.xoc.net. Old timers tend to use the prefix
"bas" (for Basic code) before module names, others may use an alternative.

Larry Linson
Microsoft Access MVP
 
G

Guest

Hi guys,

Please accept my belated thanks and rest assured your responses haven't gone
unnoticed. Just took me some time to get back to this particular question.

Cheers
Teewan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top