linking tables through code

J

John

I am having a problem with a table that looses it link
and would like to be able to relink it through code when
the link is broken. Is there a way to do this and why
would the link be broken?
 
M

Michel Walsh

Hi,



Definitively. The tableDef object has a property Connect that specify
where the linked table is, what is its format (Excel, another Access Jet
file, ... ), ... Once that is filled properly, use the RefreshLink method.
Very easy, really:


Dim tdf As TableDef
Set tdf=CurrentDb.TableDefs("YourTableNameHere")

tdf.Connect= ...
tdf.RefreshLink


Sure, I would check its Attribute first, or see if its actual connect
property makes sense, to see if the table is really a linked table in the
first place. All the code you may need is included in the help file.

You may also trap runtime error in case the refreshLink fails too.



Hoping it may help,
Vanderghast, Access MVP
 
H

Henry

I will point you to a resource that automatically checks
the back end links when ever the user opens the
database. Ken Getz and company have written an excellent
book about AC 2000. Within this book is an excellent
routine for checking the validity of links between the
front end and back end of an Access 2000 database. Works
with Access 2002 too. The routine is incluced on a CD
with the book.
The best reference for Access 2000 and Access 2002 is a
book written by Ken Getz and company published by
SYBEX, "Access 2000 Developer's Handbook" and Access
2002 ---. Within the pages there is a routine for
checking the links and re-establishing the links, should
they be broken, automatically. The routine is on a CD
included with the book along with detailed explanation of
how the routine works.
Cheers,
Henry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top