AOB
Registered User.
- Local time
- Today, 20:24
- Joined
- Sep 26, 2012
- Messages
- 615
Hi guys,
I'm putting together a subroutine to backup the backend of a split DB and compact it. Fairly straightforward; I use FSO to make a copy of the backend file to a separate location (defined with the objBackupFolder object), suffix the name with "Backup" and the date (so I can keep backups for a set period before deleting them), then compact the backup copy using the .tmp file extension, delete the (uncompacted) copy and rename the compacted file back to .accdb.
Here's how it looks at the moment (edited down for clarity) :
It works fine but I keep getting this warning message from Access :
...at the line highlighted in red? (Twice - once for the new .accdb and once for the new .tmp)
Normally I like warnings and I'm pretty careful about switching them off (and switching them back on again as early as possible!) but I know these files are safe (I'm generating them!) so I'd like to circumvent the warning if possible?
I've tried using :
But it doesn't prevent the warnings?
Any suggestions? Or is it even possible?
Thanks
AOB
I'm putting together a subroutine to backup the backend of a split DB and compact it. Fairly straightforward; I use FSO to make a copy of the backend file to a separate location (defined with the objBackupFolder object), suffix the name with "Backup" and the date (so I can keep backups for a set period before deleting them), then compact the backup copy using the .tmp file extension, delete the (uncompacted) copy and rename the compacted file back to .accdb.
Here's how it looks at the moment (edited down for clarity) :
Code:
[FONT=Courier New]Public Sub BackupBackEnd()[/FONT]
[FONT=Courier New] Dim objFSO As Object[/FONT]
[FONT=Courier New] Dim objBackupFolder As Object[/FONT]
[FONT=Courier New] Dim strBackEndDatabase As String[/FONT]
[FONT=Courier New] Dim strBackEndDatabaseCopy As String[/FONT]
[FONT=Courier New] Set objFSO = CreateObject("Scripting.FileSystemObject")[/FONT]
[FONT=Courier New] ' Make a copy of the backend[/FONT]
[FONT=Courier New] strBackEndDatabaseCopy = objBackupFolder.Path & "\" & Replace(Dir$(strBackEndDatabase), ".accdb", " Backup " & Format(Now, "dd mmm yyyy") & ".accdb")[/FONT]
[FONT=Courier New] objFSO.CopyFile strBackEndDatabase, strBackEndDatabaseCopy, True[/FONT]
[FONT=Courier New] ' Compact the backup to a .tmp file[/FONT]
[FONT=Courier New][COLOR=red] Application.CompactRepair strBackEndDatabaseCopy, strBackEndDatabaseCopy & ".tmp"[/COLOR][/FONT]
[FONT=Courier New] ' Delete the uncompacted backup database[/FONT]
[FONT=Courier New] objFSO.DeleteFile strBackEndDatabaseCopy[/FONT]
[FONT=Courier New] ' Rename the compacted backup database[/FONT]
[FONT=Courier New] Name strBackEndDatabaseCopy & ".tmp" As strBackEndDatabaseCopy[/FONT]
[FONT=Courier New]End Sub[/FONT]
It works fine but I keep getting this warning message from Access :
Microsoft Office Access Security Notice
A potential security concern has been identified
This file might contain unsafe content that could harm your computer. Do you want to open this file or cancel the operation?
...at the line highlighted in red? (Twice - once for the new .accdb and once for the new .tmp)
Normally I like warnings and I'm pretty careful about switching them off (and switching them back on again as early as possible!) but I know these files are safe (I'm generating them!) so I'd like to circumvent the warning if possible?
I've tried using :
Code:
DoCmd.SetWarnings False
But it doesn't prevent the warnings?
Any suggestions? Or is it even possible?
Thanks
AOB