Linking Table

Ian Mac

Registered User.
Local time
Today, 19:14
Joined
Mar 11, 2002
Messages
179
All,

Is there a way that I can ask if a Table is Linked or Resident in a Database.
I would like to use the follow code without Defining which table not to include?

Code:
Public Sub LinkTables(strP As String)

Dim vItem As Variant
Dim strTable As String

For Each vItem In CurrentDb.TableDefs

If Left(vItem.Name, 2) <> "MS" And Left(vItem.Name, 6) <> "Client" Then

DoCmd.DeleteObject acTable, vItem.Name
DoCmd.TransferDatabase acLink, "Microsoft Access", _
    strP, acTable, vItem.Name, _
    vItem.Name
End If

Next

End Sub

Where I have 'Client' I would like to just skip the resident tables regardless of name.

Cheers,
 
Native tables will have an empty string for their "Connect" and "SourceTableName" properties, so...
Code:
Public Sub TraverseLinkedTDF()
  Dim tdf As DAO.TableDef

  For Each tdf In CurrentDb.TableDefs
    If tdf.Connect <> "" Then
[COLOR="Green"]      'do something with linked table "tdf"[/COLOR]
      Debug.Print tdf.name
    End If
  Next tdf

End Sub
...should traverse only the linked tables in the database in CurrentDb.
 
Excellent, I'll use right now.

Thanks,
 

Users who are viewing this thread

Back
Top Bottom