Repair a database automatically (1 Viewer)

JohnPapa

Registered User.
Local time
Today, 03:49
Joined
Aug 15, 2010
Messages
954
I have a db (approximately 70Mb) which gets corrupted. The message says something about an "inconsistent sate". If I enter Access and do a "Compact and Repair", it is fine. If this be db is at a client, is there a way for the client to do a compact and repair using vba? Can it be done from within the software or does the be db have to be closed and the Compact and repair be done from another program.

The problem, I believe, is the fact that the client's network is not well setup for example he does not have a dedicated server, but is working on this.
 

isladogs

MVP / VIP
Local time
Today, 01:49
Joined
Jan 14, 2017
Messages
18,216
Compacting was possible using VBA up to version 2010 when this feature was disabled.
This may have been because compacting has been known to cause problems with data corruption.

The chances are that the inconsistent state issue needs more than just compacting.
I recommend the steps outlined here https://www.access-programmers.co.uk/forums/showpost.php?p=1626477&postcount=12

In addition, be aware there is a Windows 10 bug that can cause this issue. See https://www.devhut.net/2018/06/13/access-bug-database-is-in-an-unrecognized-format/
 

JohnPapa

Registered User.
Local time
Today, 03:49
Joined
Aug 15, 2010
Messages
954
At the end of the day and as a workaround for the time being, we need to provide a way for the client to do a Compact and Repair. Maybe through a different program.
Is there another suggestion?
 

isladogs

MVP / VIP
Local time
Today, 01:49
Joined
Jan 14, 2017
Messages
18,216
You can still compact an external database using code. So you could have an Access utility who's sole job is to compact your application(s)
Alternatively, you can open a database using the /compact switch. A desktop shortcut could be used for this purpose where the shortcut path is your full database path followed by /compact.

However, neither of these provide a full solution which is why I suggested a more thorough approach. If its happening so often that its an issue, you need to deal with the underlying cause(s)
 

missinglinq

AWF VIP
Local time
Yesterday, 20:49
Joined
Jun 20, 2003
Messages
6,423
I agree with Colin...the important thing, here, is to figure out why the corruption keeps happening repeatedly!

Is the app divided into a Front End/Back End configuration...with the data on the Back End and a copy of the Front End on every user's PC?

And you haven't said...what version of Access are we talking about?

Linq ;0)>
 

NearImpossible

Registered User.
Local time
Yesterday, 19:49
Joined
Jul 12, 2019
Messages
225
As missinglinq mentioned, is this a FE/BE setup?, is the DB shared on a network?

I was running into this issue as well with a FE/BE setup as I had a front end Access DB, using SQL back end, on a network share and everyone that needed to use the DB would open it via a shortcut to the network share.

Over time, due to network hiccups or random issues, we would run into the inconsistent state issue. For a quick fix, I ended up making a backup of the DB and a batch file that could be ran from each client to replace the corrupted DB from the backup to correct the issue.

After multiple corruptions in the same day, I reevaluated the situation and in the end placed the FE Access DB on each client PC vs using a shortcut to the shared DB.
 
Last edited:

Users who are viewing this thread

Top Bottom