Results 1 to 9 of 9
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Backing up Currently Open MDB (2003)

    I've prepared a sub(SaveMDB on the attached file) that backs up the currently open mdb onto the medium of one's choice.
    The code stops at the line

    file1.Copy (FileProvMdb)

    with the message: Authorization denied

    What could the reason be?

  2. #2
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Backing up Currently Open MDB (2003)

    I don't know the answer to this specifically, but you can't usually *copy* an open file. Have you tried using File.SaveAs [newfilename] followed by File.SaveAs [originalfilename] (using the proper syntax, of course), instead?
    Beryl M


  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Backing up Currently Open MDB (2003)

    Thank you Beryl,
    What is the proper syntax for using the SaveAs method?
    I've tried
    file1.saveas FileProvMdb
    but I get the message:
    Property or method not supported by the object.

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

    Re: Backing up Currently Open MDB (2003)

    That line executed without error when I tried it, but it may not be a good idea to backup the currently open database.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Backing up Currently Open MDB (2003)

    Sorry, I don't use Access VBA so I can't answer that specifically! However, the syntax would usually be (in Word/XL etc)

    ActiveDocument.SaveAs FileName:="name"

    Filename can include the full path as well as the name itself, so you'd have two lines to first save a copy in the new location and then secondly resave it back in the old location. I don't know what your "file1" is but unless it's a variable defined as a document it wouldn't be suitable here.

    Good luck!
    Beryl M


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

    Re: Backing up Currently Open MDB (2003)

    The "Save As" feature in Access won't save the .mdb file, but will only save the current object (table, query etc.) within the file - so it's not much good for backing up.

    In <post:=492,757>post 492,757</post:>, HansV lists some useful utilities for backing up an Access Database. Beryl is correct that the "copy" method won't work for an open file.

    You could use VBA within a different database (or spreadsheet etc.) to copy a closed .mdb file. This of course only works if no other users have the database open, so you'll need to think about temporarily blocking access to the database - not always a viable option.
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

  7. #7
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Backing up Currently Open MDB (2003)

    Edited by HansV to put <!t>[ and ]<!/t> around reference to post, this makes it into a link.

    see post <post:=518,374>post 518,374</post:> about Helen Feddema's code to back up an open database. I use this and it is fine

  8. #8
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Backing up Currently Open MDB (2003)

    The VBA FileCopy command will not copy an open file. I have used the Windows API CopyFile command as a replacement. See:
    http://www.freevbcode.com/ShowCode.Asp?ID=498
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

  9. #9
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Backing up Currently Open MDB (2003)

    Thank you Jack.
    That's perfect.
    Thanks also to Beryl, Hans, Dave and Zave.

Posting Permissions

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