Solved

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

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

803 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