VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Compacting Databases

Bradley Liang  (6 Submissions)   Databases/Data Access/DAO/ADO   Visual Basic 3.0   Intermediate   Wed 3rd February 2021

The problem with Access databases is that when you delete records, the .MDB file doesn't shrink.
It just grows and grows and grows – until someone either compacts it or you run out of disk space.
This tip will show you how to compact a JET database up to 100 times!

Inputs
Simply run CompactDatabase passing the location of your database. There's also an optional argument requiring a True or False value to backup the original database to the Temp directory before proceeding.

Assumes
Note: In order for this to work, you need a reference (Project, References) to any version of the Microsoft DAO object library.

Returns
Substantially smaller Database (e.g. 25.3 mb to 4.7 mb).

API Declarations
Public Declare Function GetTempPath Lib "kernel32" Alias _
"GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer _
As String) As Long
Public Const MAX_PATH = 260

Rate Compacting Databases (2(2 Vote))
Compacting Databases.bas

Compacting Databases Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters