Jun 15 2022 02:16 PM
Hi.
Several weeks ago, after compacting (via VBA code) an accdb (back end on a server), I couldn't find anymore some indexes in a (important...) table.
In the compacted accdb, I found the MSysCompactError table (as expected, as compacting didn't go well ...).
Now, after reading some tips on the web on how to remove minor corruptions from an accdb, I created the following procedure, that I would like to run periodically on the accdb back end (in order to minimize the chances of losing indexes or corrupting in any way the accdb):
1) make a local copy ("C") of the back end accdb file ("BE");
2) compact "C" in file "D";
3) export all database objects of "D" in an empty accdb "E" (let's call "T" file "E" after the export);
Note: the 'export' is performed through the execution of this sql string (on all tables of "D"):
" SELECT * INTO [strConnectionStringOf_E].[tableName] FROM [strConnectionStringOf_D].[tableName] "
4) recreate in "T" all the indexes in "BE" (more precisely: the 'expected' indexes that the original "BE" should have);
5) recreate in "T" all the relations in "BE" (more precisely: the 'expected' relations that the original "BE" should have).
Now, this procedure 'worked' at recreating my "BE" (that is the file "T" after 5) in such a way that the next compact on this new file worked fine (without errors and without losing any index).
Does anyone know:
- why this procedure 'worked' (in the above sense)?;
- if this procedure has any sense or is just a waste of time?;
- if (supposing it is not useless) it could be done in a better way?
Many Thanks.
Marco M.
Jun 15 2022 06:40 PM
Jun 16 2022 12:56 AM
Hi arnel_gp,
thank you for your answer.
In my experience, it seems that accdb back ends need to be compacted less often than mdb back ends (in my experience, accdb doesn't grow as much and as often as mdb).
However, if I'm not wrong, Microsoft suggests to perform periodically a compact operation on the back end, regardless you find issues (not only in order to shrink the file but for other reasons linked to performance issues, query execution and so on).
Maybe, it could be reasonable to perform an ordinary compact each 10 days (so to say), leaving the procedure I propose in order to try to fix a corrupted accdb (in my case, the procedure worked in order to regenerate my accdb back end on which compact operation could be performed again without errors).
That said, I still have some doubts on the following point:
- in a split database (as in my case, where I have forms, reports, query, VBA code, etc. in a Front End accde and only tables in the accdb back end), what exactly impact on statistics of queries: compact on the back end or on the front end (or both)?
Thanks.
Jun 16 2022 03:57 AM
Jun 17 2022 06:07 AM
Jun 17 2022 07:27 AM
Jun 17 2022 07:45 AM
When you compact & repair the back end, do you retrieve it to the local computer first? Or do you try to do the C&R across a network? If the latter, problems of the sort you describe are more likely.
Jun 17 2022 09:11 AM
"The problem is that it's not so rare (as it happened to me... and I'm sure I'm not alone...) to lose important indexes & relations (losing also referential integrity) without realizing that (if you compact via VBA code), after a compact operation of a corrupted back end."
I've never seen this happen, except when the back end is already corrupted. Therefore, I have to assume that the problem lies in the corruption, not in the C&R per se. It is true that Access will drop constraints on corrupted tables in order to preserve as much data as possible, but that's a two-edged sword. I'd say it's probably better to resolve the corruption first, therefore, and then complete the Compact & Repair.
Jun 17 2022 09:15 AM
Jun 17 2022 09:45 AM - edited Jun 17 2022 09:46 AM
SolutionSome people do report that they've not had problems doing a C&R on an mdb/accdb on a network share. If you want to continue that practice, it's up to you.
"... at home where I have Access 2016 64 bit. At the office, where I have access 2016 32 bit, it didn't work. "
And that's probably the missing detail we needed. Does the accdb compile in both environments?
To be sure you've recovered it fully, what I would do is create a new, empty accdb in whichever version you intend to use when actually working with this accdb, presumably in the Office, where you have the 32 bit version. Then import the existing tables from this borked accdb into it and make sure the relationships, indexes, etc. are all restored properly.
Then I would NOT mess with it again on the 64 bit Access computer. No guarantees one way or the other that that is the source of the problem, but, while you can run the accdb under either version--assuming the code has been properly converted to run in both environments and there are no incompatible 32bit ActiveX controls in the accdb--I would be very reluctant to introduce changes by altering it in the 64 bit version, including a C&R.
Jun 17 2022 10:47 AM
*And that's probably the missing detail we needed. Does the accdb compile in both environments? *
Yes, the front end compiles in both environments (the front end is an accde). No ActiveX controls.
The referenced libraries are: VBA, Access 16 Object Library, DAO 3.6 Object Library, MS XML v6.0.
In the office, my colleagues have the 64 bit version...
The only guy who uses the 32 bit version is "me in the office" (while "me at home" uses the 64 bit version - which is the main version of development).
I think you pointed out the most probable cause of corruption, which is not the 64-bit version, but the 32-bit version ("me in the office"...).
In the coming days I'm going to follow your suggestions and then report the results as soon as possible.
Jun 17 2022 11:59 AM
Jun 17 2022 01:19 PM
Jun 19 2022 05:02 AM
Jun 19 2022 06:46 AM
Jun 19 2022 06:47 AM
Jun 19 2022 07:53 AM
No, there aren't index duplicates.
But I have to say that some indexes were duplicated in some table (and I discovered them only via VBA...). Unfortunately, I don't remember anymore in which table... (I'm not 100% sure but it is very likely that there were some of them in the table which gave me this problem).
Anyway, I deleted them, and now, the pseudo-corrupted table hasn't any (I checked also with VBA).
The C&R doesn't work also in a clean accdb with only the table that seems problematic/corrupted with the 32-bit Access 2016 but not with the 64-bit Access 2016.
So, what should the conclusions be?
Jun 19 2022 07:55 AM
Thank you George for your kind words.
Without your precious help I probably wouldn't have realized (among other important things) that
is preferable not having front ends built with different bitness (although of the same version) working together.
Jun 19 2022 08:47 AM
Jun 19 2022 10:49 AM
*which is the biggest table in the accdb (150 MB - 312.000 records)*
The procedure I described in my first post was exactly an attempt (implemented in a working solution) to solve minor corruption issues, mainly through the SELECT INTO clause. I quote myself:
* 1) make a local copy ("C") of the back end accdb file ("BE");
2) compact "C" in file "D";
3) export all database objects of "D" in an empty accdb "E" (let's call "T" file "E" after the export);
Note: the 'export' is performed through the execution of this sql string (on all tables of "D"):
"SELECT * INTO [strConnectionStringOf_E].[tableName] FROM [strConnectionStringOf_D].[tableName]"
4) recreate in "T" all the indexes in "BE" (more precisely: the 'expected' indexes that the original "BE" should have);
5) recreate in "T" all the relations in "BE" (more precisely: the 'expected' relations that the original "BE" should have).*
Now, I initially believed that this fixed the problem, but I was at home with the 64 bit version. When I tried the procedure in the office with the 32-bit version, I realized that it didn't work (then discovered that the pseudo-corrupted back end was not 'really' corrupted as the C&R worked without issues with the 64 bit version).
I'll certainly try an INSERT INTO (tomorrow), but I have autonumbers as PK in my tables:
if an INSERT INTO should work, how could I manage the autonumber fields?
Jun 17 2022 09:45 AM - edited Jun 17 2022 09:46 AM
SolutionSome people do report that they've not had problems doing a C&R on an mdb/accdb on a network share. If you want to continue that practice, it's up to you.
"... at home where I have Access 2016 64 bit. At the office, where I have access 2016 32 bit, it didn't work. "
And that's probably the missing detail we needed. Does the accdb compile in both environments?
To be sure you've recovered it fully, what I would do is create a new, empty accdb in whichever version you intend to use when actually working with this accdb, presumably in the Office, where you have the 32 bit version. Then import the existing tables from this borked accdb into it and make sure the relationships, indexes, etc. are all restored properly.
Then I would NOT mess with it again on the 64 bit Access computer. No guarantees one way or the other that that is the source of the problem, but, while you can run the accdb under either version--assuming the code has been properly converted to run in both environments and there are no incompatible 32bit ActiveX controls in the accdb--I would be very reluctant to introduce changes by altering it in the 64 bit version, including a C&R.