N
Xin chào cả nhà ! em có vấn đề nho nhỏ mong được chỉ giúp. Em dùng code bên dưới để backup DB xong em muốn Rar/Zip file này lại luôn cho gọn nhưng không biết cách làm thế nào ?
Public Function BackupDB()
Dim strCompactFrom As String
Dim strCompactTo As String
Dim strPath As String
strPath = CurrentProject.path & "\"
strCompactFrom = "Database.mdb"
strCompactTo = Right("0" & Day(Now()), 2) & Right("0" & Month(Now()), 2) & Right("0" & Year(Now()), 2) & Hour(Now()) & Minute(Now()) & Second(Now()) & ".mdb"
If Dir(strPath & "Backup", vbDirectory) = "" Then
MkDir strPath & "Backup"
End If
If Dir(strPath & "Backup\" & strCompactTo, vbDirectory) <> "" Then
Kill strPath & "Backup\" & strCompactTo
End If
DBEngine.CompactDatabase strPath & strCompactFrom, strPath & "Backup\" & strCompactTo
'Name strPath & strCompactTo As strPath & strCompactFrom
MsgBox "Compact Database successful !"
End Function
Public Function BackupDB()
Dim strCompactFrom As String
Dim strCompactTo As String
Dim strPath As String
strPath = CurrentProject.path & "\"
strCompactFrom = "Database.mdb"
strCompactTo = Right("0" & Day(Now()), 2) & Right("0" & Month(Now()), 2) & Right("0" & Year(Now()), 2) & Hour(Now()) & Minute(Now()) & Second(Now()) & ".mdb"
If Dir(strPath & "Backup", vbDirectory) = "" Then
MkDir strPath & "Backup"
End If
If Dir(strPath & "Backup\" & strCompactTo, vbDirectory) <> "" Then
Kill strPath & "Backup\" & strCompactTo
End If
DBEngine.CompactDatabase strPath & strCompactFrom, strPath & "Backup\" & strCompactTo
'Name strPath & strCompactTo As strPath & strCompactFrom
MsgBox "Compact Database successful !"
End Function

