By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,210 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

How do I test for an existing link before linking to a BE file?

P: n/a

Having trouble with tblCustomer, tblCustomer1, tblCustomer2, etc appearing
if I've already got a link between the front end and back end and I try to
link to tblCustomer. So, how do I code a test to make sure the table isn't
*already* linked before linking it?

Using Access2000 if it matters.

Apr 25 '06 #1
Share this Question
Share on Google+
1 Reply

P: n/a
here is some code you can experiment with. This codes tests if a table
in the TableDefs collections is linked by testing the connect string.
If the connectstring is not "" then it is a linked table.

Sub tblLinks()
Dim DB As DAO.Database, tdf As DAO.TableDef
Set DB = CurrentDb
For Each tdf In DB.TableDefs
If tdf.Connect <> "" Then Debug.Print tdf.Name & " is a linked
'If (tdf.Attributes And dbAttachedTable) = dbAttachedTable Then
Debug.Print tdf.Name; " is a linked table"
End Sub

And to re-link a table you can do this :

Sub ReLink()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim strPath As String
strPath = "<SomePathToBackEndDatabase>"
Set db = CurrentDb()
For Each tdf In db.TableDefs
If (tdf.Attributes AND dbAttachedTable) = _
dbAttachedTable Then
tdf.Connect = ";DATABASE=" & strPath
End If

*** Sent via Developersdex ***
Apr 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.