Solved

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

Posted on 2013-01-15
4
272 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 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

828 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