Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Compact and Repair Access MDB.

Total Hit ( 2949)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Following code requires Microsoft DAO 3.6 reference.

To add this reference goto Project->Reference

example:

Click here to copy the following block
Call DBCompact("OLt.mdb", "tmpOLT.mdb", , , ";pwd=mypwd")

Click here to copy the following block
'***********************************************
'Defrag and Repair database
'***********************************************
Public Function DBCompact(ByVal DBSource As String, Optional ByVal DBTemp As String = "C:\CSITmp.mdb", Optional ByVal DstLocale As String = "", Optional ByVal Options As String = dbEncrypt, Optional ByVal Password As String = ";pwd=")
   On Error GoTo CompactError
   'set database variables to user variables
   DBs = DBSource: DBs2 = DBTemp: DBLocale = DstLocale
   DBOptions = Options: DBPassword = Password
   If Dir(DBs) = "" Or DBs = "" Then
     MessageBox "Database Was Not Located.", vbExclamation, "DB Error"
   Else
        DBEngine.CompactDatabase DBs, DBs2, DBLocale, DBOptions, DBPassword
        Kill DBs
        DBEngine.CompactDatabase DBs2, DBs, DBLocale, DBOptions, DBPassword
        Kill DBs2
   End If
   Exit Function
CompactError:
   MessageBox "Error Compacting Database. Make Sure Database Is Closed." & vbCrLf & vbCrLf & Err.Number, vbExclamation, "Compact Error"
End Function


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.