How can I move files from one location to another.

All

How can I move files from one location to another.

I currently have files that are produced every month and 'sent' to specific folders.  I would like to be able to then move these to another folder at the end of the month so that only the current month reports are available in the original folder

Example
Before new reports are 'sent' to the below folder

S:\Statement of Expectations\General Staff\Finance Office

I would like all files within the folder moved to

S:\Statement of Expectations\General Staff\Finance Office\old

Is this possible and if so can I do from a button or even on opening of the database.

TIA

shaz
shaz0503Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can use FileCopy to do this:

Dim sFiles as String

sFiles = Dir("Path to your folder\*.*")

Do Until sFiles = ""
  FileCopy "Source", "Destination"
  sFiles = Dir
Loop

Or you can use Name instead of FileCopy:

Name "Your Old File" As "Your New File"

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shaz0503Author Commented:
Thanks

I have used your suggestion must be doing something wrong.

Below is what I am using - is this correct

Private Sub Command16_Click()
Dim sFiles As String

sFiles = Dir("S:\Statement of Expectations\General Staff\Finance Office\*.*")

Do Until sFiles = ""
  FileCopy "S:\Statement of Expectations\General Staff\Finance Office", "S:\Statement of Expectations\General Staff\Finance Office\Old"
  sFiles = Dir
Loop


End Sub

thx
S
0
Rey Obrero (Capricorn1)Commented:
you did not include the file

sFiles = Dir("S:\Statement of Expectations\General Staff\Finance Office\*.*")

Do while sFiles <> ""
  FileCopy "S:\Statement of Expectations\General Staff\Finance Office\" & sFiles, "S:\Statement of Expectations\General Staff\Finance Office\Old\" & sFiles
  sFiles = Dir
Loop

0
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

shaz0503Author Commented:
Thanks

Works a treat but I neglected to mention in the first instance that I need to cut/remove these files and paste to new directory.

tia

s
0
Rey Obrero (Capricorn1)Commented:
sFiles = Dir("S:\Statement of Expectations\General Staff\Finance Office\*.*")

Do while sFiles <> ""
  FileCopy "S:\Statement of Expectations\General Staff\Finance Office\" & sFiles, "S:\Statement of Expectations\General Staff\Finance Office\Old\" & sFiles

  'check if the file was copied
 if dir("S:\Statement of Expectations\General Staff\Finance Office\Old\" & sFiles) <> "" then
      'delete the file from the original folder
         kill "S:\Statement of Expectations\General Staff\Finance Office\" & sFiles
 end if

  sFiles = Dir
Loop
0
Rey Obrero (Capricorn1)Commented:
here is another way to move the file

sFiles = Dir("S:\Statement of Expectations\General Staff\Finance Office\*.*")

Do while sFiles <> ""

        name  "S:\Statement of Expectations\General Staff\Finance Office\" & sFiles  as  "S:\Statement of Expectations\General Staff\Finance Office\Old\" & sFiles


  sFiles = Dir
Loop
0
shaz0503Author Commented:
Thanks both -
Have been on leave and neglected to answer sooner,,,

This turns out to be a bigger than is worth..

Will continue to do the old way....

rgds
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.