Reference a module in a remote database?

  • Thread starter Margaret Bartley
  • Start date
M

Margaret Bartley

I'm opening a remote Access database and reading each module in it. This
works. What I'd like to do now is open each module to get at the module
properties.

The following code snippet works to list the modules in a connected
database:

Set cntModule = LookupDB.Containers("modules")
For Each docModule In cntModule.Documents
debug.print "Module: " & docModule.Name
Next docModule


What I'd like to do next is open an module object: in that remoted database:

Set cntModule = LookupDB.Containers("modules")
For Each docModule In cntModule.Documents
debug.print "Module: " & docModule.Name
DoCmd.OpenModule docModule.Name
Next docModule

But I get the run-time error '2516': Microsoft Office Access can't find the
module 'Convert ISBNs.' [the name of the module in the remote database]

I'm assuming the reason I get this error is because the syntax I'm using is
causing the interpreter to look in the CurrentDB, which does not contain the
module called "Convert ISBNs", instead of the remote db, which does.

So, how do I reference a module in a connected database?

Thank you.
 
D

david

You have to open the remote module in an Access Application
object. This will cause an autoexec macro or startup form to
run, so it can be tricky.

Or, if you are brave, you can load the remote database as a
reference. This may cause your application to fail if there are
problems with the remote database. Also, it is tricky (but not
impossible) to work with modules in a referenced database,
because the implementation was broken in A2000, and never
fixed.

(david)
 
M

Margaret Bartley

Do you know if there is a way to load a remote databse as a reference in VBA
code?

When you say that it is tricky to work with a "referenced database", do you
mean a database that has been loaded as a reference (as above), or a
database that has been dimmed in the procedure as a database in an new
instance of an Access Application?

Were you saying that I needed to create a new instance of the Access
Application for every database that I want to examine the module properties?

david said:
You have to open the remote module in an Access Application
object. This will cause an autoexec macro or startup form to
run, so it can be tricky.

Or, if you are brave, you can load the remote database as a
reference. This may cause your application to fail if there are
problems with the remote database. Also, it is tricky (but not
impossible) to work with modules in a referenced database,
because the implementation was broken in A2000, and never
fixed.

(david)

Margaret Bartley said:
I'm opening a remote Access database and reading each module in it. This
works. What I'd like to do now is open each module to get at the module
properties.

The following code snippet works to list the modules in a connected
database:

Set cntModule = LookupDB.Containers("modules")
For Each docModule In cntModule.Documents
debug.print "Module: " & docModule.Name
Next docModule


What I'd like to do next is open an module object: in that remoted
database:

Set cntModule = LookupDB.Containers("modules")
For Each docModule In cntModule.Documents
debug.print "Module: " & docModule.Name
DoCmd.OpenModule docModule.Name
Next docModule

But I get the run-time error '2516': Microsoft Office Access can't find
the module 'Convert ISBNs.' [the name of the module in the remote
database]

I'm assuming the reason I get this error is because the syntax I'm using
is causing the interpreter to look in the CurrentDB, which does not
contain the module called "Convert ISBNs", instead of the remote db,
which does.

So, how do I reference a module in a connected database?

Thank you.
 
D

david

It's tricky either way: tricky in a separate Access Application
because of the possible problems with startup code, tricky
in a VBA reference because of the difficulty working with
modules in the referenced database.

To add a module as a reference, you use
application.References.AddFromFile


If you use a separate Access Application object, you would
not typically create a new object for every database: you
would look at them sequentially using
obj.NewCurrentDatabase
and
obj.CloseCurrentDatabase

But you can create a new object for each if you want to.

(david)

Margaret Bartley said:
Do you know if there is a way to load a remote databse as a reference in
VBA code?

When you say that it is tricky to work with a "referenced database", do
you mean a database that has been loaded as a reference (as above), or a
database that has been dimmed in the procedure as a database in an new
instance of an Access Application?

Were you saying that I needed to create a new instance of the Access
Application for every database that I want to examine the module
properties?

david said:
You have to open the remote module in an Access Application
object. This will cause an autoexec macro or startup form to
run, so it can be tricky.

Or, if you are brave, you can load the remote database as a
reference. This may cause your application to fail if there are
problems with the remote database. Also, it is tricky (but not
impossible) to work with modules in a referenced database,
because the implementation was broken in A2000, and never
fixed.

(david)

Margaret Bartley said:
I'm opening a remote Access database and reading each module in it.
This works. What I'd like to do now is open each module to get at the
module properties.

The following code snippet works to list the modules in a connected
database:

Set cntModule = LookupDB.Containers("modules")
For Each docModule In cntModule.Documents
debug.print "Module: " & docModule.Name
Next docModule


What I'd like to do next is open an module object: in that remoted
database:

Set cntModule = LookupDB.Containers("modules")
For Each docModule In cntModule.Documents
debug.print "Module: " & docModule.Name
DoCmd.OpenModule docModule.Name
Next docModule

But I get the run-time error '2516': Microsoft Office Access can't find
the module 'Convert ISBNs.' [the name of the module in the remote
database]

I'm assuming the reason I get this error is because the syntax I'm using
is causing the interpreter to look in the CurrentDB, which does not
contain the module called "Convert ISBNs", instead of the remote db,
which does.

So, how do I reference a module in a connected database?

Thank you.
 

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