Solved

Move entire folder from MS Access

Posted on 2013-01-17
9
332 Views
Last Modified: 2013-01-18
Dear Experts

I am building an HR database in Access & one of the features I want to have is the ability to move an employee's folder when they resign.

An employee's folder will typically have 1/2 a dozen subfolders and lots of different file types stored within

A typical move would be:

from:
C:\Users\xxx\HR\Current Employees\Individual HR Files\Jo Bloggs-1\

to:
C:\Users\xxx\HR\Ex Employees\Individual HR Files\Jo Bloggs-1\

Can anybody help?
0
Comment
Question by:correlate
  • 4
  • 3
9 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 250 total points
Comment Utility
Take a look at this article about moving files and folders... there is a function in there to move folders, which I think is what you want:

http://www.rondebruin.nl/folder.htm

(look at the code for "Sub Move_Rename_Folder()")
0
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 250 total points
Comment Utility
dim fso As Object
 dim fromPath As String
 dim toPath As String
set fso = createObject("scripting.filesystemobject")

frompath="C:\Users\xxx\HR\Current Employees\Individual HR Files\Jo Bloggs-1\"
toPath="C:\Users\xxx\HR\Ex Employees\Individual HR Files\Jo Bloggs-1\

fso.MoveFolder Source:=FromPath, Destination:=ToPath
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
Just a note -

The code in that article uses the File Scripting Object library, so you would have to add a reference.

From the VBA Editor:

Tools -> References , check Microsoft Scripting Runtime


Edit:

Actually never mind the reference.  The code uses Late Binding, so an explicit reference is not needed.
0
 

Author Comment

by:correlate
Comment Utility
Brilliant - thank you very much
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 61

Expert Comment

by:mbizup
Comment Utility
correlate,

The code that capricorn1 posted is exactly what is in the article I linked to.

The difference is that the function in the article contains some additional checks to ensure that the paths specified are valid for those operations.
0
 

Author Comment

by:correlate
Comment Utility
Hi mbizup,

Apologies for that - in my haste I overlooked that - simply saw capricorn1's code there, tried it & it worked - very happy to reallocate as that would seem fairest.
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
Thanks... if you click the request attention button a mod can reopen it for you.
0
 

Author Closing Comment

by:correlate
Comment Utility
Excellant - thanks for your help
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now