PDA

View Full Version : Compact and Repair



Tommy
05-08-2007, 04:37 PM
I am accessing an access database from VB. I have this code I picked up somewhere several years ago, and of course I butchered it.

How often should I do this? every delete/insert? once a month? Once each data entry session?

Opinions are good, I'm thinking once each data entry session.:dunno

Is there a way to reindex?

This is currently a single user on a local PC. It may goto a multi user on a server who knows. The data is entered once and maybe changed on occasion. Mainly a read it and forget it data-storage (in access) so it will not get very big.


Dim JRO As JRO.JetEngine
Dim DBDir As String
DBDir = "C:\Program Files\somedirectory\"
Set JRO = New JRO.JetEngine
JRO.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBDir _
& "database.mdb;", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBDir & "database1.mdb;"
Kill DBDir & "database.mdb"
Name DBDir & "database1.mdb" As DBDir & "database.mdb"
FileCopy DBDir & "database.mdb", DBDir & "hopefullysafefolder\database.mdb"
Set JRO = Nothing

Tommy
05-08-2007, 04:51 PM
:rofl:

Ok the reindexing - I'm thinking about something else. :doh:

Note to self. Take a break. :beerchug: