Relinking Tables in code

Mcgrco

Registered User.
Local time
Today, 13:29
Joined
Jun 19, 2001
Messages
118
Can anyone provide me with some sample code for droping and relinking linked tables.

The simpler the better

Thanks in advance
 
this my function which works for me' Function to Refresh links to the supplied database. Return True if successful.

Dim dbs As Database
Dim tdf As TableDef
' Loop through all tables in the database.
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
' If the table has a connect string, it's a linked table.
If Len(tdf.Connect) > 0 Then
tdf.Connect = ";DATABASE=" & strFileName
Err = 0
On Error Resume Next
tdf.RefreshLink ' Relink the table. _
If Error occurs HERE, on this line, -produces- <> 0
If Err <> 0 Then
RefreshLinks = False
Exit Function
End If
End If
Next tdf
RefreshLinks = True ' Relinking complete.

Note: strFileName = root to required db ie C:\accessfolder\access.mdb

hope ok

[This message has been edited by RonB (edited 02-23-2002).]
 
Thank you thats very helpfull
 

Users who are viewing this thread

Back
Top Bottom