Can we backup automatic with every open time file open?
Can we backup automatic with every open time file open?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I got backup code but getting error report
I also want to backup file name should be Present date and Time
Code:
Public Function db_backup()
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 & "\db backups - please do not remove\" & 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
What error? What line triggers the error? Have you step debugged?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Wow, an explicit error message! VBA can't find the file path. Are you sure the string is correct? Have you step debugged? Is the variable set with the correct value? Review link at bottom of my post for debugging guidelines.
The code syntax is fine, I use it, except I don't bother with the aFSO variable:
CreateObject("Scripting.FileSystemObject").CopyFil e sourceFile, destFile, True
Actually, don't need FileSystemObject with this alternative:
FileCopy sourceFile, destFile
Another problem could be file folder permissions.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I can't get success of ridding over it. can you please send me an example file have this Funciton/Command.
I do not understand anything
I debug but not find any thing like this.
Thank Your
Plz plz help me.
Is the computer connected to the network? The file path can not be found.
Why don't you test your destinationFile string before combining it with your path? You could declare a separate string for it and combine that with "path".
You could even hard code the path variable since it really shouldn't change/vary. You would just have to use UNC convention and not a mapped drive.
I would even go as far as declaring the dates into a date variable. Then format that separate date variable before concatenating it in your destinationFile string.
I'm sending you my sample file.
please check where I have made mistake.
Thank You
Loan.zip
All I had to do was create a folder named "db backups - please do not remove" and the code works. You can have the code look for this folder and if not found, create it.
I don't use macros so I changed the [Embedded Macro] of the button to [Event Procedure] and changed the backup Function to a Sub and called the Sub from the button VBA event.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Thank you it works.
but i want to make little change on it.
i have splitted database (FE/BE) which database i have to backup? if i want both database to backup how can I? Teller should have to provided FE database(Access 2007).
Thanks in advance.
I've never programmed for backup, maybe I should but I really just depend on my network server automated backup.
What you are doing is just copying files. Use the paths and filenames you want to copy from/to.
What do you mean 'teller should have to provide'? Who or what is teller and provide what - filename?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
in Programming language database_be should be kept in server and client should be distributed database_fe for transaction.
I want to backup database_be by using database_fe. can it possible?
Thank You
.
CopyPaste.zip
A front end application can copy and paste files it has access to. If you think of your backup code as a copy and paste method, like June7 mentioned, it may help you understand how to accomplish this from the FE. There may be limitations but I believe as long as the security privileges are met, it is all good.
I have attached a sample DB for you to practice with. On a PC, create the following
A folder in your C drive named “Test”
Within that folder create the following…
A text file named “CopyMe” and
A folder named “Result”
In the practice DB I uploaded here I changed the existing code to help illustrate how you can copy and paste when you know what the path and file names are. The paths are hard coded.
In a network environment you want to use the Universal Naming Convention (UNC) rather than a mapped drive or drive letter.
\\ServerName\FolderName\Filename.Extension