Hi. I think so. Have a
look here. Hope it helps...
Hi TheDBGuy and thanks but,
I modified the code as follow but i have problem because there is a password in my backend and i'm getting the error msg.
Option Compare Database
Option Explicit
Public Sub BackUpAndCompactBE()
'Courtesy of Brent Spaulding (datAdrenaline), MVP
'Source:
http://accessmvp.com/theDBguy
On Error GoTo errHandler
Dim oFSO As Object
Dim strDestination As String
Dim strSource As String
'Get the source of your back end
strSource = Split(Split(CurrentDb.TableDefs("tblSettings").Connect, _
"Database=")(1), ";")(0)
'Determine your destination
HERE I WANT A STANTART DESTINATION PATH AS :M:\Backup
strDestination = CurrentProject.Path & "\DATASET_MD216.0.0.1 (" _
& Format(Now, "yyyymmddhhnnss") & ").accde"
'Flush the cache of the current database
DBEngine.Idle
'Create a file scripting object that will backup the db
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.CopyFile strSource, strDestination
Set oFSO = Nothing
'Compact the new file, ...
Name strDestination As strDestination & ".cpk"
DBEngine.CompactDatabase strDestination & ".cpk", strDestination
Kill strDestination & ".cpk"
'Notify users
MsgBox "Backup file '" & strDestination & "' has been created.", _
vbInformation, "Backup Completed!"
errExit:
Exit Sub
errHandler:
MsgBox err.Number & ": " & err.Description
Resume errExit
End Sub