0

I have several accdb files. Most of them (I will call them slaves) have only tables and queries and only one (I will call it master) have vba macros that actuate over the other files as an engine.

Now I need to use directly on an 'slave' file a macro stored on the 'master' file, but I don't want to duplicate it because if I make some change on the vba code in the master, I will need also to replicate the same change on the 'slave' code.

It is possible to link tables between accdb files. It is also possible to link queries between accdb files (using full path on the SQL statement)

My question is: is there any possibility to link a vba macro code from an access file to another access file similarly as the import table manager or 'absolute path' query SQL statement?

7
  • when I talk about the "link query" I mean that it is possible to link a query from other access into the current access without liking also the origin tables. Example: SELECT * FROM [C:\Users\username\Desktop\Database.accdb].Query1
    – Joracosu
    Jul 2, 2019 at 12:45
  • 1
    Create new module (or open some existing) in "slave" database. Then Tools-References, find "master" database (via Browse knob) and add it. Now you can use public subs/funcs from "master" database in "slave" code.
    – Akina
    Jul 2, 2019 at 13:15
  • For about 1 minute I thought that you gave me the answer hahaha, but the problem is that when I close and open again the 'slave' file, the Reference to the 'master' is not there anymore and is needed to re-load again the Reference. Is it possible to left it there forever?
    – Joracosu
    Jul 2, 2019 at 13:31
  • when I close and open again the 'slave' file, the Reference to the 'master' is not there anymore and is needed to re-load again the Reference. I cannot reproduce this behavior...
    – Akina
    Jul 2, 2019 at 13:50
  • STEP BY STEP: 1º open 'slave' file. 2º load the 'master' code through Tools-References. 3º close 'slave' file. 4º open again 'slave' file --> the 'master' code is unloaded and to use it I have to do again the step 2
    – Joracosu
    Jul 3, 2019 at 8:22

1 Answer 1

1
  • Create new module (or open some existing) in "slave" database VBA Editor.
  • Tools-References, find "master" database (via Browse knob) and add it.
  • Use public subs/funcs from "master" database in "slave" code.

Avoid of names interferences (project, module, sub/function, variable...).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .