<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1126" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=889540914-05022003>As I
have mentioned numerous times, I use a framework for my FEs. This
framework runs the app pretty much, or at least runs the form presentation side
of things. It is not a trivial application, all in itself. As a
result I have a class that does nothing but initialize the framework! As
would be expected, this class only ever loads once (in a given project) but that
class holds data structures and methods that are global to the class,
initializes my system variables, initializes the application variables etc
etc. Thus with a simple:</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=889540914-05022003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=889540914-05022003>dim
gclsFW as clsFW my framework springs to life and does everything it needs to do
to get things going. Then other code can use gclsFW.XXXX to access methods
and properties that they need to read sysvars etc.</SPAN></FONT></DIV>
<P><FONT size=2>John W. Colby<BR>Colby
Consulting<BR>www.ColbyConsulting.com</FONT> </P>
<BLOCKQUOTE>
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B>
accessd-admin@databaseadvisors.com
[mailto:accessd-admin@databaseadvisors.com]<B>On Behalf Of </B>Jim
DeMarco<BR><B>Sent:</B> Wednesday, February 05, 2003 9:01 AM<BR><B>To:</B>
accessd@databaseadvisors.com<BR><B>Subject:</B> RE: [AccessD] Standard vs.
Class Module<BR><BR></FONT></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff size=2>No
clear cut answer to this question. I normally put any code that I feel I
will reuse in a class module (by reuse I mean within the same app
only, or many apps). A couple of examples:</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff size=2>1. I
used to have a problem remembering the provider/connect string for Access and
SQL OLEDB provides used when opening an ADO connection and/or
recordset(s). I wrapped the code I use to open connections and create
recordsets in a class, cDatabase. Now when I want to use ADO I create an
object of type cDatabase, call the OpenConnection method, pass in the mdb or
SQL DB, and pass a parameter telling the class what type of db I'm using and
I've got my connection.</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2>Ex.</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2><snip></FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff size=2>Dim
oDB As cDatabase</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff size=2>Dim
rs As ADODB.Recordset</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003> <FONT face=Arial
color=#0000ff size=2>Set oDB = New cDatabase</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2> oDB.OpenConnection "mydb.mdb" 'mdb is default so we
don't have to pass optional db type argument</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2> Set rs = oDB.OpenRecordset
("mytablequeryorsql")</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2></snip></FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff size=2>I
don't have to remember or find the provider/connect string
anymore.</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff size=2>2. I
wrote some code that reads setup/configuration settings from an XML
file. Once it was done I realized I'd like to add this functionality to
more apps so I ported it into a class module. Now with no knowledge
of XML my team of developers can add this functionality to their apps by
importing the class module.</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff size=2>This
is not to say a one-off class is not out of the realm of possibility. As
J. Colby mentioned in a earlier post, if you need certain functionality in
more than one place in a single app classes make it very easy to add that
functionality without copy/paste or reviewing a code module to see "how it
works" or how to use it. </FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff size=2>We
all have stand alone functions that belong in standard modules. One
common module (here at least) is basUtil containing utility functions like
IsLoaded to check whether a form or Access object is currently open (things
not related to the function of the system). There's nothing stopping you
from putting those in a class. Why bother? Class objects implement
type ahead code functionality. Imagine then how easy it would be to
access your utility functions by calling an object of type cUtil as
follows:</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2><snip></FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff size=2>Dim
oUtil As cUtil</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2> Set oUtil = New cUtil</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2> oUtil.IsLoaded "myform"</FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2></snip></FONT></SPAN></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff size=2>I'd
normally have to take a look at basUtil to see what functionality was in there
but the class object's type ahead would alleviate that (actually, this was a
last minute thought but I think I'll give it a try!).</FONT></SPAN></DIV>
<P><FONT face=Arial><FONT size=2><SPAN
class=716064013-05022003>HTH</SPAN>,</FONT></FONT> </P>
<P><FONT face=Arial size=2>Jim DeMarco</FONT> <BR><FONT face=Arial
size=2>Director of Product Development</FONT> <BR><FONT face=Arial
size=2>HealthSource/Hudson Health Plan</FONT> </P>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"><CODE><FONT size=3><FONT
face=Arial color=#0000ff
size=2></FONT> </BLOCKQUOTE></BLOCKQUOTE></FONT></CODE></BODY></HTML>