Run a procedure in a different database

B

Bill Andersen

I have a procedure in a separate database. I want to call that procedure.
This is what I have so far.
dim appAccess as Access.Application
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase "C:\Sykes\Copy File.mdb"

Now, I need the syntax to call the procedure in 'Copy File.mdb'. That
procedure is in a module called 'CopyData'. The procedure is named
'CopyThis'. I tried the following: appAccess.Run "CopyThis" . That gives
an error saying it can't find "CoipyThis". Then I tried
"appAccess.Run C:\Sykes\Copy File.mdb\CopyData\CopyThis". This also gave an
error saying that it could not find the object.

Please suggest a better syntax.

Bill Andersen
 
O

Ofer

You can use reference from MDB1 to MDB2, so MDB1 will recognise all the
functions in MDB2.
Open MDB1, when you are in code, select tools, reference. browse and select
MDB2.
You will notice that MDB1 recognise all the functions, but it wont recognise
forms, reports, macros etc, so if for example you want to open a form in MDB2
From MDB1, create a function in MDB2 that open the form, and then call that
function from MDB1.
 
D

David C. Holley

You'll probably want to investigate the use of a database as a LIBRARY
db. Basically its a DB that contains information (code, forms) that you
want available to one or more DB's. The Access Wizards are all done as
Library DB's. All the information that you'll need SHOULD be in help.
 
F

Friedi

If you don't want to work with a reference or custome library - you can use
the run method - in help an example code is given
 

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