Is there a way to make a Linked Table path relative ?

  • Thread starter Thread starter John
  • Start date Start date
J

John

I would like to reference tables in another .mdb database in the same
folder. I would also like the option of moving the folder to other
locations. The path stored in Access for linked tables is the full and
complete path, resulting in the links being broken if the folder is
moved. Is there a way to make the path relative, i.e. ".\data.mdb" ?

Please respond to the list. Thank you.

John
 
No, you can' to use relative paths.

On the other hand, you can simply have your application check if the link to
a back table is present, if it is, then everything is ok.

If the link is NOT ok, then you simply attempt to re-link, and the first
place your code can try is the current dir.

So, in effect, if the database is moved, then it can run as normal without
user interaction. Hence, at the end of the day, you can't use relative
paths, but since it can re-link at startup...then you get the same effect
(and users can move the database to different locations)

You can use the code here to re-link.

http://www.mvps.org/access/tables/tbl0009.htm
 
As can be seen by this immediate window test:

currentdb.TableDefs("Absence1").Connect = ";DATABASE=.\db3.mdb"
currentdb.TableDefs("Absence1").RefreshLink
?currentdb.TableDefs("Absence1").Connect
;DATABASE=C:\Documents and Settings\Wayne\Desktop\db3.mdb

Access will accept the ".", but then expands it out to the full path. This
leaves you with relinking the tables in code.

http://www.mvps.org/access/tables/tbl0009.htm
 
Back
Top