MT.
MT.

Reputation: 791

Relative file references

In have built a couple of mda library files which I am then referencing from my main Access application (i.e. using Tools -> References from within the IDE).

Is there a way that these references can be made relative rather than absolute. The reason I am asking is so that it would make it easy to set-up on the user's computer if all three files (main application and two mda files) could simply be placed in any directory and work without having to change the references...

Thanks

Upvotes: 6

Views: 13696

Answers (3)

Tony Toews
Tony Toews

Reputation: 7882

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

Or are you using the add-in logic with the USysRegInfo table? You don't really need to do that with your own add-ins. Just with developer type add-ins such as Rick Fisher's Find and Replace.

If this isn't working for you then tell us what error messages or symptoms.

Upvotes: 7

Mike
Mike

Reputation: 327

You can add VBA references through VBA itself.

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

Application.References.AddFromFile sFilename

Just put that in your AutoExec and that reference ought to be available for everything. Of course, you'll have to check if the reference already exists before adding it, otherwise you get an error. But that's just a matter of looping through Application.References.

Upvotes: 1

Russ Cam
Russ Cam

Reputation: 125498

To get the file path for the access application

CurrentProject.Path & "\"

Then just add the other files into the same directory and get them by name. i.e.

Dim filepath As String
filepath = CurrentProject.Path & "\name_of_file.mda"

Upvotes: 6

Related Questions