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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

access and linked tables 1

Status
Not open for further replies.

iamapollo

MIS
Aug 22, 2001
38
AU
I have split the tables in a database i am designing between data and code. What I want to know is how do you relink the tables in code if the client moves the data part of the database, or it is installed in a different location than what I was designing in. I would like a routine to do the job then have to explain to the user how to manually relink the tables.

Thanks in advance

Michael Fabiankovits
 
You could try something along these lines, you'll have to put in your own error handling - particularly for when the string entered is not correct. Or you might want to use the common dialog to find the source database name. This seems to work well in Access 97

Function ChangeTableSource(OldDB As String, NewDb As String)
Dim MyDb As Database, i As Integer
Set MyDb = CurrentDb
For i = 1 To MyDb.TableDefs.Count - 1
If MyDb.TableDefs(i).Connect = ";DATABASE=" & OldDB Then
MyDb.TableDefs(i).Connect = ";DATABASE=" & NewDb
MyDb.TableDefs(i).RefreshLink
End If
Next
End Function


Sandy
 
There is a "linked table manager" under Tools, Add-ins that is very easy to use to manage your linked tables. If your linked tables move, use this manager to easily fix all of your links.

Good luck,
Larry
 
Thanks Sandy

Does help simplify things, I just had no idea where to start, now it looks quite simple.

Thanks Again
Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top