Thank you ridders52,
Code:
I'm sorry - I need to treat that as proprietary software
It is a pity but i will write similar code which unfortunately will take more time.
And will share here for others ;-)
Code:
I use code to create the backup as already explained
Code:
When a backup is made
It is a bunch of methods for creating backups, are you just copying database or what VBA code are you using?
Code:
Disagree with your comment in brackets
I also compact the backup copy - C&R can cause issues on current copy in certain circumstances but if done wisely it's a very important developers tool
You can do it of course but when you are working in network environment and something goes wrong (for example connection error) your database copy will be corrupted.
Good post where i was asking about it is here:
https://www.accessforums.net/showthread.php?t=67800
I also used automatically backups , here is my code:
Code:
Set fso = CreateObject("Scripting.FileSystemObject")
Set db = CurrentDb
DateUnderscore = Format(Now(), "yyyy-mm-dd")
FilePath = "\\nt-wro4-01\dane\ihrm\dokument\worek\KADRY\DOKUMENTY _BRAKI\Back-End\"
OriginalFile = "Aplikacja_Braki_BE.accdb"
FileWithoutExtention = Left(OriginalFile, InStr(OriginalFile, ".") - 1)
DoCmd.Hourglass True
FilePathDestination = "\\nt-wro4-01\dane\ihrm\dokument\worek\KADRY\DOKUMENTY _BRAKI\Archiwum_kopie\"
TryAgain:
'Compact the Back-End database to a temp file.
If CheckLock(FilePath & OriginalFile) = True Then
Access.Quit
End If
DBEngine.CompactDatabase FilePath & OriginalFile, FilePath & FileWithoutExtention & "Temp.mdb", , , ";pwd=1234"
'Delete the previous backup file if it exists.
If Dir(FilePathDestination & FileWithoutExtention & ".bak") <> "" Then
Kill FilePathDestination & FileWithoutExtention & ".bak"
End If
'Rename the current database as backup and rename the temp file to
'the original file name.
Name FilePath & OriginalFile As FilePath & FileWithoutExtention & ".bak"
fso.copyfile FilePath & FileWithoutExtention & ".bak", FilePathDestination & FileWithoutExtention & ".bak"
Kill FilePath & FileWithoutExtention & ".bak"
Name FilePath & FileWithoutExtention & "Temp.mdb" As FilePath & OriginalFile
DoCmd.Hourglass False
Access.Quit
Exit_cmdCompact:
Exit Function
Err_cmdCompact:
If Err.Number = 3356 Then
Resume TryAgain
ElseIf Err.Number = 3045 Then
Resume TryAgain
Else
MsgBox Err.Number & ": " & Err.Description
Resume Exit_cmdCompact
End If
Best Wishes,
Jacek