السلام عليكم ورحمة الله وبركاته
تفضل هذا كود كامل لغمل نسخة احتياطية من قاعدة البيانات في مجلد خاص
Private Sub Command0_Click()
If MsgBox("هل تريد انشاء نسخة احتياطية من البرنامج", _
vbQuestion + vbYesNo, _
"تاكيد الامر") = vbYes Then
On Error Resume Next
Dim OldFile As String, DBwithEXT, DBwithoutEXT, NewFile As String, CopyMyDB
Dim fs, cf, strFolder
strFolder = CurrentProject.Path & "\Backup"
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FolderExists(strFolder) = False Then
Set cf = fs.CreateFolder(strFolder)
End If
OldFile = CurrentDb.name
StrNew = CurrentProject.Path & "\Backup"
DBwithEXT = Dir(OldFile)
DBwithoutEXT = Left(DBwithEXT, Len(DBwithEXT) - 6)
If [BKUP] = True Then
NewFile = StrNew & "\" & DBwithoutEXT & "-" & Format(Date, "yyyy-mm-dd") & "-" & Format(Now(), "Hh-Nn-Ss-AMPM") & Right(DBwithEXT, 6)
CopyMyDB = "cmd.exe /C copy " & """" & OldFile & """" & " " & """" & NewFile & """"
Shell CopyMyDB, 0
Exit Sub
End If
End If
تحياتي
تفضل ايضا مثال مرفق
Backup.rar