Solved

Move entire folder from MS Access

Posted on 2013-01-17
9
336 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
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 250 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

830 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