By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,098 Members | 1,918 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,098 IT Pros & Developers. It's quick & easy.

Create a Link in Access to a Text File

P: n/a
I am writing a little routine to perform the following operations from an
Acces 97 mdb:

1. create a fixed width text file
2. create/establish a table type link to the text file in Access
3. allow the user to view the text contained in the text file via an Access
form.

I have been able to achieve this, albeit with one major limitation. That is
that the name of the text file needs to be known prior to runtime. In other
words currently I cant let the user make up their own name for the file. I
have to dictate this so that I can pick up a link to the file, based on a
link specification that I manually created earlier. This appears to be a
limitation in Access?

The place where the limitation occurs is in the following code.

.Connect = "Text;DSN=" & strLinkName _
& " Link Specification;FMT=Fixed;HDR=NO;IMEX=1;" _
& "DATABASE=" & fs.GetParentFolderName(Path:=strFileName) & ";"

The restriction appears to be that the DATABASE parameter requires only a
path and then assumes that the file name corresponds to the name of the Link
Specification component of the DSN. (Supplying a file name as part of the
DATABASE definition causes an error.) Therefore I can vary the folder where
the file is created, but not the name. To get around this it appears I
would have to create a Link Specification myself as part of the routine, or
use some other method to identify the file. Either way I am out of my
comfort zone on this. Has anyone successfully achieved this and wouldnt
mind sharing their experience?

Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
The name of the file is stored as the SourceTableName property.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Andrew Chanter" <he****@radsolutions.com.au> wrote in message
news:Xv********************@news-server.bigpond.net.au...
I am writing a little routine to perform the following operations from an
Acces 97 mdb:

1. create a fixed width text file
2. create/establish a table type link to the text file in Access
3. allow the user to view the text contained in the text file via an
Access
form.

I have been able to achieve this, albeit with one major limitation. That
is
that the name of the text file needs to be known prior to runtime. In
other
words currently I cant let the user make up their own name for the file.
I
have to dictate this so that I can pick up a link to the file, based on a
link specification that I manually created earlier. This appears to be a
limitation in Access?

The place where the limitation occurs is in the following code.

.Connect = "Text;DSN=" & strLinkName _
& " Link Specification;FMT=Fixed;HDR=NO;IMEX=1;" _
& "DATABASE=" & fs.GetParentFolderName(Path:=strFileName) & ";"

The restriction appears to be that the DATABASE parameter requires only a
path and then assumes that the file name corresponds to the name of the
Link
Specification component of the DSN. (Supplying a file name as part of the
DATABASE definition causes an error.) Therefore I can vary the folder
where
the file is created, but not the name. To get around this it appears I
would have to create a Link Specification myself as part of the routine,
or
use some other method to identify the file. Either way I am out of my
comfort zone on this. Has anyone successfully achieved this and wouldnt
mind sharing their experience?

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.