autobackup database (1 Viewer)

THREE05

Registered User.
Local time
Today, 00:34
Joined
Dec 29, 2015
Messages
30
Hi guys.
How can I do to program my database to autobackup with a button or when exit ? I hate to go to file, save as, backup database. I would like something nice like automatic :)

please help :banghead:
 

missinglinq

AWF VIP
Local time
Today, 03:34
Joined
Jun 20, 2003
Messages
6,423
I saw this somewhere, recently, and archived it. I haven't tried it myself, but the OP of the post reported that it worked for him without any problem.

Create a SubFolder to the Folder that holds your Access File, naming it LatestBackups. Next, enter this code into a Standard Module.

Code:
Public Function BackUpAccess()
Dim sourceFile As String, destinationFile As String
Dim aFSO As Variant
Dim path As String, name As String

sourceFile = CurrentProject.FullName
path = CurrentProject.path
name = CurrentProject.name
destinationFile = path & "\LatestBackups\" & Left(name, Len(name) - 6) & "_backup" & "_" & _
Year(Now) & "_" & Month(Now) & "_" & Day(Now) & ".accdb"

'this removes a file created on the same day
If Dir(destinationFile) <> "" Then
Kill destinationFile
End If

'this creates a backup into destination path
If Dir(destinationFile) = "" Then

Set aFSO = CreateObject("Scripting.FileSystemObject")
aFSO.CopyFile sourceFile, destinationFile, True

MsgBox "A database backup has been stored under " & destinationFile
End If
End Function
Save the Module, naming it modBackUp.

In an appropriate event, enter

Code:
Call BackUpAccess()

Linq ;0)>
 

THREE05

Registered User.
Local time
Today, 00:34
Joined
Dec 29, 2015
Messages
30
Exelent my friend I definitely try this and I let you know... have a good day.
 

Users who are viewing this thread

Top Bottom