Clear or Break Table Links

  • Thread starter Thread starter box2003
  • Start date Start date
B

box2003

Hello,

Just as there is code to establish and refresh table links, I would at time
like to break or delete these links. I would like to know how that is done
in code. I have been able to follow the code samples for refreshing and
linking tables, I am requesting information on how to break those link.

Thank you.
 
box2003 said:
Hello,

Just as there is code to establish and refresh table links, I would at
time
like to break or delete these links. I would like to know how that is
done
in code. I have been able to follow the code samples for refreshing and
linking tables, I am requesting information on how to break those link.

Thank you.



The following code will delete all linked tables:

Public Function DeleteLinks() As Boolean

On Error GoTo Err_DeleteLinks

Dim dbs As DAO.Database
Dim lng As Long

Set dbs = CurrentDb

With dbs.TableDefs
For lng = .Count - 1 To 0 Step -1
If (.Item(lng).Attributes And dbAttachedTable) <> 0 Then
.Delete .Item(lng).Name
End If
Next lng
End With

DeleteLinks = True

Exit_DeleteLinks:
On Error Resume Next
Set dbs = Nothing
Exit Function

Err_DeleteLinks:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_DeleteLinks

End Function
 
Thank you, the solutions are just what I needed. It is too bad the
solutions found in these newsgroups could not be categorized into an all
encompassing book, perhaps they already and I don't know about it. I think
it would sell.
 
Back
Top