
Changing Linked Table link?
You can change the Connect property of the tabledefs to include the
new path and then use the RefreshLink method to update the link. Here
is some sample code that also puts up a progress meter in the status
bar.
Dim db as Database
Dim tdf as TableDef
Dim strNewDB as String
Dim intTableDefCount as Integer
'You may want to pass strNewDB to the proc
' as a parameter, instead.
strNewDB = "New path\file"
Set db = CurrentDb
Call SysCmd(acSysCmdInitMeter, _
" Updating the links to the data file . . .", _
db.TableDefs.Count)
For Each tdf In db.TableDefs
If (tdf.Attributes And dbAttachedTable) = _
dbAttachedTable Then
tdf.Connect = ";DATABASE=" & strNewDB
tdf.RefreshLink
End If
intTableDefCount = intTableDefCount + 1
Call SysCmd(acSysCmdUpdateMeter, intTableDefCount)
Next
Call SysCmd(acSysCmdRemoveMeter)
-- Andy
Quote:
>Is there a way to programmatically change the destination of a linked table?
>I have an MDB that is just an interface with some value add to another MDB.
>All of it's tables are linked to the other MDB. The other MDB is installed
>on various systems in different places. So, I'd like the interface .MDB to
>change it's own links based on, say, the COMPUTERNAME environment variable.
>--
>Dick Watson