Deleting linked tables

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

My database is used by remote workers who work on a stand-
alone basis but I have written code to create links to
tables in a central database when they need to access that
data. I need to write code to sever those links when the
users wish to work on a stand-alone basis again. Is there
a way I can write code to delete all linked tables, or do
I have to name them individually?
 
You have to name them individually, but you can always loop through the
TableDefs collection and do it that way. Assuming you've got a reference set
to DAO, the following untested air-code will delete all linked tables in
your database:

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

Set dbCurr = CurrentDb()
For lngLoop = (dbCurr.TableDefs.Count - 1) To 0 Step -1
Set tdfCurr = dbCurr.TableDefs(lngLoop)
If Len(tdfCurr.Connect) > 0 then
dbCurr.TableDefs.Delete tdfCurr.Name
End If
Next lngLoop
 
Back
Top