<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content=Word.Document name=ProgId>
<META content="MSHTML 6.00.2800.1170" name=GENERATOR>
<META content="Microsoft Word 10" name=Originator><LINK
href="cid:filelist.xml@01C32BD2.498F7210" rel=File-List><!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:DoNotRelyOnCSS/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:SpellingState>Clean</w:SpellingState>
<w:GrammarState>Clean</w:GrammarState>
<w:DocumentKind>DocumentEmail</w:DocumentKind>
<w:EnvelopeVis/>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<STYLE>@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.25in 1.0in 1.25in; mso-header-margin: .5in; mso-footer-margin: .5in; mso-paper-source: 0; }
P.MsoNormal {
FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"; mso-style-parent: ""; mso-pagination: widow-orphan; mso-fareast-font-family: "Times New Roman"
}
LI.MsoNormal {
FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"; mso-style-parent: ""; mso-pagination: widow-orphan; mso-fareast-font-family: "Times New Roman"
}
DIV.MsoNormal {
FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"; mso-style-parent: ""; mso-pagination: widow-orphan; mso-fareast-font-family: "Times New Roman"
}
A:link {
COLOR: blue; TEXT-DECORATION: underline; text-underline: single
}
SPAN.MsoHyperlink {
COLOR: blue; TEXT-DECORATION: underline; text-underline: single
}
A:visited {
COLOR: purple; TEXT-DECORATION: underline; text-underline: single
}
SPAN.MsoHyperlinkFollowed {
COLOR: purple; TEXT-DECORATION: underline; text-underline: single
}
SPAN.EmailStyle17 {
COLOR: windowtext; FONT-FAMILY: Arial; mso-style-type: personal-compose; mso-style-noshow: yes; mso-ansi-font-size: 10.0pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial
}
SPAN.SpellE {
mso-style-name: ""; mso-spl-e: yes
}
SPAN.GramE {
mso-style-name: ""; mso-gram-e: yes
}
DIV.Section1 {
page: Section1
}
</STYLE>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]--></HEAD>
<BODY lang=EN-US style="tab-interval: .5in" vLink=purple link=blue>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff
size=2>Bob,</FONT></SPAN></DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff
size=2>Classes built directly in a library database are not visible outside of
the library in VBA. No Se Por Que. I guess that since
Microsoft considers VBA developers to be children, giving us such
powers is considered dangerous - kinda like playing with knives or matches I
suppose. At any rate, it absolutely is possible to get your classes
exposed such that they can be seen and used outside of the
library.</FONT></SPAN></DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff size=2>The
easiest way to do this is to:</FONT></SPAN></DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff size=2>1)
Export the class to a text file.</FONT></SPAN></DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff size=2>2)
Open the class module with a text editor</FONT></SPAN></DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff size=2>3)
Look for two attributes at the top of the module. Change Creatable and
Exposed to True.</FONT></SPAN></DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff size=2>4)
Save the class and close the text file.</FONT></SPAN></DIV>
<DIV><SPAN class=306273411-06062003></SPAN><SPAN class=306273411-06062003><FONT
face=Arial color=#0000ff size=2>5) In your library, click Insert / Class
module</FONT></SPAN></DIV>
<DIV><SPAN class=306273411-06062003></SPAN><SPAN class=306273411-06062003><FONT
face=Arial color=#0000ff size=2>6) In the editor window that opens, click Insert
/ File. Navigate to and select the txt file that you saved the class
in. This will cause Access to pull in the contents of whatever file you
selected and insert it in your class. In this case it is the contents of
the modified class.</FONT></SPAN></DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff size=2>7) At
the top of the class you will see something like:</FONT></SPAN></DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff size=2>Option
Compare Database<BR>Option Explicit</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff
size=2>VERSION 1.0 CLASS<BR>BEGIN<BR> MultiUse = -1
'True<BR>End<BR>Option Compare Database<BR>Option Explicit</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff size=2>Select
and delete everything from the first Option down through the
End.</FONT></SPAN></DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff size=2>8)
Compile and save the class</FONT></SPAN></DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=306273411-06062003><FONT face=Arial color=#0000ff size=2>The
class will now be visible from any database that references your
library.</FONT></SPAN></DIV>
<P><FONT size=2>John W. Colby<BR>www.colbyconsulting.com</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>
accessd-bounces@databaseadvisors.com
[mailto:accessd-bounces@databaseadvisors.com]<B>On Behalf Of </B>Bob
Bedell<BR><B>Sent:</B> Friday, June 06, 2003 2:22 AM<BR><B>To:</B>
accessD@databaseadvisors.com<BR><B>Subject:</B> [AccessD] Where does
WithEvents go?<BR><BR></FONT></DIV>
<DIV class=Section1>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">I hope I can make this intelligible. Info on this
issue seems a bit sparse. I have a custom class and a form that work fine
together. The class declares a custom event using Public Event syntax in the
general declaration and Raise syntax in a method. The calling class (the form)
declares a private instance of the class using <SPAN
class=SpellE>WithEvents</SPAN> and instantiates it. No
problems.<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">Now I’m trying to import the class into a library
(<SPAN class=SpellE>mda</SPAN>.) and set a reference to it in the database
that contains the calling form. It’s my understanding that my calling
application can’t instantiate the class directly, and needs to use a wrapper
function. So I added a standard module to the calling application that calls a
function in the library database which returns a copy of the object. The
calling database then has a public, shared copy of the object to work with.
The standard module in the calling database is:<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">Public <SPAN class=SpellE>g_oInventory</SPAN> <SPAN
class=GramE>As</SPAN> <SPAN
class=SpellE>clsInventory</SPAN><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">Public Sub <SPAN
class=GramE>Startup()</SPAN><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes">
</SPAN><SPAN class=GramE>' Get</SPAN> handles to shared
objects<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes">
</SPAN>Set <SPAN class=SpellE>g_objInventory</SPAN> = <SPAN
class=SpellE>GetclsInventory</SPAN><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes">
</SPAN><SPAN class=SpellE>DoCmd.OpenForm</SPAN> "<SPAN
class=SpellE>frmInventory</SPAN>"<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">End Sub<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">The standard module in the library database (where the
class is located) is:<BR style="mso-special-character: line-break"><![if !supportLineBreakNewLine]><BR
style="mso-special-character: line-break"><![endif]><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">Public Function <SPAN class=SpellE><SPAN
class=GramE>GetclsInventory</SPAN></SPAN><SPAN
class=GramE>()</SPAN><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes">
</SPAN>Dim <SPAN class=SpellE>objInventory</SPAN> <SPAN class=GramE>As</SPAN>
<SPAN class=SpellE>clsInventory</SPAN><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes">
</SPAN>Set <SPAN class=SpellE>GetclsInventory</SPAN> = New <SPAN
class=SpellE>clsInventory</SPAN><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">End Function<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">Here’s my problem. Using the library scenario, I can’t
find any place to put my <SPAN class=SpellE>WithEvents</SPAN> statement. The
old declaration (before <SPAN class=SpellE>seperating</SPAN> the class and the
form) was in the forms general declaration:<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">Private <SPAN class=SpellE>WithEvents</SPAN> <SPAN
class=SpellE>m_objProduct</SPAN> <SPAN class=GramE>As</SPAN> <SPAN
class=SpellE>clsInventory</SPAN><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes"> </SPAN>But now
(library scenario) the declaration needs to be global, needs to include <SPAN
class=SpellE>WithEvents</SPAN>, and needs to be in a class or form module
(<SPAN class=SpellE>WithEvents</SPAN> won’t work in a standard
module).<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">Should I do a VB ActiveX component instead? <SPAN
class=GramE>I’m <SPAN class=SpellE>kinda</SPAN>’ at a loss here.</SPAN> <SPAN
class=GramE>Real limited experience with classes/libraries stuff.</SPAN>
Thanks to anyone who can make heads or tails of
that.<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">Bob<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P></DIV></BLOCKQUOTE></BODY></HTML>