• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 381
  • Last Modified:

How to Delete all Linked Tables in code?

I need some robust code to enable me to delete all linked tables in my MDB, but leave all the non-linked tables as they are.
This should be easy...High points for a fast answer!
  • 2
1 Solution
Rey Obrero (Capricorn1)Commented:

Sub dropLinkedTables()
Dim db As DAO.Database, x As Variant
    Set db = CurrentDb
    For Each x In db.TableDefs
        If Len(x.Connect) > 0 Then
            db.Execute "drop table [" & x.Name & "]"
        End If
End Sub
SOTAAuthor Commented:
Perfect!! Thanks capricorn1
SOTAAuthor Commented:
Awesome as usual!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now