Link to home
Start Free TrialLog in
Avatar of Todd MacPherson
Todd MacPhersonFlag for Canada

asked on

How do I remove links to dbf tables only and ignore the rest of the linked tables?

I have some code that drops all of the linked tables but I do not know how to alter it to only drop linked dbf tables while still maintaining a link to all of my back end access tables.

Please help

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

Thanks PBLack
SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
btw, you can also get an idea of what your dbf connection string looks like by hovering the mouse over a linked dbf table name in the Nav Pane or database window.

".dbf" should be found in any DSN-less connections, otherwise there should be some other tell tale text that identifies linked tables you want to remove.  If needed, you can subsitute 'other' text for .dbf in the Instr function in the code I posted.

Standard connection strings can be found here:
http://www.dofactory.com/Connect/Connect.aspx#_self705
Avatar of Todd MacPherson

ASKER

Thanks. That did the trick. I rarely work with dbf's and hope to keep it that way!