+ Reply to Thread
Results 1 to 5 of 5

Open, Compact & Repair, then close Access Database via VBA

  1. #1
    Registered User
    Join Date
    11-12-2021
    Location
    London
    MS-Off Ver
    Microsoft 365 MSO (Version 2202)
    Posts
    72

    Open, Compact & Repair, then close Access Database via VBA

    Hi,

    I have an excel file which, via power query, imports thousands of rows of data from an access database. The sheet has multiple users but is password protected meaning only I, have write access.

    I am relatively new to Access so forgive me for the basic questions:

    1. Having only created the sheet recently, I am constantly having to "compact and repair" the database - does that sound right or could there be something wrong with the database?
    2. I have amended the settings of the database so that on close, the compact and repair function is run. With that in mind is it possible to:
    i) Write some code (in the excel file) to open and close the database (and therefore I assume the compact and repair function will be run)
    ii) If the above is not possible then, write the code to open the database, run the repair, then close?

    From my research I have written the following:

    Please Login or Register  to view this content.
    Can someone verify whether this looks correct and what I need to add, for the code to run the compact and repair function?

    Any help would be great.

    Many Thanks

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: Open, Compact & Repair, then close Access Database via VBA


    Hi,

    and what the appropriate Access forum says ?!

    Another question : why using Excel, what could be the benefit instead of just using Access ?

    Try also to use a local path rather than a network path to see if you still have the same repair issue …

  3. #3
    Registered User
    Join Date
    11-12-2021
    Location
    London
    MS-Off Ver
    Microsoft 365 MSO (Version 2202)
    Posts
    72

    Re: Open, Compact & Repair, then close Access Database via VBA

    Hi,

    I have yet to submit the questions in the Access forum but can do so today.

    The data originates from a CRM system which then goes into Access. From their power query is used to manipulate the data into Excel. Excel is used as most colleagues (including myself have only ever used Excel). Further, the data used to go from the CRM system into Excel. It I experienced lots of issues with power query locking the source file.

    Lastly, I am unable to change the path due to the setup at work.

    Thanks

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Open, Compact & Repair, then close Access Database via VBA


    In Access VBA help see CloseCurrentDatabase and its sample.
    For more question about Access ask on an Access forum …

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,836

    Re: Open, Compact & Repair, then close Access Database via VBA

    I have moved this thread to the Access VBA section.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. MS Access - Compact and Repair ??
    By Logit in forum Access Tables & Databases
    Replies: 4
    Last Post: 07-14-2018, 11:01 AM
  2. Compact & Repair Backend Database
    By PSSMargaret in forum Access Programming / VBA / Macros
    Replies: 1
    Last Post: 08-14-2017, 06:49 AM
  3. VBA to open access runtime database on close
    By hudaz1 in forum Access Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2016, 03:41 AM
  4. Filters blank and compact repair not working
    By grifter in forum Access Tables & Databases
    Replies: 1
    Last Post: 05-25-2016, 04:08 PM
  5. Compacting Access Database on Close, Using Excel VBA
    By irickman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-14-2016, 04:45 PM
  6. Compact/Repair Access Database
    By pr4t3ek in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-27-2009, 04:41 AM
  7. Replies: 1
    Last Post: 12-02-2005, 05:00 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1