With multiple linked dbs, wow do I drop linked tables all tables in only one of them. (1 Viewer)

ToddMac

New member
Local time
Today, 12:37
Joined
Nov 2, 2019
Messages
4
This works to drop all linked tables but now that the database has grown so large I have split it into 3 backends. I only want to drop linked tables from one of the dbs: salesauto_be.accdb

Project is all Access databases.

Code:
On Error GoTo Err_Load
Dim db As DAO.Database
Set db = CurrentDb()
Dim tDef As DAO.TableDef
Dim strFi As String

'drop all linked dbfs
For Each tDef In CurrentDb.TableDefs
    If CBool(Len(tDef.Connect)) Then
        Debug.Print "Dropping linked Table:  "; tDef.Name
        CurrentDb.Execute "DROP TABLE [" & tDef.Name & "]"
    End If
Next

I could cycle through each table name but with over 100 tables and growing, it is not practical nor efficient.

Thank you
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:37
Joined
Oct 29, 2018
Messages
21,447
Hi. You could use the InStr() function to check the .Connect property for the name of the BE.
 

Users who are viewing this thread

Top Bottom