Access 2007 Split DB Un-Link Tables

I am looking for code to un-link all tables that are connected to the split backend DB
CMILLERAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Are you aware that you can just manually Delete the links via the Navigation Pane ?

mx
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Because any VBA Code solution would simply Delete those table names.
Example

CurrentDB.TableDefs.Delete("YourLinkedTableName")
mx
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can do it with code like this:

Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Set dbs = CurrentDB
For Each tdf in dbs.TableDefs
  If Len(tdf.Connect) > 0 Then
    DoCmd.DeleteObject acTable, tdf.Name
  End If
Next tdf

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

CMILLERAuthor Commented:
DatabaseMX,

Yes and I tried that but when I ran the code that I have to re-link the backend tables it didnt add the one table back that I deleted.
0
CMILLERAuthor Commented:
Here is what I am using to link the tables.



Function HQlinkTable()
On Error GoTo Relink_Error
Dim dbs As DAO.Database, strBEPath As String
Dim tdf As DAO.TableDef
Set dbs = CurrentDb()
strBEPath = "\\server-name\folder1\folder2\db_be.accdb"
Dim dbData  As DAO.Database
Set dbData = DBEngine.OpenDatabase(strBEPath)
     For Each tdf In dbs.TableDefs
          If tdf.Connect <> "" Then
               tdf.Connect = ";DATABASE=" & strBEPath
               tdf.RefreshLink
          End If
     Next
dbData.Close
Set dbData = Nothing

'add this line
If Err = 0 Then
MsgBox "DB Table Linking Process Successful"
End If


Relink_Error:
     If Err.Number = 3024 Then
          MsgBox "Unable to connect to data tables!" & vbCrLf & "Closing Application", vbQuestion, "DATA TABLES MISSING!"
          Err.Clear
           Application.Quit
     End If
End Function
0
CMILLERAuthor Commented:
Scott McDaniel,

When I run that code it removes all the tables but the only way to relink them is to manually import them back in.
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
You didn't say anything about relinking ...

And ... if you delete the links, then you have to manually link them using the Access UI before you can 'relink' them ...for example if the BE is moved ... and you need to Relink.   Relinking is generally done when a BE is moved.  If there are no tables currently linked (to relink), then you need to manually Link to get started.

 

2
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
This image should  have been above the first image above

1
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
When I run that code it removes all the tables but the only way to relink them is to manually import them back in.
As Joe mentioned, you didn't say you wanted to relink, only "un-link" them.

You can relink in several ways. Joe has shown you the manual method. If you'd like a way to RE-link that tables - that is to "refresh" the links - then you can either write your own method, or use one of the many free processes out there. Armen Stein's J Street Access Relinker (http://www.jstreettech.com/downloads.aspx) is a nice one, and should do everything you need.
0
CMILLERAuthor Commented:
Sorry, for not asking the question correctly.

Yes, I know how to re-link them manually.

I will ask a new question.
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"You can relink in several ways. Joe has shown you the manual method. "
Actually ... I showed how to Link, not relink ... since relinking technically ... only applies to tables already Linked to a BE. And Armen's tool does Relinking ... not initial Linking - of previously unlinked tables.

Further, I actually explained why the code we supplied was not doing what you asked - and how to correct that issue.

Just sayin' ...

mx
0
CMILLERAuthor Commented:
The code that I posted for this question is how I relink the tables.

I use this split DB for three diff dept's on three diff networks. The code that I have mapping...relinking...etc....works fine.

I have another use for the split DB and need a quick way to unlink....delete....etc.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Acrobat

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.