KB Article on Programmatically Linking to Tables

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

Quite some time ago I ran across a MS Knowledge Base article on how to
programmatically link to tables. Basically using VBA to perform the
functions of the 'Linked Table Manager' in Access' 'Database Utilities'
menu. I just went looking for it at the MSDN web site, but came up empty
handed.

Anyone recall this article and how to get to it?

Thanks!

Don
 
Don,

I am afraid I can't remember where the link to it has gone, I had it; but
have obviously cleared it out on one of my recent blitz's.

I have provided a snippet of code below that might be of help thou;

***CODE BEGINS***

Dim tdfTable As TableDef
Dim strNewPath As String

strNewPath = CurrentProject.Path & "YOUR PATH"

For Each tdfTable In CurrentDb.TableDefs
If Len(tdfTable.Connect) > 1 Then
tdfTable.Connect = ";DATABASE=" & strNewPath
tdfTable.RefreshLink
End If
Next

***CODE ENDS***

Basically it loops through each table definition you have, and if it has a
connect property that is longer than 1 (i.e it is a linked table), updates
it with your new connection string, then refreshes the table defintion.

Of course, this only works of your back end is an Access database. If it
is of another type you will need to alter the connection string accordingly.

Hope that helps; if I do find the link I will post it here, but I don't
think I will find it :-(

Cheers

John Webb
 
Back
Top