copy Julian dated folder

S

Shawn

Hello,
I have database witch create fold each day by Julian date, for example
“SMP09002†folder name year and day folder name does not change. User
manually copy files to different drive folder and import to access db. Is
their any way I can automate that process. I tried FileCopy method but I am
getting error message “File path not foundâ€.
Here is the code:

StrFolder = ("smp" & Format(Now(), "yy") & Format(Now(), "y"))

FileCopy "S:\Remitance\TAB\" & StrFolder & "\Trans\AAB.001",
"C:\DATA\AAB.001"

Any help would be most appreciated

Regards,
 
D

Douglas J. Steele

Assuming today's date (January 16), your code tries to copy
"S:\Remitance\TAB\smp09016\Trans\AAB.001" to "C:\DATA\AAB.001".

Does folder C:\Data exist? Does the user have the necessary permissions on
it? (For that matter, is "S:\Remitance\TAB\smp09016\Trans\" the correct
folder name: no typos or anything like that?)
 
S

Shawn

Thanks for prompt respons . Yes "C:\data" does exist there is no typo or any
thing
If I use code without expression it does copy the file on "C:\data" folder.
Example "S:\Remitance\TAB\smp09016\Trans\AAB.001" to "C:\DATA\AAB.001".
with expression gives me error "File path not found".

Thanks againg for helping me
 
D

Douglas J. Steele

You may need to verify that the file you're trying to copy exists:

StrFolder = ("smp" & Format(Now(), "yy") & Format(Now(), "y"))

If Len(Dir("S:\Remitance\TAB\" & StrFolder & "\Trans\AAB.001")) > 0 Then
FileCopy "S:\Remitance\TAB\" & StrFolder & "\Trans\AAB.001",
"C:\DATA\AAB.001"
Else
MsgBox "S:\Remitance\TAB\" & StrFolder & "\Trans\AAB.001 doesn't exist."
End If
 
S

Shawn

Thank you, I think problem I having in my expression. If today is Jan 1st
“Expression converts "StrFolder = ("smp" & Format(Now(), "yy") &
Format(Now(), "y"))" date to “SMP091“instead of “SMP09001†format date
display day digit only.
 
D

Douglas J. Steele

Try

StrFolder = "smp" & Format(Date(), "yy") & Format(DatePart("y", Date()),
"000")
 

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