Code Library and Class Modules 
Author Message
 Code Library and Class Modules

Having developed quite a few functions and procedures that I use everywhere
I finally decided it was time to get these into a library. This seemed
simple enough but I have run into one obstacle. I have a Class Module that I
wanted to be available in the library but it does not show up in the Object
Browser - all of my other functions and procedures are there.

What do I have to do to make a custom class available from a library. This
class does not use forms, it is just used for saving and handling a
particular set of data.

I'm using Office2000 Developer.

Thanks.

--
Sandra Daigle



Tue, 05 Mar 2002 03:00:00 GMT  
 Code Library and Class Modules
There is no supported way of doing this, since there is no
way in VBA or VBE to create a class that is "public
createable." There is an unsupported workaround....

http://www.mvps.org/access/modules/mdl0034.htm

Although it claims that Steve Arbaugh pointed it out, AFAIK
Ken Getz was the first person to point it out, after I
mentioned the idea to him on the phone.

Oh well, I only expect credit for 10% of the things I do.
:-)

--
MichKa

-------------------------------------
don't send questions by e-mail unless
you're paying for it. (TANSTAAFL!) :-)

random junk of dubious value and
replica error and problem fixing at:
http://www.trigeminal.com


Quote:
> Having developed quite a few functions and procedures that
I use everywhere
> I finally decided it was time to get these into a library.
This seemed
> simple enough but I have run into one obstacle. I have a
Class Module that I
> wanted to be available in the library but it does not show
up in the Object
> Browser - all of my other functions and procedures are
there.

> What do I have to do to make a custom class available from
a library. This
> class does not use forms, it is just used for saving and
handling a
> particular set of data.

> I'm using Office2000 Developer.

> Thanks.

> --
> Sandra Daigle



Tue, 05 Mar 2002 03:00:00 GMT  
 Code Library and Class Modules
Thanks Michael,

I've attempted to use this solution and it does give me partial success. I
used the second method and attempted to expose the class to VBA by change
the VB_Exposed attribute to True. This did allow me to see the class in the
object browser and to create a single instance of it - but only one
instance.

Is there a way to allow multiple instancing of this class?

I might also add that in the text file created, there were the following
lines at the beginning of the module:

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END

These were not removed when I inserted the text file into a new module and
they triggered compile errors.  The MultiUse line sort of sounds like it
might have something to do with instancing but I don't know how to work it
in so that VBA will allow it.

Why is this so difficult? It seems like the capability to use a library
database should include classes, which are supposedly (and IMHO are) a great
strength of VB.

As a side question, if I abandon the library approach for the class module,
could I create an Object library for it using VBA. Is this going to be
getting me in over my head?

I appreciate your help.

Sandra Daigle

Quote:
> --
> MichKa

> -------------------------------------
> don't send questions by e-mail unless
> you're paying for it. (TANSTAAFL!) :-)

> random junk of dubious value and
> replica error and problem fixing at:
> http://www.trigeminal.com



> > Having developed quite a few functions and procedures that
> I use everywhere
> > I finally decided it was time to get these into a library.
> This seemed
> > simple enough but I have run into one obstacle. I have a
> Class Module that I
> > wanted to be available in the library but it does not show
> up in the Object
> > Browser - all of my other functions and procedures are
> there.

> > What do I have to do to make a custom class available from
> a library. This
> > class does not use forms, it is just used for saving and
> handling a
> > particular set of data.

> > I'm using Office2000 Developer.

> > Thanks.

> > --
> > Sandra Daigle



Tue, 05 Mar 2002 03:00:00 GMT  
 Code Library and Class Modules
Well I've temporarily worked this out, using both of the methods referred to
on Dev's Web site. I used the text file export and import to expose the
class, then I also created a public function which returns a new instance of
the class. It compiles but I've yet to discover whether it really works b/c
of other new problems.

This seemed like a good idea a couple of hours ago, now I'm wondering
whether it's going to be too kludgey to support.

Having developed only stand-alone Access applications, and always copying
modules back and forth I'm becoming frustrated with the effort required to
maintain a single working copy of my shared code --- you know the
routine --- make an enhancement to a function in Database A, forget to
change it or copy it into database B. Then 2 weeks later I end up scratching
your head and wondering "where did it go?". Usually it's no big deal to fix
it then but it is an unnecessary annoyance.

Do I need to have the full blown version of VB so that I can create DLLs or
some such something like that? This sounds like a stupid question (but
having stayed pretty much in VBA for Access I'm not fully up-to-speed here),
but from Access, can I call code from DLLs? Is this the way to go to create
real code libraries?

How else can I or should I go about maintaining my shared code?

Thanks for your help.

Sandra Daigle



Tue, 05 Mar 2002 03:00:00 GMT  
 Code Library and Class Modules

Quote:
> Then 2 weeks later I end up scratching
> your head and wondering "where did it go?". Usually it's no big deal to
fix
> it then but it is an unnecessary annoyance.

I hope no one wonders why I end up scratching YOUR head :)

