G
Guest
Hallo
I hope some one can help me im using the Filecopy statment to copy multipal
files from one location to the a diffrent location. The problem im having it
only copys one files and it ignores the rest of them here is my code im
using at the moment. What it does i have a table with the Source path info
and the destination path info. but the last part of the file name has a date.
So what i want it to do is only copy the last 7 days of files. But it only
copys one file even do it goes to the next record it has the correct new
filename and date but it does not copy it. I hope some one can help
Dim SourceFile As String
Dim Destination As String
Dim DateCounter As String
Dim DateC As String
Dim DateC1 As String
DateCounter = 7
Start_Click:
DateCounter = DateCounter - 1
DateC1 = Date - DateCounter
DateC = Format([DateC1], "yyyy-mm-dd")
MsgBox DateC
If DateCounter = 0 Then
GoTo Error_Click
Else
If IsNull([IND]) Then
GoTo RecordReset_Click
Else
GoTo Copy_Click
End If
End If
Exit Sub
RecordReset_Click:
DoCmd.GoToRecord , , acFirst
Error_Click:
MsgBox "Done"
'DoCmd.Close
Exit Sub
Copy_Click:
SourceFile = [Forms]![CopyFiles]![SourcePath] & [DateC] & ".zip"
Destination = [Forms]![CopyFiles]![DestinationPath] & [DateC] & ".zip"
If Dir(SourceFile, vbNormal) <> "" Then
FileCopy SourceFile, Destination
DoCmd.GoToRecord , , acNext
GoTo Start_Click
Else
DoCmd.GoToRecord , , acNext
GoTo Start_Click
End If
I hope some one can help me im using the Filecopy statment to copy multipal
files from one location to the a diffrent location. The problem im having it
only copys one files and it ignores the rest of them here is my code im
using at the moment. What it does i have a table with the Source path info
and the destination path info. but the last part of the file name has a date.
So what i want it to do is only copy the last 7 days of files. But it only
copys one file even do it goes to the next record it has the correct new
filename and date but it does not copy it. I hope some one can help
Dim SourceFile As String
Dim Destination As String
Dim DateCounter As String
Dim DateC As String
Dim DateC1 As String
DateCounter = 7
Start_Click:
DateCounter = DateCounter - 1
DateC1 = Date - DateCounter
DateC = Format([DateC1], "yyyy-mm-dd")
MsgBox DateC
If DateCounter = 0 Then
GoTo Error_Click
Else
If IsNull([IND]) Then
GoTo RecordReset_Click
Else
GoTo Copy_Click
End If
End If
Exit Sub
RecordReset_Click:
DoCmd.GoToRecord , , acFirst
Error_Click:
MsgBox "Done"
'DoCmd.Close
Exit Sub
Copy_Click:
SourceFile = [Forms]![CopyFiles]![SourcePath] & [DateC] & ".zip"
Destination = [Forms]![CopyFiles]![DestinationPath] & [DateC] & ".zip"
If Dir(SourceFile, vbNormal) <> "" Then
FileCopy SourceFile, Destination
DoCmd.GoToRecord , , acNext
GoTo Start_Click
Else
DoCmd.GoToRecord , , acNext
GoTo Start_Click
End If