deleting linked tables from FE

EileenL

New member
Local time
Today, 15:15
Joined
Sep 15, 2004
Messages
8
Having a bit of trouble There use to be a kb article that described how to delete linked tables programatically and I can't seem to find it. I have two BE databases and one FE database that links the BE there are many table and I would like to delete all linked tables at once.

Any help would greatly be appreciated. :confused:
 
Function tlk_RemoveTableLinks() As Integer
'* Delete all table links in this database
'* Local tables will not be deleted.
Dim intRtn As Integer
Dim strProcName As String
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim i As Integer
Dim intTableCount As Integer
Dim Finished As Integer

On Error Resume Next
strProcName = "tlk_RemoveTableLinks"
intRtn = False

'* Loop through all tables in the database.
Set dbs = CurrentDb()
Finished = False
Do While Not Finished
Finished = True
intTableCount = dbs.TableDefs.Count
For i = 0 To intTableCount - 1
Set tdf = dbs.TableDefs(i)
If Len(tdf.Connect) > 0 Then
'* It's a linked table
dbs.TableDefs.Delete tdf.name
Finished = False
Exit For
End If
Next i
Loop

If err <> 0 Then Beep: MsgBox "Error in " & strProcName & " (9): " & err.Number & " - " & err.Description: err.Clear: GoTo Exit_Section

intRtn = True

Exit_Section:
On Error Resume Next
Set tdf = Nothing
Set dbs = Nothing
tlk_RemoveTableLinks = intRtn
On Error GoTo 0
End Function



Is This What You are Looking for

Regards
Bjackson
 
Thank You!!!!!

That worked great Thanks for the code what a time saver! :)
 
Your Welcome

I cant take credit for the code, as i obtained it as you have, from some kind soul whose is willing to share their knowledge.Where would we be without these forums !!

Regards
Bjackson
 

Users who are viewing this thread

Back
Top Bottom