Avatar of SommerAlain
SommerAlain asked on

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?
Microsoft OfficeMicrosoft ApplicationsMicrosoft Access

Avatar of undefined
Last Comment
Jim Dettman (EE MVE)

8/22/2022 - Mon
Jim Dettman (EE MVE)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Jim Dettman (EE MVE)

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.


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
Jeffrey Coachman

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

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy


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 (EE MVE)

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.