Solved

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

Posted on 2013-01-15
4
268 Views
Last Modified: 2013-01-15
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
0
Comment
Question by:PBLack
  • 2
4 Comments
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 150 total points
Comment Utility
run this query and see the common item "thing" for the linked dbf tables


select connect,database,name,type from msysobjects
where connect is not null


once you found the "item"for the dbf linked tables, use it to get all the dbf tables and drop them
0
 
LVL 61

Accepted Solution

by:
mbizup earned 350 total points
Comment Utility
Try checking the connection string for .dbf (or anything else such as DSN name that identifies the connection as one you want to remove)

For Each tDef In CurrentDb.TableDefs
    If CBool(Len(tDef.Connect)) Then
        if instr(1, tDef.Connect, ".dbf") > 0 then
             Debug.Print "Dropping linked Table:  "; tDef.Name
             CurrentDb.Execute "DROP TABLE [" & tDef.Name & "]"
        end if
    End If
Next

Open in new window

0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
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
0
 

Author Closing Comment

by:PBLack
Comment Utility
Thanks. That did the trick. I rarely work with dbf's and hope to keep it that way!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now