<!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.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=951225513-08022003><FONT face=Arial color=#0000ff size=2>Thanks
Shamil. I'm familiar with PublicNotCreatable instancing in VB6 but
haven't really touched Access Libraries. Interesting technique. So
in the calling db there's a reference to the library and I can just use the property without declaring a variable for it anywhere?
Neat.</FONT></SPAN></DIV>
<DIV><SPAN class=951225513-08022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=951225513-08022003><FONT face=Arial color=#0000ff size=2>BTW, I
finally see these messages I was having trouble with a day or more after I sent
them. Go figure.</FONT></SPAN></DIV>
<DIV><SPAN class=951225513-08022003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=951225513-08022003><FONT face=Arial color=#0000ff size=2>Jim
DeMarco</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> Shamil Salakhetdinov [mailto:shamil@smsconsulting.spb.ru]<BR><B>Sent:</B> Wednesday, February 05,
2003 6:05 PM<BR><B>To:</B> accessd@databaseadvisors.com<BR><B>Subject:</B> Re:
[AccessD] Standard vs. Class Module: RESEND<BR><BR></FONT></DIV>
<DIV><FONT face=Arial size=2><<<</FONT></DIV>
<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>
<DIV><FONT face=Arial size=2>>>></FONT></DIV>
<DIV><FONT face=Arial size=2>Jim,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>For utility classes you'd better use what is
called singleton classes/object instances:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>- let's image your custom class is called
CMyClass and it has only one method </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Public Function Test()<BR> MsgBox "TEST"<BR>End Function</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>- let's also imagine/assume that this class is
located in MS Access library database and that is has its Instancing prioperty
set to "2 - PublicNotCreatable"</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>- then you can create a standard helper module
with the following code:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Private mobjCMyClass As CMyClass</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Public Property Get CMyClass() As
CMyClass<BR> If mobjCMyClass Is Nothing Then<BR> Set
mobjCMyClass = New CMyClass<BR> End If<BR> Set CMyClass = mobjCMyClass<BR>End Property</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>- having all that you can call your custom class'
CMyClass Test method by simply using the following code
line:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>CMyClass.Test</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>- and you guaranteed to have only one instance of
your custom class during your app lifetime and you've type ahead/intellisense
while you typing your code even if your custom class is located in library
database and you don't need to type three code lines to call one utility method of your utility/generic function custom class...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Just some info on singletons and other custom
classes' usage "tricks",</FONT></DIV>
<DIV><FONT face=Arial size=2>Shamil</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=Jdemarco@hshhp.org href="mailto:Jdemarco@hshhp.org">Jim DeMarco</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=accessd@databaseadvisors.com
href="mailto:accessd@databaseadvisors.com">accessd@databaseadvisors.com</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, February 05, 2003 8:50
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> RE: [AccessD] Standard vs.
Class Module: RESEND</DIV>
<DIV><BR></DIV>
<DIV><SPAN class=716064013-05022003><FONT face=Arial color=#0000ff
size=2>Sent early AM and so sign of this one.</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></FONT></SPAN> </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">
<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
6: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><CODE><FONT
size=3><BR><BR>***********************************************************************************<BR>"This
electronic message is intended to be for the use only of the named
recipient, and may contain information from HealthSource/Hudson Health Plan
(HS/HHP) that is confidential or privileged. If you are not the intended
recipient, you are hereby notified that any disclosure, copying,
distribution or use of the contents of this message is strictly prohibited.
If you have received this message in error or are not the named recipient,
please notify us immediately, either by contacting the sender at the
electronic mail address noted above or calling HS/HHP at (914) 631-1611. If
you are not the intended recipient, please do not forward this email to anyone, and delete and destroy all copies of this message. Thank
You".<BR>***********************************************************************************<BR></BLOCKQUOTE></BLOCKQUOTE></FONT></CODE><CODE><FONT SIZE=3><BR>
<BR>
***********************************************************************************<BR>
"This electronic message is intended to be for the use only of the named recipient, and may contain information from HealthSource/Hudson Health Plan (HS/HHP) that is confidential or privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited. If you have received this message in error or are not the named recipient, please notify us immediately, either by contacting the sender at the electronic mail address noted above or calling HS/HHP at (914) 631-1611. If you are not the intended recipient, please do not forward this email to anyone, and delete and destroy all copies of this message. Thank You".<BR>
***********************************************************************************<BR>
</FONT></CODE>
</BODY></HTML>