Figured I'd catch that one before some one else does!



Tue, 05 Mar 2002 03:00:00 GMT  
 Code Library and Class Modules
Take a look at this page
http://ourworld.compuserve.com/homepages/attac-cg/Aobject.htm. They have a
procedure there that will let you "Make class modules in a library database
visible to other databases"

--
HTH/EQTA
Mario Osorio
--
You'll find good answer to common
and not so common questions
at Dev Ashish's site. <=>
Ud. encontrar buenas respuestas
a preguntas comunes y no tan
comunes en la pgina de
Dev Ashish:
http://www.mvps.org/access
--
--



: Having developed quite a few functions and procedures that I use
everywhere
: I finally decided it was time to get these into a library. This seemed
: simple enough but I have run into one obstacle. I have a Class Module that
I
: wanted to be available in the library but it does not show up in the
Object
: Browser - all of my other functions and procedures are there.
:
: What do I have to do to make a custom class available from a library. This
: class does not use forms, it is just used for saving and handling a
: particular set of data.
:
: I'm using Office2000 Developer.
:
: Thanks.
:
: --
: Sandra Daigle
:
:



Tue, 05 Mar 2002 03:00:00 GMT  
 Code Library and Class Modules
I think such things are better in a VB ActiveX DLL that you
can reference from Access. Since public createable objects
are not really supported in VBA, any bug you hit, you're
stuck with.

--
MichKa

-------------------------------------
don't send questions by e-mail unless
you're paying for it. (TANSTAAFL!) :-)

random junk of dubious value and
replica error and problem fixing at:
http://www.trigeminal.com


Quote:
> Well I've temporarily worked this out, using both of the
methods referred to
> on Dev's Web site. I used the text file export and import
to expose the
> class, then I also created a public function which returns
a new instance of
> the class. It compiles but I've yet to discover whether it
really works b/c
> of other new problems.

> This seemed like a good idea a couple of hours ago, now
I'm wondering
> whether it's going to be too kludgey to support.

> Having developed only stand-alone Access applications, and
always copying
> modules back and forth I'm becoming frustrated with the
effort required to
> maintain a single working copy of my shared code --- you
know the
> routine --- make an enhancement to a function in Database
A, forget to
> change it or copy it into database B. Then 2 weeks later I
end up scratching
> your head and wondering "where did it go?". Usually it's
no big deal to fix
> it then but it is an unnecessary annoyance.

> Do I need to have the full blown version of VB so that I
can create DLLs or
> some such something like that? This sounds like a stupid
question (but
> having stayed pretty much in VBA for Access I'm not fully
up-to-speed here),
> but from Access, can I call code from DLLs? Is this the
way to go to create
> real code libraries?

> How else can I or should I go about maintaining my shared
code?

> Thanks for your help.

> Sandra Daigle



Tue, 05 Mar 2002 03:00:00 GMT  
 Code Library and Class Modules
Thanks Michka,

I guess I need to step up to the VB world and learn how to create an ActiveX
DLL. Over the last few years I learned how to create classes and began to
see how they would simplify so many repetetive tasks for programming  the UI
for Access. Now I really depend on my classes and I've got to find a way
improve my code maintenance practices.

How hard is it to learn how to create an ActiveX DLL?

Thanks for your help.

Sandra Daigle



Tue, 05 Mar 2002 03:00:00 GMT  
 Code Library and Class Modules
Its actually pretty easy. When VB first starts the opening
dialog lets you choose project type.... choose "ActiveX dll"
and it will start you off with a class.... just add the code
you want to it and compile it and you're there. :-)

You can get as complicated as you like from there....

--
MichKa

-------------------------------------
don't send questions by e-mail unless
you're paying for it. (TANSTAAFL!) :-)

random junk of dubious value and
replica error and problem fixing at:
http://www.trigeminal.com


Quote:
> Thanks Michka,

> I guess I need to step up to the VB world and learn how to
create an ActiveX
> DLL. Over the last few years I learned how to create

classes and began to
Quote:
> see how they would simplify so many repetetive tasks for
programming  the UI
> for Access. Now I really depend on my classes and I've got
to find a way
> improve my code maintenance practices.

> How hard is it to learn how to create an ActiveX DLL?

> Thanks for your help.

> Sandra Daigle



Tue, 05 Mar 2002 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Using class modules in a code library

2. Q: Code Module vs UserControl (Form, Class) module.

3. Q: Code Module vs UserControl (Form, Class) module.

4. Q: Code Module vs UserControl (Form, Class) module.

5. Class modules 97 - Refering to array within a custom class module

6. Useing Class modules in Library mda

7. Accessing procedures of a class module from another class module

8. Binary compatibility, Public Class, Name conflicts with existing module, project, or object library

9. Code / Class libraries for VB5...?

10. Create class module with code

11. Classes/Code modules: Difference, when and why etc..

12. My Code Gen - vb thinks class files are modules

 

 
Powered by phpBB® Forum Software