Moving Folders via VBA (1 Viewer)

jtgarrison85

New member
Local time
Yesterday, 23:14
Joined
Mar 10, 2023
Messages
6
Good morning -

Within my database, I have a flag that will determine if the Project is Current or Archive.

Depending on the flag, I want to copy all files in the subdirectory from one file share to another. I want to do all of this via VBA.

Thanks in advance.

Jeff
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:14
Joined
Oct 29, 2018
Messages
21,477
Hi Jeff. Welcome to AWF!

You have plenty of choices. Check ou the Name As statement or the FileCopy and Kill commands or check out the File System Object.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:14
Joined
Feb 28, 2001
Messages
27,193
Add to that the possibility of creating a command-line "SHELL" operation to bulk-rename files with wildcards as part of the name selection, if the names are predictable and follow a pattern.
 

jtgarrison85

New member
Local time
Yesterday, 23:14
Joined
Mar 10, 2023
Messages
6
They somewhat follow the same pattern -

The root would be the project number and then there could be numerous sub-folders underneath.

I need to be able to grab the project number and tell Access to move everything in that folder from the old location to the new location.

The easier the better. I want to be able to be in the project and tell it to move on the fly as well as be able to run a process that looks at the project close date and move everything 90+ days on the admin side (button in my admin options).
 

JonXL

Active member
Local time
Yesterday, 22:14
Joined
Jul 9, 2021
Messages
153
You want to move everything from folder A to folder B?

This is easy enough. How does folder B come to exist?
 

jtgarrison85

New member
Local time
Yesterday, 23:14
Joined
Mar 10, 2023
Messages
6
Correct, including subfolders.

Then delete the source files/folders.
 

bastanu

AWF VIP
Local time
Yesterday, 20:14
Joined
Apr 13, 2010
Messages
1,402
As already suggested by the_Doc_Man using the Name statement would probably be the easiest as it does all actions in one step(create new\copy\remove old):


Cheers,
 

jtgarrison85

New member
Local time
Yesterday, 23:14
Joined
Mar 10, 2023
Messages
6
It won't work using UNCs will it?

I am trying to archive old projects. In doing so, I want to move their network attachments to another file share.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:14
Joined
Feb 28, 2001
Messages
27,193
If the UNC is correct, copying a folder from point A to point B will do fine. So will drive-letter:/path/ format. In fact, technically you ALWAYS use UNC because since WinNT, drive-letter is treated as an alias anyway. So a drive-letter specification gets translated internally before use.
 

Users who are viewing this thread

Top Bottom