Results 1 to 15 of 15
  1. #1
    joshynaresh is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Aug 2013
    Posts
    131

    auto backup of database with every open

    Can we backup automatic with every open time file open?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    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.

  3. #3
    joshynaresh is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Aug 2013
    Posts
    131
    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

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    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.

  5. #5
    joshynaresh is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Aug 2013
    Posts
    131
    error type
    Click image for larger version. 

Name:	error.jpg 
Views:	47 
Size:	22.8 KB 
ID:	13903Click image for larger version. 

Name:	debug.jpg 
Views:	49 
Size:	81.5 KB 
ID:	13904

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    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.

  7. #7
    joshynaresh is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Aug 2013
    Posts
    131
    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.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    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.

  9. #9
    joshynaresh is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Aug 2013
    Posts
    131

    auto backup of database with every open

    I'm sending you my sample file.
    please check where I have made mistake.
    Thank You
    Loan.zip

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    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.

  11. #11
    joshynaresh is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Aug 2013
    Posts
    131
    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.

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    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.

  13. #13
    joshynaresh is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Aug 2013
    Posts
    131
    in Programming language database_be should be kept in server and client should be distributed database_fe for transaction.

  14. #14
    joshynaresh is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Aug 2013
    Posts
    131
    I want to backup database_be by using database_fe. can it possible?
    Thank You

  15. #15
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by joshynaresh View Post
    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

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Save database as backup
    By MadeCurler in forum Access
    Replies: 3
    Last Post: 11-08-2012, 06:59 AM
  2. Search employees backup database
    By mademen in forum Access
    Replies: 4
    Last Post: 12-19-2011, 03:30 PM
  3. access database backup...
    By alex_raju in forum Access
    Replies: 5
    Last Post: 07-17-2011, 09:00 AM
  4. Auto Backup
    By jo15765 in forum Access
    Replies: 17
    Last Post: 11-23-2010, 11:57 AM
  5. Database backup automation
    By aat in forum Access
    Replies: 2
    Last Post: 09-17-2010, 07:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums