I created the following code to delete all linked tables in my database (Access 200):
--------------------------------------------------------
Dim tbl As TableDef
Dim dbs As Database
Set dbs = CurrentDb
For Each tbl In dbs.TableDefs
If Len(tbl.Connect) > 0 Then ' Is a linked table
Debug.Print "Deleting table " & tbl.name & " ... "
dbs.TableDefs.Delete tbl.name
End If
Next tbl
---------------------------------------------------------
When I execute the code it goes through the collection of tables and deletes "some" of the linked tables.
If I execute the code again, it again deletes "some" of the linked tables.
Thus, in order to delete all linked tables I have to execute this code several times.
My question is, since I'm using the connection string to determine if the table is a linked table, then why does it return true some times and false on other times for the same table? I'm assuming this is what is happening as it is the only thing that makes sense.
Thanks for your help.
- Bruce
--------------------------------------------------------
Dim tbl As TableDef
Dim dbs As Database
Set dbs = CurrentDb
For Each tbl In dbs.TableDefs
If Len(tbl.Connect) > 0 Then ' Is a linked table
Debug.Print "Deleting table " & tbl.name & " ... "
dbs.TableDefs.Delete tbl.name
End If
Next tbl
---------------------------------------------------------
When I execute the code it goes through the collection of tables and deletes "some" of the linked tables.
If I execute the code again, it again deletes "some" of the linked tables.
Thus, in order to delete all linked tables I have to execute this code several times.
My question is, since I'm using the connection string to determine if the table is a linked table, then why does it return true some times and false on other times for the same table? I'm assuming this is what is happening as it is the only thing that makes sense.
Thanks for your help.
- Bruce