Solved

How do I repair and compress an Access database from VB

Posted on 1998-06-18
2
139 Views
Last Modified: 2010-05-03
How do I repair and compress an Access database from VB?
0
Comment
Question by:jfl
2 Comments
 
LVL 2

Accepted Solution

by:
swilt earned 20 total points
ID: 1463648
This sub repairs and then compacts a database

sFile is the path of the database e.g. C:\DATA\MYMDB.MDB
sTempFile is the temporary file used in compation eg C:\DATA\MYMDB.TMP
When a database is compacted it must not be open

Private Sub Compact(ByVal sFile As String, ByVal sTempFile As String)
    On Error GoTo EHCompact
   
    RepairDatabase sFile
    CompactDatabase sFile, sTempFile
    Kill sFile
    Name sTempFile As sFile
ExitCompact:
    Exit Sub
   
EHCompact:
    MsgBox "Error occurred whilst trying to compact database " & sFile & vbCr & Error$, vbCritical, Me.Caption
    Resume ExitCompact
End Sub
0
 

Author Comment

by:jfl
ID: 1463649
I have another question here that I think you can help with:
http://www.experts-exchange.com/topics/comp/lang/visualbasic/Q.10058529
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

919 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

14 Experts available now in Live!

Get 1:1 Help Now