relink flat file not a Table

E

eighthman11

Goodmorning;

Using Access 2000.

Quick question. I have a flat file which is linked to my access
database. I need to link this flat file based on the location of the
application. I've seen the code to relink tables from other databases
but when I try to apply this code to the flat file the code fails.

The flat file is called PCISSU.txt. The link table to the file is
called IssueImport.

I have a function that tells me the path of the application. Based on
the results the relink can only be one of two choices.

"C:\Inventory\PCISSU.txt"
or
"\\tsclient\C\Inventory\PCISSU.txt"

Any help would be appreciated.

Thanks Ray
 
D

Dirk Goldgar

eighthman11 said:
Goodmorning;

Using Access 2000.

Quick question. I have a flat file which is linked to my access
database. I need to link this flat file based on the location of the
application. I've seen the code to relink tables from other databases
but when I try to apply this code to the flat file the code fails.

The flat file is called PCISSU.txt. The link table to the file is
called IssueImport.

I have a function that tells me the path of the application. Based on
the results the relink can only be one of two choices.

"C:\Inventory\PCISSU.txt"
or
"\\tsclient\C\Inventory\PCISSU.txt"

Any help would be appreciated.


You can probably find and replace the folder location as a string within the
..Connect property of the IssueImport TableDef. However, I haven't ever
tried that. Failing that, it seems simple enough to just delete the linked
table and recreate it using DoCmd.TransferText. Have you tried that?
Depending on the nature of the text file, you may or may not need an
import/export specification.
 
E

eighthman11

You can probably find and replace the folder location as a string within the
.Connect property of the IssueImport TableDef.  However, I haven't ever
tried that.  Failing that, it seems simple enough to just delete the linked
table and recreate it using DoCmd.TransferText.  Have you tried that?
Depending on the nature of the text file, you may or may not need an
import/export specification.

--
Dirk Goldgar, MS Access MVPwww.datagnostics.com

(please reply to the newsgroup)- Hide quoted text -

- Show quoted text -

Thanks for the reply. I got it to work. Below is the code. Hope it
helps others.
Dim tdfLinked As DAO.TableDef
Dim db As Database
On Error Resume Next
Set db = CurrentDb
CurrentDb.TableDefs.Delete "IssueImport"
Set tdfLinked = db.CreateTableDef("IssueImport")
tdfLinked.Connect = "Text;DSN=PCISSU Link
Specification6;FMT=Fixed;HDR=NO;IMEX=2;CharacterSet=437;DATABASE=" &
PathLink
tdfLinked.SourceTableName = "PCISSU.txt"
db.TableDefs.Append tdfLinked
 

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