Linking Tables

G

Guest

I am using the following code to link tables from a back-end db, it doesn't
link to all of them for some reason and the ones that are linked appear
twice.

Private Sub Command5_Click()
Dim PathName As String
NewPathName = Application.CurrentProject.Path & "\Service Tables.mdb"
Dim Dbs As Database
Dim Tdf As TableDef
Dim Tdfs As TableDefs
Set Dbs = CurrentDb
Set Tdfs = Dbs.TableDefs

For Each Tdf In Tdfs
If Tdf.SourceTableName <> "" Then
Tdf.Connect = ";DATABASE=" & NewPathName 'Set the new source
DoCmd.TransferDatabase acLink, "Microsoft Access", NewPathName,
acTable, Tdf.SourceTableName, Tdf.SourceTableName
Tdf.RefreshLink 'Refresh the link
End If
Next

End Sub


Any hints appreciated,
Ron.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top