Access.2007.VBA.Bibl..

(John Hannent) #1

Back up Database ....................................................................................................


The BackupFrontEndfunction is called from the USysRegInfo table to back up the current data-
base to the path selected in the Extra Options dialog:


Public Function BackupFrontEnd()
‘Called from USysRegInfo

On Error GoTo ErrorHandler

Set dbsCalling = CurrentDb
Set tdfsCalling = dbsCalling.TableDefs
Set fso = CreateObject(“Scripting.FileSystemObject”)
strCurrentDB = Application.CurrentProject.Name
Debug.Print “Current db: “ & strCurrentDB
intExtPosition = InStr(strCurrentDB, “.”)
strExtension = Mid(strCurrentDB, intExtPosition)
intExtLength = Len(strExtension)

Create the backup path string depending on the user’s choice, with a default of 2 (“Backups folder
under the database folder”) in case the user has not made a choice:


strPropName = “BackupChoice”
strBackupChoice = GetProperty(strPropName, “2”)
Debug.Print “Backup choice: “ & strBackupChoice
strPropName = “BackupPath”
strPath = GetProperty(strPropName, “”)
Debug.Print “Custom backup path: “ & strPath

Select Case strBackupChoice

Case “1”

Same folder as database


strBackupPath = _
Application.CurrentProject.Path & “\”

Case “2”

Backups folder under database folder


strBackupPath = _
Application.CurrentProject.Path & “\Backups\”

Case “3”

Creating Access Add-ins 14

Free download pdf