Solved

How do I repair and compress an Access database from VB

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

773 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