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
I then say
When I say
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.
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
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
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.