Not too sure if im on the correct forum on for this but im using this code on an excel workbook:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim filesys
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("S:\Shipping Receiving\Extrusion\dbExtrusion Receiving.mdb") Then
filesys.CopyFile "S:\Shipping Receiving\Extrusion\dbExtrusion Receiving.mdb", "S:\AC 174 Railing Certification Program\Database Backups\Backup of dbExtrusion Receiving " & Month(Now()) & "-" & Day(Now()) & "-" & Year(Now()) & " at " & Hour(Now()) & "-" & Minute(Now()) & ".mdb"
End If
End Sub
The code makes a backup copy of an access database via an excel spreadsheet when a user clicks save. The code works well, the problem now is disc space. i would like to keep only the most recent 50 backups, so i would need the code to check the file path, count the number of files, and delete the older files until the number of files is 50. Is this possible?
Bookmarks