Use Form Modules from exterior database

G

Gio

I have a database MyDb that have a reference with MyLibrary.mda.

MyDb contains a form MyForm

MyLibrary.mda contains a form MyDialogForm that have a form module
form_MyDialogForm

If I compile the following code in MyForm:

Private WithEvents dlg As MyLibrary.form_MyDialogForm

I receive an error:< User-defined type not defined>

How can I do to use form_MyDialogForm from an exterior database?

Thank you
 
M

Marshall Barton

Gio said:
I have a database MyDb that have a reference with MyLibrary.mda.

MyDb contains a form MyForm

MyLibrary.mda contains a form MyDialogForm that have a form module
form_MyDialogForm

If I compile the following code in MyForm:

Private WithEvents dlg As MyLibrary.form_MyDialogForm

I receive an error:< User-defined type not defined>

How can I do to use form_MyDialogForm from an exterior database?


I don't think you can do that declaration because Access
doesn't expose class objects in a library. If that's really
what you need to do, then use a public procedure in the
library to declare/create the object.

You can open a form in the library by using a public
procedure in the library. The procedure only needs to use
the OpenForm method, but you may have to do some fooling
around if the form's dataset includes a table in MyDb.
 
G

Gio

Can do.
Seehttp://www.mvps.org/access/modules/mdl0034.htmon howto make classses in
library forms publicly createable

Pieter


Gio wrote:
I don't think you can do that declaration because Access
doesn't expose class objects in a library. If that's really
what you need to do, then use a public procedure in the
library to declare/create the object.
You can open a form in the library by using a public
procedure in the library. The procedure only needs to use
the OpenForm method, but you may have to do some fooling
around if the form's dataset includes a table in MyDb.

Thank you very much Marsh and Pieter: problem solved.
I learn this:
1) Is not possible use a Form Module as a class object from exterior
database without subclassing it.
2) To SEE a class object from exterior database, in Access 2007 is
necessary to set the Class property 'Istancing' (F4 to access to it)
to 'PublicNotCreatable'
3) To USE a class object from exterior database, is necessary to
create a function that istancialize the class in the DB where it
belong and then use this function in exterior DB to get the class
object.
If anyone need help ask, I will do my best.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top