TransferText Import question

  • Thread starter gmazza via AccessMonster.com
  • Start date
G

gmazza via AccessMonster.com

Hey there,
Here is my code:
DoCmd.TransferText acImportDelim, "450Specs", "400Export", "F:\IT\db\Sales\
Archive\400a.csv", , , False

I want to export any file that starts with 400, not just 400a. There will
only be 1 file in there, but it may be named 400a, or 400b, etc.
How can I code to export anything that starts with 400...

Thanks!!
 
P

PieterLinden via AccessMonster.com

gmazza said:
Hey there,
Here is my code:
DoCmd.TransferText acImportDelim, "450Specs", "400Export", "F:\IT\db\Sales\
Archive\400a.csv", , , False

I want to export any file that starts with 400, not just 400a. There will
only be 1 file in there, but it may be named 400a, or 400b, etc.
How can I code to export anything that starts with 400...

Thanks!!

Use Dir() inside a loop that returns all the values one at a time...

strFile = DIR("F:\IT\db\Sales\Archive\400*.csv")
While Len(strFile)>0
DoCmd.TransferText acImportDelim, "450Specs", "400Export", strFile, , ,
False
strFile = Dir()
Loop
 
G

gmazza via AccessMonster.com

Thanks Pieter!
Looks good, just getting an error saying it can't find the file.
The file is there for sure, I checked and re-checked the directory.
When I debug the error on this line:
DoCmd.TransferText acImportDelim, "450Specs", "400Export", strFile, , , False

When I put my mouse over the strFile, it says the file name. Shouldn't it
have the directory in front of the file name? Shouldn't it say F:\IT\db\Sales\
Archive\400b.csv?
It just says 400b.csv therefore my error says can't find file 400b.csv.

What do you think?
Thanks!
Hey there,
Here is my code:
[quoted text clipped - 6 lines]

Use Dir() inside a loop that returns all the values one at a time...

strFile = DIR("F:\IT\db\Sales\Archive\400*.csv")
While Len(strFile)>0
DoCmd.TransferText acImportDelim, "450Specs", "400Export", strFile, , ,
False
strFile = Dir()
Loop
 

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