Results 1 to 12 of 12
  1. #1
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Backup DB on close (Access 2000 >)

    I doubt this is possible, but then again...the lounge has proven me wrong countless times!

    I was asked by a customer the other day if it was possible that when she closes her DB (working from a laptop connected to the company network) the DB can be automatically backed up?

    I mentioned it may be useful to use replication as an alternative, but just to satisfy curiosity, is there a way to automatically do backups when the DB closes. (If not from Access, how about from windows???)

    Weird Q, eh!
    Tx
    Regards,
    Rudi

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Backup DB on close (Access 2000 >)

    I would certainly shy away from using replication as a backup method - it adds considerable overhead to most databases, and has a number of undesirable side effects. In general, Access databases can be backed up even if they are open, since it involves simply copying the file. We typically suggest using one of the commercial backup utilities for this sort of thing, but even the Win XP backup program could be used. With lots of complex coding and using multiple databases, you can do this sort of thing, but its usually pretty difficult to justify.
    Wendell

  3. #3
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Backup DB on close (Access 2000 >)

    Thx for the reply Wendell. You have given me some good advice, but can a DB be backed up using the On_Close event, or using any other method other than manual copy and paste. The customer wants it automated when she closes the DB. I'm not sure if backup utility programs can do this when the DB closes...

    Tx
    Regards,
    Rudi

  4. #4
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Backup DB on close (Access 2000 >)

    You can use FileCopy to copy the file, but this usually fails if the file in question is still open. So my advice would be to create a seperate file which, on opening, copies your database after a short pause. You could then open this file on closing your database.
    Waggers
    If at first you do succeed, you've probably missed something.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Backup DB on close (Access 2000 >)

    If you have a split front-end back-end application, you can make sure all open links to tables are closed and then simply use code to compact the back end to another file name. That is a method we use all the time for this purpose.
    Charlotte

  6. #6
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Backup DB on close (Access 2000 >)

    How complex is the code Charlotte. Is it possible to post a sample of the code that does the backup?

    When you say >>> make sure all open links to tables are closed, are you meaniong that the DB is opened exclusively?

    Tx
    Regards,
    Rudi

  7. #7
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Backup DB on close (Access 2000 >)

    Perhaps you could use the code provided by Helen Feddema (accarch115.zip from http://www.helenfeddema.com/access.htm ) so that when the user clicks a button to Exit, the code would backup the database and then Quit.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  8. #8
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Backup DB on close (Access 2000 >)

    Many thanx Judy for this find. This is great. Thanx to you and Helen.
    I certainly can use the code and modify as needed!
    Cheers
    Regards,
    Rudi

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Backup DB on close (Access 2000 >)

    The code is two lines, plus some stuff to validate the paths, etc:

    <code> DoEvents
    DBEngine.CompactDatabase strFile, strFileBack </code>

    strFile is the full path and filename of the backend database and strFileBack is the full destination path and filename of the backup copy.

    As for open links, I just meant that you need to make sure there are no forms open in edit mode.
    Charlotte

  10. #10
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Backup DB on close (Access 2000 >)

    Awesome Charlotte.
    Do you put these two lines into the application.exit event?
    Regards,
    Rudi

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Backup DB on close (Access 2000 >)

    The Application object in Access doesn't have events. The code could go into the On Close event of the main form of the database (if it isn't bound to a table in the backend).

  12. #12
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Backup DB on close (Access 2000 >)

    <img src=/S/blush.gif border=0 alt=blush width=15 height=15> - Silly me!!

    That comes from typing without thinking. Thank for the answer!
    Regards,
    Rudi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •