Solved

How is a Compact and Repair performed on a database that is not opened?

Posted on 2014-10-23
4
247 Views
Last Modified: 2014-10-23
Hello,

I have databases with tables that are utilized by an Alteryx application as input and output. The end user will not be opening the databases.

The issue is the growth of the databases due to internal Access operations which can be close to 1GB in some instances.

Is there a way to set Compact and Repair for these databases without opening them?

Thanks
0
Comment
Question by:SASnewbie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 450 total points
ID: 40399471
you can use vba codes run from another access app to compact and repair the target db
, just make sure that nobody is connected to the targetdb

Sub CnR()

Dim objAcc As Access.Application
Set objAcc = Access.Application

objAcc.DBEngine.CompactDatabase "C:\folderName\targetDb1.mdb", "C:\folderName\targetDb2.mdb"
Kill "C:\folderName\targetDb1.mdb"
Name "C:\folderName\targetDb2.mdb" As "C:\folderName\targetDb1.mdb"

end sub
0
 

Author Comment

by:SASnewbie
ID: 40399481
Hi Rey,
Thank you for your quick response.

Is there a way to lock the database through VBA as well while performing the C&R?
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 450 total points
ID: 40399544
you can check for the presence of the targetDb.ldb or targetDb.laccdb in the folder where your target db is, which means that somebody is connected to your db..

if dir(<path to your targetdb> & "\*.laccdb")="" then
    'run the C&R
   else
    msgbox "DB in use!"
end if
0
 
LVL 58

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 50 total points
ID: 40399556
<<Is there a way to lock the database through VBA as well while performing the C&R? >>

 A C&R requires exclusive access and won't let anyone connect to it while it is running.

Jim.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question