How to Get Access to Move a File in the File System

whdyck

Registered User.
Local time
Today, 09:00
Joined
Aug 8, 2011
Messages
169
I'm using Access 2003.

I have VBA code that imports a CSV file into an Access temp table. After the import, I'd like Access to move the CSV file into a "Processed" folder so the end user doesn't try to import it again.

I've googled on this, but there seem to be a bunch of different recommendations. Ideally, I'd like it to do the move only if the file imported successfully, so I'd probably want to put the command(s) inside a transaction. I know how to do transaction processing, just unsure of the right approach for the move(s).

Thanks for any help you can give.

Wayne
 
Use

Name OldPathAndNameHere NewPathAndNameHere

So, like this:

Name "C:\Temp\MyFile.csv" "C:\Processed\MyFile.csv"
 
Use

Name OldPathAndNameHere NewPathAndNameHere

So, like this:

Name "C:\Temp\MyFile.csv" "C:\Processed\MyFile.csv"

Wow! That's awesome.

Thanks, Bob.
 
On a related note, ...

Is it possible to use the Name command to move the file using from and to locations *relative* to the MDB or MDE file that is running (rather than an absolute reference)?

I'd like to make it so that I can move the entire directory structure that contains the MDB, source files, and destination folder and it will still work.

I tried doing something like
Code:
Name ".\CSVInput\...\Infile.csv" AS ".\CSVProcessed\...\Infile.csv"
but it doesn't like it.

Any way to get this to work?

Thanks.

Wayne
 

Users who are viewing this thread

Back
Top Bottom