I entered the following code into the button....
--------------------------------------------
Dim dbFE As DAO.Database
Dim tdfFE As DAO.TableDef
Set dbFE = CurrentDb
For Each tdfFE In dbFE.TableDefs
If tdfFE.Connect <> "" Then
dbFE.TableDefs.Delete tdfFE.Name
End If
Next tdfFE
'To find all the tables in another db, open the other
'database and loop through its Tabledefs collection, adding
'the tabledef to your current database:
------------------------------------------------
Dim dbBE As DAO.Database
Dim tdfBE As DAO.TableDef
Set dbBE = OpenDatabase(strDataLinkPath)
For Each tdfBE In dbBE.TableDefs
Set tdfFE = dbFE.CreateTableDef(tdfBE.Name, ,
tdfBE.Name, ";DATABASE=" & strDataLinkPath)
dbFE.TableDefs.Append tdfFE
Next tdfBE
dbFE.TableDefs.Refresh
Set tdfBE = Nothing
dbBE.Close: Set dbBE = Nothing
Set tdfFE = Nothing
Set dbFE = Nothing
-----------------------------------------
On line "dbFE.TableDefs.Append tdfFE", I get the following
message "Run-time Error 3264. No field defined. Cannot
append tabledef or index."
The delete linked tables code deletes every other table,
leaving half the tables there each time it is run.
Randy
++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----Original Message-----
The recommended approach to manipulating linked tables is
through the TableDefs Collection and Delete the ones with a
something in it's Connect property or to set the Connect
property,
To Delete the linked tables in the current db:
Dim dbFE As DAO.Database
Dim tdfFE As DAO.TableDef
Set dbFE = CurrentDb
For Each tdfFE in dbFE.TableDefs
If tdfFE.Connect <> "" Then
db.TableDefs/Delete tdf.Name
End If
Next tdf
To find all the tables in another db, open the other
database and loop through its Tabledefs collection, adding
the tabledef to your current database:
Dim dbBE As DAO Database
Dim tdfBE As DAO.TableDef
Set dbBE = OpenDatabase("path to BE db")
For Each tdfBE in dbBE.TableDefs
Set tdfFE = dbFE.CreateTableDef (TdfBE.Name, , _
TdfBE.Name, ";DATABASE=" & "path to BE db")