• Want to auto-close Access 2010 database and quit Access

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Want to auto-close Access 2010 database and quit Access

    Author
    Topic
    #500655

    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 OfficeOffice14MSACCESS.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.:confused:

    Thanks,

    Viewing 1 reply thread
    Author
    Replies
    • #1512209

      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.

    • #1513373

      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 OfficeOffice14MSACCESS.EXE” “U:CI.accdb” /X macRunETL
      in a bat file and run the bat file, the macro executes and Access quits.

      :confused:

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

    Viewing 1 reply thread
    Reply To: Want to auto-close Access 2010 database and quit Access

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: