Solved

Move entire folder from MS Access

Posted on 2013-01-17
9
338 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 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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 …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

752 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