check if a table is linked

L

Luis

Hello.
I'm trying to export all tables of a database to a new database. This task
needs to run everyday.
The issue here is that i don't want to export linked tables.

How can i check if a table is linked or not?

Thanks,

Luis
 
D

Douglas J. Steele

You can check whether its Connect property is set.

Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef

Set dbCurr = CurrentDb()
For Each tdfCurr In dbCurr.TableDefs
If Len(tdfCurr.Connect) > 0 Then
Debug.Print "Table " & tdfCurr.Name & " is linked."
Else
Debug.Print "Table " & tdfCurr.Name & " is not linked."
End If
Next tdfCurr

Another way would be to look it up in the MSysObjects table:

Function IsLinked(TableName As String) As Boolean

IsLinked = Nz(DLookup("Type", "MSysObjects", _
"Name = '" & TableName & "'"), 0) <> 1

End Function

(Non-linked tables have a type of 1, tables linked using ODBC have a type of
4 and all other linked tables have a type of 6)
 

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