Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Move entire folder from MS Access

Posted on 2013-01-17
9
Medium Priority
?
340 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 1000 total points
ID: 38787346
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 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1000 total points
ID: 38787359
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
ID: 38787368
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:correlate
ID: 38787493
Brilliant - thank you very much
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38787559
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
ID: 38787588
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
ID: 38787611
Thanks... if you click the request attention button a mod can reopen it for you.
0
 

Author Closing Comment

by:correlate
ID: 38792196
Excellant - thanks for your help
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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