M
Marsha
First a general disclaimer - I'm not sure that i know what I'm doing;
however, I founds some VBA code that looks like it should be relatively easy
to work with. My goal is to build a module that will save a copy of my
database file, so that I'll have a backup. I'm pasting in a link to the site
with the original code and then the code as a I modified it. Again, I'm
pretty new to trying to modify and work with VBA code, so I could be making a
really stupid, lame mistake. Any help would be greatly appreciated.
http://www.mdbmakers.com/forums/showthread.php?p=15088
Adapted code:
Function fBackup()
' File(s) to copy
DataDBFile = "Scantest.mdb"
DataDBPath = "Z:\Registry\Reg Scan Files\REGISTRY DATABASE FILES\2006
Registry Database\"
' Main directory to store backups
BackupDir = "Z:\Registry\Reg Scan Files\REGISTRY DATABASE FILES\2008 Back Up
Files"
' Subdirectory of above for actual file
NewDirName = Year(Date) & "." & Month(Date) & "." & Day(Date)
' Create File System object
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
' Check if backup folder exists
If Not fso.FolderExists(BackupDir) Then
fso.CreateFolder (BackupDir)
End If
' Create new folder for current backup
Dim fld
Set fld = fso.CreateFolder(BackupDir & "\" & NewDirName)
' Copy file(s)
fso.CopyFile DataDBFile, fso.BuildPath(fld, DataDBFile & ".BACKUP") [THIS IS
WHERE I'M GETTING THE DEBUG ERROR I'M NOT SURE IF MY PATH IS NOT WRITTEN
CORRECTLY ABOVE OR WHAT, THE CODE SEEMS TO WORK FINE UP TO HERE, IT CREATES A
NEW FOLDER ON THE DRIVE AND EVERYTHING]
End Function
however, I founds some VBA code that looks like it should be relatively easy
to work with. My goal is to build a module that will save a copy of my
database file, so that I'll have a backup. I'm pasting in a link to the site
with the original code and then the code as a I modified it. Again, I'm
pretty new to trying to modify and work with VBA code, so I could be making a
really stupid, lame mistake. Any help would be greatly appreciated.
http://www.mdbmakers.com/forums/showthread.php?p=15088
Adapted code:
Function fBackup()
' File(s) to copy
DataDBFile = "Scantest.mdb"
DataDBPath = "Z:\Registry\Reg Scan Files\REGISTRY DATABASE FILES\2006
Registry Database\"
' Main directory to store backups
BackupDir = "Z:\Registry\Reg Scan Files\REGISTRY DATABASE FILES\2008 Back Up
Files"
' Subdirectory of above for actual file
NewDirName = Year(Date) & "." & Month(Date) & "." & Day(Date)
' Create File System object
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
' Check if backup folder exists
If Not fso.FolderExists(BackupDir) Then
fso.CreateFolder (BackupDir)
End If
' Create new folder for current backup
Dim fld
Set fld = fso.CreateFolder(BackupDir & "\" & NewDirName)
' Copy file(s)
fso.CopyFile DataDBFile, fso.BuildPath(fld, DataDBFile & ".BACKUP") [THIS IS
WHERE I'M GETTING THE DEBUG ERROR I'M NOT SURE IF MY PATH IS NOT WRITTEN
CORRECTLY ABOVE OR WHAT, THE CODE SEEMS TO WORK FINE UP TO HERE, IT CREATES A
NEW FOLDER ON THE DRIVE AND EVERYTHING]
End Function