Solved

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

Posted on 2013-01-15
4
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 150 total points
ID: 38778867
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
ID: 38778869
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
ID: 38778911
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
ID: 38779043
Thanks. That did the trick. I rarely work with dbf's and hope to keep it that way!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

738 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