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
Solved

How do I repair and compress an Access database from VB

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 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…

828 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