Solved

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

Posted on 2014-10-23
4
240 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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 use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

762 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