Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

RE: Auto backup in Access?

Discussion in 'Information Technology' started by '69 Camaro, Oct 28, 2005.

  1. '69 Camaro

    '69 Camaro
    Expand Collapse
    Guest

    Hi, Paul.

    This backup command is for backing up "another" database file, not the
    current one. Apparently, it's for backing up an MSDE database back end, not
    a Jet front end. Please see the following Web page for a mention of this
    using VBA code:

    http://groups.google.com/group/micr...public.access.*&rnum=9&hl=en#9a45b66ad105bd8d

    > Is there an autobackup function somewhere that will do it for me?


    No. Probably because it's not safe to back up an Access database file while
    it's open. However you could try the following code, and if you have the
    correct version of Access, then not only will it create a backup file for
    you, Access won't crash afterwards. To use this code, create a button on a
    form and name it BackUpDBBtn, then paste the following code into the form's
    module, then save and compile the code. Save all of your work in this
    database now. Open the form in Form View and select the BackUpDBBtn button.
    Watch out for word wrap:

    Private Sub BackUpDBBtn_Click()

    On Error GoTo ErrHandler

    CommandBars("Menu Bar").Controls("Tools"). _
    Controls("Database utilities").Controls("Back up database..."). _
    accDoDefaultAction

    Exit Sub

    ErrHandler:

    MsgBox "Error in BackUpDBBtn_Click( ) in" & vbCrLf & _
    Me.Name & " form." & vbCrLf & vbCrLf & _
    "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    Err.Clear

    End Sub ' BackUpDBBtn_Click( )

    HTH.
    Gunny

    See http://www.QBuilt.com for all your database needs.
    See http://www.Access.QBuilt.com for Microsoft Access tips.

    (Please remove ZERO_SPAM from my reply E-mail address so that a message will
    be forwarded to me.)
    - - -
    If my answer has helped you, please sign in and answer yes to the question
    "Did this post answer your question?" at the bottom of the message, which
    adds your question and the answers to the database of answers. Remember that
    questions answered the quickest are often from those who have a history of
    rewarding the contributors who have taken the time to answer questions
    correctly.


    "paulpenta" wrote:

    > I wanted to RunCommand Backup in a macro for an Exit button. I get an error
    > message that I can't do that to an open database from either a macro or VB.
    >
    > Is there an autobackup function somewhere that will do it for me?
    >
    > And, BTW, if I can't do it from a Macro (I don't speak VB), why is that
    > option available in the drop down for the RunCommand action?
    >
    > Thanks
     
  2. Loading...

    Similar Threads Forum Date
    Opinion Is Autocomplete Evil? Some Women Take A Hard Look at Google ! Breaking News Nov 7, 2013
    Sikh News AutoZone sued for firing Everett Sikh Breaking News Sep 29, 2010
    India Singh: Centre Ready To Give Kashmir Autonomy Breaking News Aug 11, 2010
    India Paste tariff cards behind driver’s seat: Transport dept to automen Breaking News Jul 21, 2010
    Gursharan Kaur: India's First Lady's Autobiography Sikh Personalities Jun 1, 2010

  3. paulpenta

    paulpenta
    Expand Collapse
    Guest

    Hi Gunny,

    OK I understand that you can't backup a file while it's open. So, (being an
    old DOSer)if I knew the correct Access C:\=> command line syntax, I could
    write a batch file that would open my application and then back it up from
    DOS, right? Like this:


    Mybatch.bat

    Access <filename>.mdb
    echo Backing Up <filename>.mdb
    Copy <filename.mdb> fileback.mdb

    And I know that Windows would construct an icon for the desktop.

    What do you think?

    Thanks


    "'69 Camaro" wrote:

    > Hi, Paul.
    >
    > This backup command is for backing up "another" database file, not the
    > current one. Apparently, it's for backing up an MSDE database back end, not
    > a Jet front end. Please see the following Web page for a mention of this
    > using VBA code:
    >
    > http://groups.google.com/group/micr...public.access.*&rnum=9&hl=en#9a45b66ad105bd8d
    >
    > > Is there an autobackup function somewhere that will do it for me?

    >
    > No. Probably because it's not safe to back up an Access database file while
    > it's open. However you could try the following code, and if you have the
    > correct version of Access, then not only will it create a backup file for
    > you, Access won't crash afterwards. To use this code, create a button on a
    > form and name it BackUpDBBtn, then paste the following code into the form's
    > module, then save and compile the code. Save all of your work in this
    > database now. Open the form in Form View and select the BackUpDBBtn button.
    > Watch out for word wrap:
    >
    > Private Sub BackUpDBBtn_Click()
    >
    > On Error GoTo ErrHandler
    >
    > CommandBars("Menu Bar").Controls("Tools"). _
    > Controls("Database utilities").Controls("Back up database..."). _
    > accDoDefaultAction
    >
    > Exit Sub
    >
    > ErrHandler:
    >
    > MsgBox "Error in BackUpDBBtn_Click( ) in" & vbCrLf & _
    > Me.Name & " form." & vbCrLf & vbCrLf & _
    > "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
    > Err.Clear
    >
    > End Sub ' BackUpDBBtn_Click( )
    >
    > HTH.
    > Gunny
    >
    > See http://www.QBuilt.com for all your database needs.
    > See http://www.Access.QBuilt.com for Microsoft Access tips.
    >
    > (Please remove ZERO_SPAM from my reply E-mail address so that a message will
    > be forwarded to me.)
    > - - -
    > If my answer has helped you, please sign in and answer yes to the question
    > "Did this post answer your question?" at the bottom of the message, which
    > adds your question and the answers to the database of answers. Remember that
    > questions answered the quickest are often from those who have a history of
    > rewarding the contributors who have taken the time to answer questions
    > correctly.
    >
    >
    > "paulpenta" wrote:
    >
    > > I wanted to RunCommand Backup in a macro for an Exit button. I get an error
    > > message that I can't do that to an open database from either a macro or VB.
    > >
    > > Is there an autobackup function somewhere that will do it for me?
    > >
    > > And, BTW, if I can't do it from a Macro (I don't speak VB), why is that
    > > option available in the drop down for the RunCommand action?
    > >
    > > Thanks
     
  4. '69 Camaro

    '69 Camaro
    Expand Collapse
    Guest

    Hi, Paul.

    "paulpenta" wrote:

    > if I knew the correct Access C:\=> command line syntax, I could
    > write a batch file that would open my application and then back it up from
    > DOS, right?


    Try these examples (watch out for word wrap):

    BkupMDB.BAT:

    Echo Off
    Echo Backing up database file C:\MyDB.mdb to C:\BkUp\MyDB_BkUp.mdb
    Copy /B C:\MyDB.mdb /B C:\BkUp\MyDB_BkUp.mdb
    Echo Backup successful.
    Echo On

    .. . . or in a Windows shortcut Target (watch out for word wrap, as it's all
    one line):

    "C:\Program Files\Microsoft Office\OFFICE11 \MSACCESS.EXE" "C:\MyDB.mdb "
    /compact "C:\BkUp\MyDB_BkUp.mdb"

    .. . . where C:\MyDB.mdb is the database to be backed up, and
    C:\BkUp\MyDB_BkUp.mdb is the back up.

    > What do you think?


    If you add error handling to the batch file, it will be the safer of the two
    options, because the Windows shortcut will actually open the database in
    exclusive mode, then compact it to the destination. If there's a problem,
    then you won't have a safe backup, just a failed compaction.

    HTH.
    Gunny

    See http://www.QBuilt.com for all your database needs.
    See http://www.Access.QBuilt.com for Microsoft Access tips.

    (Please remove ZERO_SPAM from my reply E-mail address so that a message will
    be forwarded to me.)
    - - -
    If my answer has helped you, please sign in and answer yes to the question
    "Did this post answer your question?" at the bottom of the message, which
    adds your question and the answers to the database of answers. Remember that
    questions answered the quickest are often from those who have a history of
    rewarding the contributors who have taken the time to answer questions
    correctly.


    > Hi Gunny,
    >
    > OK I understand that you can't backup a file while it's open. So, (being an
    > old DOSer)if I knew the correct Access C:\=> command line syntax, I could
    > write a batch file that would open my application and then back it up from
    > DOS, right? Like this:
    >
    >
    > Mybatch.bat
    >
    > Access <filename>.mdb
    > echo Backing Up <filename>.mdb
    > Copy <filename.mdb> fileback.mdb
    >
    > And I know that Windows would construct an icon for the desktop.
    >
    > What do you think?
    >
    > Thanks
     

Share This Page