Solved

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

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

632 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