How to get rid off all the linked tables ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there anyway in link manager to get rid off all the links and to a attach
it later
to a different database. That is that after deselecting I should not see the
database connections ?
 
nach said:
Is there anyway in link manager to get rid off all the links and to a
attach it later
to a different database. That is that after deselecting I should not
see the database connections ?

I'm not sure what you have in mind. You can run code that uses DAO to
delete all the linked tables if you want, though not via the Linked
Table Manager. The following is untested, but should work:

'----- start of example code -----
Dim db As DAO.Database
Dim intTD As Integer

Set db = CurrentDb

For intTD = (db.TableDefs.Count - 1) To 0 Step -1

With db.TableDefs(intTD)
If Len(.Connect) > 0 Then
db.TableDefs.Delete .Name
End If
End With

Next intTD

Set db = Nothing
'----- end of example code -----

Note that will delete all the linked tables in the database -- it will
not delete the actual table in the source database to which it is
linked, just the link itself.

Maybe this is what you had in mind, maybe it isn't.
 
This code deletes all linked ODBC tables.
Try swapping dbAttachedODBC with dbAttachedTable for removing linked Access
tables.

Public Sub DeleteODBCTableNames()
On Error GoTo Err_DeleteODBCTableNames

Dim dbs As Database, tdf As TableDef, I As Integer
Set dbs = CurrentDb
For I = dbs.TableDefs.Count - 1 To 0 Step -1
Set tdf = dbs.TableDefs(I)
If (tdf.Attributes And dbAttachedODBC) Then
dbs.TableDefs.Delete (tdf.Name)
End If
Next I

Set dbs = Nothing

Exit_DeleteODBCTableNames:
Exit Sub

Err_DeleteODBCTableNames:
MsgBox ("Error # " & str(Err.Number) & " was generated by " & Err.Source
& Chr(13) & Err.Description)
Resume Exit_DeleteODBCTableNames

End Sub
 
I have developed a Link Table form which allows linking and unlinking of
tables. It's yours for the asking (source code in A97).


Andy
 
Andy, This sounds like just what I need, and would greatly appreciate the
source code.
-Stu
 
Back
Top