Solved

How do I repair and compress an Access database from VB

Posted on 1998-06-18
2
138 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

705 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

19 Experts available now in Live!

Get 1:1 Help Now