Unfortunatly there isn't. There could be a way to programmatically call the API on which is based the "Compact and Repair" tool. But obviously this way is platform/windows dependent.
Last edit: Marco Amadei 2016-01-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As Marco mentions, any built-in way of doing a Compact and Repair Database operation from UCanAccess would only work on Windows machines, and even then it would only work if the required version of the Access Database Engine was installed. That would involve 32-bit vs. 64-bit execution environments, .accdb vs. .mdb requirements, and the headaches that go with them.
There is also a fairly strong argument against performing a Compact and Repair Database operation programatically. Yes, C+R can solve a lot of problems with corrupted database files but it can also permanently destroy data that could otherwise be recovered (e.g., if the primary key for a table contains an invalid data page).
Compact and Repair Database operations should not be taken lightly. They should be done with appropriate planning and due care. The only time that I would recommend that it be done programatically would be when Microsoft Access itself was not installed and the user wanted to do the C+R using just the Access Database Engine.(on Windows). In that case a simple VBScript or PowerShell script would be sufficient.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear Marco,
Is there a method in UCanAccess to compact the access DB without use the internal function "Compact and Repair" into MS Access?
Thank you.
Dario.
Unfortunatly there isn't. There could be a way to programmatically call the API on which is based the "Compact and Repair" tool. But obviously this way is platform/windows dependent.
Last edit: Marco Amadei 2016-01-12
As Marco mentions, any built-in way of doing a Compact and Repair Database operation from UCanAccess would only work on Windows machines, and even then it would only work if the required version of the Access Database Engine was installed. That would involve 32-bit vs. 64-bit execution environments, .accdb vs. .mdb requirements, and the headaches that go with them.
There is also a fairly strong argument against performing a Compact and Repair Database operation programatically. Yes, C+R can solve a lot of problems with corrupted database files but it can also permanently destroy data that could otherwise be recovered (e.g., if the primary key for a table contains an invalid data page).
Compact and Repair Database operations should not be taken lightly. They should be done with appropriate planning and due care. The only time that I would recommend that it be done programatically would be when Microsoft Access itself was not installed and the user wanted to do the C+R using just the Access Database Engine.(on Windows). In that case a simple VBScript or PowerShell script would be sufficient.