Solved VBA Compact & Repair (1 Viewer)

Romio_1968

Member
Local time
Today, 21:44
Joined
Jan 11, 2023
Messages
126
Neither of the examples you supplied will work.
You can use VBA to copy the current database to another file then compact that.
However you cannot overwrite the current file with the compacted copy whilst the original file is open
Clear!
 

KitaYama

Well-known member
Local time
Tomorrow, 03:44
Joined
Jan 6, 2022
Messages
1,541
I have an application with a custom ribbon. Since the ribbon hides everything in File tab, I've added the internal compact & repair button to the ribbon.
This way I can simply click the button and compact & repair.

<button idMso="FileCompactAndRepairDatabase" size="large"
tag="RibbonName:=;inMenu:=;CustomPicture:=;CustomPicturePath:="/>
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 13:44
Joined
Feb 28, 2001
Messages
27,188
For a monolithic database (unsplit) you must have the DB opened in EXCLUSIVE mode because otherwise the file will be write-locked against you. The last step of that C&R is to delete the old file and replace it with the newly created compressed copy. However, if the file is shared at the moment, that can't happen. Even having a file that is opened in EXCLUSIVE mode AND is not currently being shared doesn't necessarily avoid the possibility of corruption in an automated C&R on a standalone system.
 

Users who are viewing this thread

Top Bottom