Folder Date in File Name

JDeezy

Registered User.
Local time
Today, 16:24
Joined
Sep 4, 2009
Messages
54
I have some queries importing files from the previous day where instead of the date being in the file name it is in the folder before it. For example C:\Programs\090903\FileName.txt.

I have tried to pull it like this..."C:\Programs\"Format(Date()-1,"yymmdd")"\FileName.txt... still to no avail.

I am really clueless on what to do so if anyone has any ideas it would be greatly appreciated
 
Concatenation is key:

"C:\Programs\" & Format(Date()-1,"yymmdd") & "\FileName.txt"
 
I have tried that but for some reason it is saying "You cannot import a text file unless it has one of these extensions: TXT, CSV, TAB, etc." But it is a text file, labeled .txt, and the file is there. So I am just confused about the whole situation.
 
Try building the file path outside of the import statement, so something like:

Dim strPath As String

strPath = "C:\Programs\" & Format(Date()-1,"yymmdd") & "\FileName.txt"

and then use strPath where you were using the other code.

Also, where is FileName coming from? If that is a variable too, then you would need to concatenate it in:

strPath = "C:\Programs\" & Format(Date()-1,"yymmdd") & "\" & FileName & ".txt"
 
Yeah same error message with both of the solutions. The file is always constant as New_in.txt it is just the folder date that changes day by day. Im using access 2003 if that might have anything to do with it.
 
What's the entire code you are using?

And are you sure that the path is correct?
 
It's confidential so i cant disclose that info but the path is correct. It looks to me like it just stops reading it once it gets to the date and its not picking up the file name tho.
 
Set a breakpoint and step through it using F8 and see what the values are at any one time.
 

Users who are viewing this thread

Back
Top Bottom