Results 1 to 5 of 5
  1. #1
    Roncc is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2017
    Posts
    85

    Issuing a DOS command when you close Access database

    I have an Access database that I would like to have automatically backed up when I close the program. I have a "Quit Application" button on my MainMenuFrm that runs the code:


    DoCmd.Quit acPrompt

    but I would like the program to initiate a backup command following the closing. I can program a dos command like xcopy *.* h:\dailybackup /y

    and this is the type of code I want to run automatically when I close the program.

    Any ideas on how I can tie the two together?

    Thanks for the help.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    what are you trying to back up? the data or the forms/reports etc? The data should be in a separate backend, so you can just use vba to copy it to another location (the vba filecopy function) - since you are on the 'exit route' you presumably are not updating tables at that point. Front ends should never change so don't need backing up - except when developing and then there is no guarantee the form you want to run the code will be open. If your db is multi user, backing up on exit is generally a bad idea - if a backup is taken whilst another user is making changes can result in an incomplete transaction.

  3. #3
    Roncc is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2017
    Posts
    85
    The program is not on a server. It is a stand alone. I want to backup the entire database to a thumbdrive.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    I didn't ask about a server. However backup up to a thumb drive has many potential problems - not connected, connection interrupted, drive full to name the obvious ones. It is not something I would want to get involved with. Suggest look at using the vba Shell command to execute a DOS command or google something like 'vba to execute a DOS command', I can see there are plenty of links on the subject. Good luck with your project

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    I didn't ask about a server. However backup up to a thumb drive has many potential problems - not connected, connection interrupted, drive full to name the obvious ones. It is not something I would want to get involved with. Suggest look at using the vba Shell command to execute a DOS command or google something like 'vba to execute a DOS command', I can see there are plenty of links on the subject. Good luck with your project

    there is also a link at the bottom of this thread from someone who has the same basic requirement

    https://www.accessforums.net/showthread.php?t=51228

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

Similar Threads

  1. Replies: 3
    Last Post: 02-01-2018, 08:46 AM
  2. Replies: 1
    Last Post: 03-21-2015, 11:55 AM
  3. Replies: 1
    Last Post: 04-29-2013, 11:05 AM
  4. Replies: 2
    Last Post: 04-19-2012, 12:53 PM
  5. Replies: 1
    Last Post: 02-12-2011, 10:30 AM

Tags for this Thread

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