Solved

Move entire folder from MS Access

Posted on 2013-01-17
9
335 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

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.

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…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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…

770 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