Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect linked tables and relink if broken.

Status
Not open for further replies.

djmc

Programmer
Jun 12, 2002
179
CA
I have a question. I have linked tables and non-linked tables in my database frontend connected to the backend. (Linked tables on frontend that links to the backend)

I would like a feature where in the startup of my access application, it would check to see if all my linked tables are valid (linked), and if it is not then it will prompt the user or something (not sure what is a good way to handle this situation)

I would also like an 'open' feature in my file menu where it would open a backend db with the tables that were linked from the frontend and relink it to the current db you've opened (assuming the same table definitions are in that db as well) TIA
 
Here's a "refresh links" module I wrote for an VB 6 / Acc97 project a few years back:

Dim Tdf As TableDef, dbs As Database

On Error GoTo HandleError

'<linked db path> = absolute path + filename
Set dbs = OpenDatabase(<linked db path>)

'Loop to process all tables in the database
For Each Tdf In dbs.TableDefs
'If table has connect string, it's linked
If Len(Tdf.Connect) > 0 Then
Tdf.Connect = &quot;;DATABASE=&quot; & <linked db path>
Err = 0
On Error Resume Next
'Reattach table
Tdf.RefreshLink
If Err <> 0 Then
'Problems
RefreshLinks = False
Exit Function
End If
End If
Next Tdf

RefreshLinks = True

Exit Function


Needless to say, there's a good deal of error trapping to go along with this, but this gets the job done.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top