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

transfertext error when filename holds . 2

Status
Not open for further replies.

Pampers

Technical User
Apr 7, 2004
1,300
0
0
AN
Hi everybody,
I am trying to read a file into a table using transfertext command. But if the file name holds '.' before the file extension, Access cannot the find the file (error 3011). My code is:

Code:
DoCmd.TransferText acImportDelim, "specArtImp_SchapKaart", "tblArtImpLocalTemp", strInputFileName, False

FileName: "25.0101 Feest 3000 formule - 1 WAND element.txt" gives an error

But: 250101 Feest 3000 formule - 1 WAND element.txt; works ok

Any suggestions?



Pampers [afro]
Keeping it simple can be complicated
 
the use of '.' in file names other than for the file extension is very bad practise. I would avoid using them that way upir transfertext command will work fine.
 
A starting point:
Code:
oldFileName = "25.0101 Feest 3000 formule - 1 WAND element.txt"
newFileName = "250101 Feest 3000 formule - 1 WAND element.txt"
FileCopy oldFileName newFileName
DoCmd.TransferText acImportDelim, "specArtImp_SchapKaart", "tblArtImpLocalTemp", newFileName, False
DoEvents
Kill newFileName

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Well, I agree that the points in the filename is bad practice, but if that is the file name you get to work with, that is the way it is. Furthermore, Windows allows you to use these kind of names in the first place, so one can argue that the transfertext would be able to work with that as well. But that is just an academic point of view.

Anyway, thanks PHV for this workaround. That will do fine.



Pampers [afro]
Keeping it simple can be complicated
 
I mean, I will take out any point in the filename and use FileCopy to import the file

Pampers [afro]
Keeping it simple can be complicated
 
To take PHV's idea one step further:

Code:
newfilename = Replace(strInputFileName, ".", "")
FileCopy strInputFileName newFileName
DoCmd.TransferText acImportDelim, "specArtImp_SchapKaart", "tblArtImpLocalTemp", [blue]newFileName[/blue], False

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Thnanks for the reply, but that will take out the point of the file extension as well i believe....

Pampers [afro]
Keeping it simple can be complicated
 
Pampers said:
Thnanks for the reply, but that will take out the point of the file extension as well i believe....
Right - sorry. I quickly cut and pasted this from some code I had where I was adding the extension back on afterwards. [blush]

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
He Greg,
No worries, you are idea was clear. After i posted my reply, i aslo thought, does it matter that the extension is taken off...

Pampers [afro]
Keeping it simple can be complicated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top