Connection between 2 databases

I have 3 Access databases using similar modules.
For easing the maintenance of the modules, I would like to locate the modules in one database and to use those modules in the 2 other databases.
Is it feasible?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Yes.   You place the code in a DB, rename it with a MDA  extension (not absolutly required, it's just a convention).

Then in each DB, you set a reference in VBA to the MDA DB.

You can then call code in the MDA as if it resided in your DB.   Note that if you make a change in the MDA code, you need to re-compile your DB code.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Also should add that these are referred to as "Library" DB's and you should be aware of CurrentDB() vs CodeDB().

Depending on the operations you are performing, it may be important to know where the code is executing.  

See the on-line help for CodeDB() for all the details.

SommerAlainAuthor Commented:
Hi Jim, Thank you it looks clear. I will see it later today. I mainly use sql code. Is there somthing specific?
Have a nice day
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

Jeffrey CoachmanMIS LiasonCommented:
Also what some Access developers do is simply store all their "useful" codes in one simple text file

The code in your MDA file should only contain the code needed for that particular system

SommerAlainAuthor Commented:

In DataBase A I have a sub like this one:

Private Sub CalculateXXS
Call CalculateComplex("TableLocalTable")
End Sub

Imagine that the code of the sub CalculateComplex is in DataBase B and that the TableLocalTable is in DataBase A.
How to adapt this code to make it work?

Best regards
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
In this case, there is nothing you would need to do.  When you need to use CodeDB() is if your code is referring to objects in the library DB.

CurrentDB() always points to the DB open in the Access interface.  CodeDB() may or may not be different depending on the procedure that is currently executing and where it is.

This is actually how all the Access Wizards are written that you use, and things like the F2 Zoom Box.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.