Solved

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

Posted on 2014-10-23
4
234 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
  • 2
4 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero 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 119

Assisted Solution

by:Rey Obrero
Rey Obrero 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 57

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now