473,387 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Code to change linked tables

I'm having trouble locating code to change the names/locations of
linked tables. For example, App1.mdb is linked to tblA in
w:\server1\data. I want the code to enable App1.mdb to relink to tblA
in e:\server1\data, without having to use the Linked Table Manager. Is
there a way to do this ? Any help is greatly appreciated.

Nov 22 '06 #1
3 2224
Something like:-

dim db as dao.database
dim tdf as dao.tabledef

set db = currentb

for each tdf in db.tabledefs
with tdf
if len(.connect) 0 then
.connect = "Your new connectstring here"
.refreshlink
end if
end with
next
set tdf = nothing
set db = nothing

BTW if you had bothered to search Google on the phrase Relink Access Tables
you would have got about 6000 hits, a large number of which would have
pointed you to similar code to the above.
--

Terry Kreft
"LucaBrasi" <Lu*******@FishNap.comwrote in message
news:4563d5f9.1267953@news-server...
I'm having trouble locating code to change the names/locations of
linked tables. For example, App1.mdb is linked to tblA in
w:\server1\data. I want the code to enable App1.mdb to relink to tblA
in e:\server1\data, without having to use the Linked Table Manager. Is
there a way to do this ? Any help is greatly appreciated.

Nov 22 '06 #2

Thank you for your help, I see that I have not actually asked the
question I wanted to. I wanted to link tables that are not all in the
same back end mdb. tblA is linked to a back end one a certain drive,
and tblB is linked to a back end on another drive. I have found plenty
of code segments to change all the links to the same new link, but not
individually. In effect, I'm looking for code like this:

tblA.newlink = "E:\Archive\History.mdb" ( This mdb contains tblA)
tblB.newlink = "S:\Public\Vendors.mdb" (This mdb conatins tblB)

So all the code I've found won't do that, and I'm not knowledgeable
enough to modify the code I've seen.
On Wed, 22 Nov 2006 09:25:43 -0000, "Terry Kreft"
<te*********@mps.co.ukwrote:
>Something like:-

dim db as dao.database
dim tdf as dao.tabledef

set db = currentb

for each tdf in db.tabledefs
with tdf
if len(.connect) 0 then
.connect = "Your new connectstring here"
.refreshlink
end if
end with
next
set tdf = nothing
set db = nothing

BTW if you had bothered to search Google on the phrase Relink Access Tables
you would have got about 6000 hits, a large number of which would have
pointed you to similar code to the above.
Nov 22 '06 #3
Ahh, I'll let you off then <g>.

Unfortunately you're reduced to doing something like the following

dim db as dao.database
dim tdf as dao.tabledef

set db = currentdb

Set tdf = db.Tabledefs("tblA")
with tdf
.connect = "Your new connectstring for tblA here"
.refreshlink
end with

Set tdf = db.Tabledefs("tblB")
with tdf
.connect = "Your new connectstring for tblB here"
.refreshlink
end with

'and so on ...

set tdf = nothing
set db = nothing

You can make this more generic to some extent by creating a table with two
fields one of which contains the tablename to relink and the other one
contains the new connection string.

e.g.
tblNewConnect
-----------------
TableName
ConnectString

You enter the details into this table and then you can do something like:-

dim db as dao.database
dim rs as dao.recordset
dim tdf as dao.tabledef
Dim strName as string
Dim strConnect as string

set db = currentdb
set rs = db.OpenRecordset("SELECT * FROM tblNewConnect, dbopensnapshot)

with rs
Do Until .EOF
strName = .Fields("TableName")
strConnect = .Fields("ConnectString")

Set tdf = db.Tabledefs(strName)
with tdf
.connect = strConnect
.refreshlink
end with

.Movenext
Loop
.Close
End With

set rs = nothing
set tdf = nothing
set db = nothing

--

Terry Kreft
"LucaBrasi" <Lu*******@FishNap.comwrote in message
news:45647216.2247953@news-server...
>
Thank you for your help, I see that I have not actually asked the
question I wanted to. I wanted to link tables that are not all in the
same back end mdb. tblA is linked to a back end one a certain drive,
and tblB is linked to a back end on another drive. I have found plenty
of code segments to change all the links to the same new link, but not
individually. In effect, I'm looking for code like this:

tblA.newlink = "E:\Archive\History.mdb" ( This mdb contains tblA)
tblB.newlink = "S:\Public\Vendors.mdb" (This mdb conatins tblB)

So all the code I've found won't do that, and I'm not knowledgeable
enough to modify the code I've seen.
On Wed, 22 Nov 2006 09:25:43 -0000, "Terry Kreft"
<te*********@mps.co.ukwrote:
Something like:-

dim db as dao.database
dim tdf as dao.tabledef

set db = currentb

for each tdf in db.tabledefs
with tdf
if len(.connect) 0 then
.connect = "Your new connectstring here"
.refreshlink
end if
end with
next
set tdf = nothing
set db = nothing

BTW if you had bothered to search Google on the phrase Relink Access
Tables
you would have got about 6000 hits, a large number of which would have
pointed you to similar code to the above.

Nov 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: pinballjim | last post by:
Hello everyone, I'm looking for a simple way to create a local copy of a linked table. I've got a database that links about 10 tables from other databases. This works fine on my machine, but I...
1
by: Ange T | last post by:
Hi, I have a secured Access 2000 database, and have encountered a strange error that I can't find any similar postings on. I'd really appreciate your help! In my database, I have a number of...
0
by: S | last post by:
Hi, I have a MS Access db MDE which is linked to some SQL tables on a server. Now in my company we are using a certain IP address. The same MDE is given to external company to use, but they...
2
by: TanMan | last post by:
I have a large Access 2002 DB (mdb) with many linked tables pointing to a vendor database. The vendor has released a new version, and the column names in all the linked tables has changed. There...
2
by: Jill Elaine | last post by:
I am building an Access 2002 frontend with linked tables to an encrypted Paradox 7 database. When I first create these linked tables, I'm asked for the password to the encrypted Paradox database,...
5
by: Easystart | last post by:
Hi, Sorry for my English. English is not my native tougue. I am working in MS Access 2000 with a SQLServer 2000 Backend database. MS Access 2000 is my GUI front end that has SQLServer linked...
7
by: ApexData | last post by:
Hello I currently Link the FE/BE using the LinkTables Option and the Linked Table Manager. Any time I need to move the BE to another location, I have to go through this process over again. I...
1
by: Himmel | last post by:
Hello, I am using an access database to query a very large number of linked tables. Currently, the name of the database the linked tables point to is always the same name. However we are...
8
by: brucedodds | last post by:
I've inherited an A2003 application with linked SQL Server 2000 tables in the back end, using the Microsoft SQL Server ODBC driver. We've set up a test SQL Server database. I'd like to automate...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.