492JQS
Access Muppet
- Local time
- Today, 23:42
- Joined
- Aug 27, 2004
- Messages
- 9
This is a shortened version of a problem I posted in the General Forum a week or so ago but have had no response to. Maybe I'll have more luck here.
I'm using the following code to delete backup files older than ten days:
Dim checkFile
checkFile = Dir(MyBackupPath & "\*.zip", vbDirectory) ' Retrieve the first entry.
Do While checkFile <> "" ' Start the loop.
If (Now - FileDateTime(MyBackupPath & "\" & checkFile)) > 10 Then
Kill MyBackupPath & "\" & checkFile 'Delete file as it is older than 10 days
End If
checkFile = Dir ' Get next entry.
Loop
I'm using the code on the onload event of my switchboard, and the problem is that if the database is not used for 10 days or more it deletes all my backup files! Is there a way to modify the code so it doesn't delete the newest file, even if it is older than 10 days?
I'm using the following code to delete backup files older than ten days:
Dim checkFile
checkFile = Dir(MyBackupPath & "\*.zip", vbDirectory) ' Retrieve the first entry.
Do While checkFile <> "" ' Start the loop.
If (Now - FileDateTime(MyBackupPath & "\" & checkFile)) > 10 Then
Kill MyBackupPath & "\" & checkFile 'Delete file as it is older than 10 days
End If
checkFile = Dir ' Get next entry.
Loop
I'm using the code on the onload event of my switchboard, and the problem is that if the database is not used for 10 days or more it deletes all my backup files! Is there a way to modify the code so it doesn't delete the newest file, even if it is older than 10 days?