Results 1 to 2 of 2

Thread: Closing front end by vba to compact a backend Access database by vba

  1. #1
    Join Date
    Aug 2014

    Closing front end by vba to compact a backend Access database by vba

    Closing front end by vba to compact a backend Access database by vba

    I wish to by vba close the front end of an Access data base so it is not running when a compact backend database is called from vba by a third utility database.

    I have three databases.
    The front end database. DbFront
    The back end database. DbBackend
    A utility database. DbUtility where dbUtility opens automatically by an autoexec macro to a form with a button that when click compacts DbBackend

    All this works fine if I physically close DbFront navigate to DbUtility and click the compact button.
    (I have the code installed on a button on a form in the Utility database that actually compacts the back end. Working fine.)

    However, I would prefer to call the compact back end instruction from within the front end but it seems that once the form on a Utility database opens (in modal pop up) focus is lost with the front end and the code to close (quit) the front end does not complete. Leaving both the front end and utility databases visible with the focus on the utility form.

    I can see the logic if is not possible for the front end code to complete when the utility opens.

    So, I have tried a different approach where a user would locate and open the Utility database and click the compact button. I wish code to be added to the compact button that checks if the front end is open and either closes it or issues a message that it is open and quits (Utility database quits if front end is open.

    This is where my lack of coding knowledge has stumped me. I will be grateful if anyone can point me in the right direction to vba code that may fulfil what I am trying to achieve.


  2. #2
    Join Date
    Jul 2011
    Kerala, India
    Take a look at this Article: Repairing Compacting Database with VBA; you will be better informed on this subject.

Posting Permissions

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