update linked tables from VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a split database which the 2 files reside in the same directory. I
move the database to different computers in which the directory path changes
and I would like to refresh / update the linked table paths automatically on
startup.

I would like to call a Sub routine from the Autoexec macro that does this.
And I know that I can use myPath = CurrentProject.Path & "\myDB_be.mdb" to
refer to my back end.

If guess my first check is to see if the directory has changed (which is
probably a second thing to address).

However I have no idea how I should use myPath to re-establish the linked
table references. Ive been looking at ADODB.Connection stuff but I dont know
if im even heading in the right direction.

Can anyone help?

Bruce
 
You need to loop through the TableDefs connection.
Examine each TableDef that does not have a name starting with "MSys or "~".
If it has something in its Connect property, it is a linked table, and you
need to assign the new string to the Connect property and RefreshLink.

This link has example code, based on the assumption that the front end and
back end are both on the same folder:
http://members.iinet.net.au/~allenbrowne/ser-13.html
 
Back
Top