VBA Access - Relative File Links

In created a couple of mda library files, which I then link to my main Access application (i.e. using Tools → References from in IDE).

Is there any way that these links can be made relative, not absolute. The reason I ask is to simplify the configuration on the user's computer if all three files (the main application and two mda files) can simply be placed in any directory and work without having to change the links ..

thanks

+6
vba access-vba ms-access
source share
3 answers

Why not just place the three MDEs in the same folder on the target system? Access should find links to MDE just fine.

Or do you use add-in logic in the USysRegInfo table? You do not need to do this with your own add-ons. Just with add-ons like developer like Rick Fisher Find and Replace.

If this does not work for you, let us know what error messages or symptoms.

+7
source share

To get the file path for an access application

CurrentProject.Path & "\" 

Then just add other files to one directory and get them by name. i.e.

 Dim filepath As String filepath = CurrentProject.Path & "\name_of_file.mda" 
+4
source share

You can add VBA links through VBA itself.

 Dim sFilename As String sFilename = CurrentProject.Path & "\" & whatever.mda Application.References.AddFromFile sFilename 

Just put this in your AutoExec and this link should be accessible to everyone. Of course, you will need to check if the link already exists before adding, otherwise you will receive an error message. But this is just a matter of loop through Application.References.

0
source share

All Articles