Copy everything below between the double lines, into a new module, changing the red paths appropriately. The FROMPATH is the folder in which the files currently reside, and the TOPATH is where you want them copied to. That's it.
Now to run it, you can either go to the debug window (ctrl + G) and type the following, or put it on the click event of a button:
Call BackupFiles()
====================
Public Const FROMPATH As String = "C:\TestFolder\"
Public Const TOPATH As String = "C:\TestFolder\BackupFolder\"
-------------------
Public Sub BackupFiles()
On Error GoTo Err_Import
Dim strFile As String, strOldFile As String, strNewFile As String
strFile = Dir(FROMPATH & "*.*"
DoCmd.Hourglass True
Do While strFile <> ""
strOldFile = FROMPATH & strFile
strNewFile = TOPATH & strFile
FileCopy strOldFile, strNewFile
Kill strOldFile
strFile = Dir
Loop
Exit_Import:
DoCmd.Hourglass False
MsgBox "Process Complete"
Exit Sub
Err_Import:
MsgBox Err & Err.Description, , "Error in Import"
Resume Exit_Import
End Sub
====================
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.