nhior.it@gmail.com +966534401783
January 25, 2024 - BY Admin

Compact on Close in MS Access

Compact on Close ms access vba code


In Microsoft Access, you can use VBA (Visual Basic for Applications) to set the "Compact on Close" option programmatically. Here's an example of VBA code that you can use to enable the "Compact on Close" option for an Access database:


Function SetCompactOnClose() Dim db As Object ' Open the current database Set db = CurrentDb ' Set the "Compact on Close" option to True db.Properties("Compact on Close") = True ' Save the changes to the database db.Close End Function To use this code:



Open your Access database. Press Alt + F11 to open the VBA editor. Insert a new module (right-click on a folder in the Project Explorer, choose "Insert," and then select "Module"). Copy and paste the above code into the module. Close the VBA editor.

0 ITEMS
$ 0