Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Aug 2001
    Location
    USA
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Want to auto-close Access 2010 database and quit Access

    Background:
    I have an Access 2010 database that is going to be run automatically once per day.
    All of the programming for the database is a VBA Sub named ETL.
    The plan is to to start the database using a line similar to the following:
    "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" "U:\CI.accdb" /X macRunETL
    macRunETL has 1 action: RunCode RunETL().
    RunETL() only has 1 purpose, to call the Sub ETL.

    The above works fine.

    The problem is trying to close CI.accdb and exit Access after the procedure ends.

    When I try to add the macro action QuitAccess the Unsafe Action icon is displayed and the 'The command or action isn't available now.' error message appears when the macro runs.

    I tried adding Application.Quit acQuitSaveNone to a function and having the macro call this function, but receive Runtime error 2046 with the same error message. (This function works if I manually execute it from the Visual Basic Editor, although Task Manager still shows the MSACCESS process running even though the Access application is not.)

    The database is saved in a trusted location and the Trust Center Macro Settings = Enable All Macros.

    All of my other databases have Main Menu forms with a exit button that works.

    This is my first non-user interaction database and I don't know what else to try.

    Thanks,

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts
    Are you closing the database before you try to quit Access? If so, you cannot run a macro in a database if that database is closed. So just the QuitAccess should be all you need. If you are not closing the database, then we need to know more about the code in ETL.
    Wendell

  3. #3
    2 Star Lounger
    Join Date
    Aug 2001
    Location
    USA
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do not understand why, but when I try running the macro containing the QuitAccess command, I get the error message as stated in my original post, however, if i put the line
    "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" "U:\CI.accdb" /X macRunETL
    in a bat file and run the bat file, the macro executes and Access quits.



    I guess the end result is that I don't have an automation issue.

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
  •