<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Message</TITLE>
<META content="MSHTML 6.00.2722.900" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2>Hmmmm.....good question. </FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff size=2>Let's
start with the basics. A standard module is a flat code page. It can
house code, store global variables, and can house callback
functions. The main portion of that is it can house code. You
can put all of the functions and subs within it that you would like, however,
that is all they are, functions and subs, and thus a standard module is
relatively 'unorganized'.</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff size=2>A
Class module is a code 'object'. Being an object allows the Class module
to have properties and procedures. The code within is the same (language
wise), but now you have an organized set of code.</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2>Examples where a Standard Module is useful.</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2>modOSMachineName</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff size=2>That's
the name of a module I have which gives you the name of the computer you are
on. It's a simple API call.</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2>modOSUserName</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff size=2>Same
as above, but it provides the NT Username of the person logged onto a
computer.</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff size=2>Can
these be put into a class? Yes they can. However, they are just as
organized in their own modules. Putting them into a class would be useful
as a 'Environment' object:</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff size=2>Dim
env as Environment</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff size=2>set
env = New Environment</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2>debug.print env.MachineName</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2>debug.print env.UserName</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2>However, if you just want the computer name, here and there, instead of
creating a class object, just to use one property, then it would be better as
it's own function in a module:</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2>debug.print fOSMachineName</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2>Examples where a Class Module is better:</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff size=2>This
list would be huge, because when you really dig into Class modules, you will
find that they are so much nicer to use. However, I have a specific one
that I would have liked to use back when I was doing heavy Access FE
development.</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff size=2>Way
back when, I liked to control the 'toggle' keys on the keyboard. (Numlock,
CapsLock and ScrollLock). What I used to do, was have a module that had a
function to set a toggle key oneway or the other, and another function to just
'check' the state. What I should have done, is create a Keyboard Class, or
Toggle class, and have that class 'represent' the toggle keys on the
keyboard. That way I would be able to 'control' the keyboard toggles as an
object, instead of using multiple functions.</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2>Drew</FONT></SPAN></DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=543243702-04022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Myke Myers
[mailto:mmmtbig@bellsouth.net]<BR><B>Sent:</B> Monday, February 03, 2003 5:44
PM<BR><B>To:</B> accessd@databaseadvisors.com<BR><B>Subject:</B> [AccessD]
Standard vs. Class Module<BR><BR></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=859564123-03022003>Can anyone
describe how to determine when to use a standard module and when to use a
class module in Access?</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=859564123-03022003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=859564123-03022003>TIA Myke</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BLOCKQUOTE></BODY></HTML>