Hi I have a split database and a code to backup the back end at the front end however I want the back end to backed up in a folder called "Backups" a the Back End and not at the front end. This is the code am using now to back up the destination at the front end. Please help me change the destination to the back end(Server)
Code:
Public Sub BackUpDatabase() On Error GoTo Err_Handler Dim oFSO As Object Dim strDestination As String Dim strSource As String Dim path As String, name As String path = CurrentProject.path name = CurrentProject.name Const conPATH_FILE_ACCESS_ERROR = 75 'Get the source of the back end strSource = Split(Split(CurrentDb.TableDefs("AssessmentT").Connect, "Database=")(1), ";")(0) 'Determine backup destination strDestination = path & "\" & Left(name, Len(name) - 6) & "_backup" & "_" & _ Year(Now) & "_" & Month(Now) & "_" & Day(Now) & ".accdb" 'this removes a file created on the same day If Dir(strDestination) <> "" Then Kill strDestination End If 'this creates a backup into destination path If Dir(strDestination) = "" Then '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!" End If Exit_Button_Backup: Exit Sub Err_Handler: If Err.Number = conPATH_FILE_ACCESS_ERROR Then MsgBox "The following Path, " & strDestination & ", already exists or there was an Error " & _ "accessing it!", vbExclamation, "Path/File Access Error" Else MsgBox Err.Description, vbExclamation, "Error Creating " & strDestination End If Resume Exit_Button_Backup End Sub
Comment