Re:linking files

Access Beginner

Active Member
Joined
Nov 8, 2010
Messages
311
Office Version
  1. 2016
Platform
  1. Windows
Re:linking files

Hi All,

I have an Access Database that links to various text and excel files. The path is located on a server P:\Data. Due to changes with our IT structre this server has changed to Z:\Data. Is there a way to change all links without going into each link individually?

Using Access 2010.

Any advice is appreciated.

Cheers
Haydn
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Re: linking files

To do this properly you should change every instance but there are two other things you could do.

If drive letter P is still available on the workstations (and it probably is since it was in use previously) you could use the subst command to equate Drive P: with the new Z: and everything should just work again.

I assume all references to the excel and text files appear only in VBA. You could use a global string variable and set it to "Z:\Data".
If there are link references that are outside VBA environment then you could the TempVars collection to set a global value for the string variable there. You still must change every link to use the new variable name but if this ever happens again you only need change the value of the variable.
 
Last edited:
Upvote 0
Re: linking files

For linked tables you can use some code like this.

Code:
[COLOR="Navy"]Sub[/COLOR] LinkTables()
[COLOR="Navy"]Dim[/COLOR] tdf [COLOR="Navy"]As[/COLOR] TableDef

    [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] tdf [COLOR="Navy"]In[/COLOR] CurrentDb.TableDefs
        [COLOR="Navy"]Debug[/COLOR].[COLOR="Navy"]Print[/COLOR] tdf.Connect
        tdf.Connect = Replace(tdf.Connect, "P:\", "Z:\")
        tdf.RefreshLink [COLOR="SeaGreen"]' Re-link the table.[/COLOR]
    [COLOR="Navy"]Next[/COLOR] tdf
    [COLOR="Navy"]Set[/COLOR] tdf = [COLOR="Navy"]Nothing[/COLOR]

[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]


Backup first. You might want to step through the code and/or run it with only the debug.print statement first so you can see how many tables and what their paths look like.
 
Upvote 0
Re: linking files

thanks for the response I'll look into it much appreciated. I'll test it out on Monday when I'm back at work.

Cheers
 
Last edited:
Upvote 0
Re: linking files

thanks for the response revver, much appreciated. I'm back at work on Monday and I'll keep this in mind in the future
 
Upvote 0

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top