Dim TemPath As String
Dim StrKey As String
Dim Tem As String
Set fs = Application.FileSearch
TemPath = CurrentProject.Path & "\bak\"
With fs
.LookIn = CurrentProject.Path & "\bak"
.FileName = "*.mdb"
If .Execute > 0 Then
IntTem = Year(Now()) & Month(Now()) & Day(Now()) & Hour(Now()) & Minute(Now())
If .FoundFiles.Count > 3 Then
For I = 1 To .FoundFiles.Count
StrKey = Right(fs.FoundFiles(I), Len(fs.FoundFiles(I)) - Len(TemPath)) 'filename
StrKey = Left(StrKey, Len(StrKey) - 4)
If IntTem > StrKey Then
IntTem = StrKey
End If
Next I
If IntTem <> Year(Now()) & Month(Now()) & Day(Now()) & Hour(Now()) & Minute(Now()) Then
Kill TemPath & IntTem & ".mdb"
End If
End If
End If
End With
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) | Powered by Discuz! X3.3 |