G
Guest
Can anyone see what I am doing wrong with the FileCopy line??? What is going
on here is that the code is reading a folder and taking all the mdbs and
compacts them into a new folder as a backup and then moves them out to a
shared area for safety backup.
The FileCopy line is blowing and I don't know why. Is there any guidance
someone can give me???
Public Function BackUpFiles(sSourceDir As String, sDestDir, kDestDir)
Dim FileSys As FileSystemObject
Dim File As File
Dim Folder As Folder
Set FileSys = CreateObject("scripting.FileSystemObject")
Set Folder = FileSys.GetFolder(sSourceDir)
For Each File In Folder.Files
If Right(File.Name, 3) = "mdb" Then
If Not Dir(sDestDir & "\" & File.Name, vbDirectory) =
"" Then
Kill sDestDir & "\" & File.Name
End If
DBEngine.CompactDatabase sSourceDir & "\" & File.Name,
sDestDir & "\" & File.Name
'Kill sSourceDir & "\" & File.Name
FileCopy sDestDir & "\" & File.Name, kDestDir & "\" &
File.Name
End If
Next
End Function
Thanks in advance
on here is that the code is reading a folder and taking all the mdbs and
compacts them into a new folder as a backup and then moves them out to a
shared area for safety backup.
The FileCopy line is blowing and I don't know why. Is there any guidance
someone can give me???
Public Function BackUpFiles(sSourceDir As String, sDestDir, kDestDir)
Dim FileSys As FileSystemObject
Dim File As File
Dim Folder As Folder
Set FileSys = CreateObject("scripting.FileSystemObject")
Set Folder = FileSys.GetFolder(sSourceDir)
For Each File In Folder.Files
If Right(File.Name, 3) = "mdb" Then
If Not Dir(sDestDir & "\" & File.Name, vbDirectory) =
"" Then
Kill sDestDir & "\" & File.Name
End If
DBEngine.CompactDatabase sSourceDir & "\" & File.Name,
sDestDir & "\" & File.Name
'Kill sSourceDir & "\" & File.Name
FileCopy sDestDir & "\" & File.Name, kDestDir & "\" &
File.Name
End If
Next
End Function
Thanks in advance