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

access and linking tables 2

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
 
This is how I do it:

Function relinkTables(newPath)
Dim td As DAO.TableDef
For Each td In CurrentDb.TableDefs
On Error Resume Next
If (td.Attributes And dbAttachedTable) = dbAttachedTable Then
If LCase(td.Connect) <> LCase(&quot;;DATABASE=&quot; & newPath) Then
td.Connect = &quot;;DATABASE=&quot; & newPath
td.RefreshLink
End If
End If
On Error GoTo 0
Next
End Function

I hope I was helpfull
 
Thanks for the tip

Doesn't look as hard as I thought, I will be giving it a try this weekend.

Thanks Again

Michael
 
You're welcome.
If you'll have problems - let me know. I'm working with this function a lot so I think it'll work fine.

Good luck
 
I have it working fine, but just a query for interest sake (so feel free to ignore if busy) but how would you do this if you wanted to use ADO.

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top