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

Altering an Access linked table Connect string

Status
Not open for further replies.

Schroeder

MIS
Sep 25, 2001
382
US
I have an Access database that contains several tables that are linked to text files. My program copies the database and text files to a user-defined location. After the database is moved, the paths to the linked files need to be updated for the new location. This is causing me trouble.

Here's what I've tried (I'm using DAO):
After copying the database and text files, I set a TableDef object to the first of my linked tables. Before I alter it, the Connect property looks like this
Code:
Text;DSN=Img2 Link Specification;FMT=Delimited;HDR=NO;IMEX=2;CharacterSet=437;DATABASE=\\SMNT\E\Hzl
I then say
Code:
tdfTable.Connect = "Text;DSN=Img2 Link Specification;FMT=Delimited;HDR=NO;IMEX=2;CharacterSet=437;DATABASE=C:\My Documents\test

When I say
Code:
tdfTable.RefreshLink
I get
Run-time error '3625':
The text file specification 'Img2 Link Specification' does not exist. You cannot import, export, or link using the specification


I get that error even if I try the RefreshLink before altering the Connect property. My real question is, how do I make my change to the Connect property stick? I don't really care if RefreshLink ever works.
Better yet, is there a way to link tables in Access using a relative instead of absolute path? The text files are always going to be in the same directory as the database.
 
OK. Looks like it doesn't matter that RefreshLink throws an error. The change to my Connect property sticks anyway and the linked table works fine. Seems I've just got to ignore the error.
 
I should have guessed that was too good to be true. I've got too many copies of this database floating around and I was looking at the wrong one. It ain't workin' yet.

I've tried changing the name of the link specification to Img2LS thinking maybe the spaces were making DAO unhappy. No dice.

In case it isn't clear, those link specifications do exist.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top