Thêm hàm tạo file CSDL backup
Mã:
Function fMakeBackup() As Boolean
Dim Source As String
Dim Target As String
Dim retval As Integer
Dim CheckExists As Boolean
Source = ThisWorkbook.Path & "\GCSCAK.accdb"
Target = ThisWorkbook.Path & "\Backup\GCSCAK"
Target = Target & Format(Date, "mm-dd") & ".accdb"
'Target = Target & Format(Time, "hh-mm") & ".accdb"
' create the backup
retval = 0
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
CheckExists = objFSO.FileExists(Target)
If CheckExists = True Then
'Call objFSO.deletefile(Target)
objFSO.deletefile (Target)
'MsgBox ("da xoa")
Else
MsgBox ("The file does not exist")
End If
retval = objFSO.CopyFile(Source, Target, True)
Set objFSO = Nothing
End Function