This is my submission for code snippet contest.
I also posted this code to help other members on how they can use compact & repair their MS Access Database within Visual Basic 6.0.
You also need to add Microsoft Jet and Replication 2.6 in your project reference.
To use, add the snippet in Module;
Once you have added it to the module just call CompactAccess with database location and its password like this;
Call CompactAccess("C:\Database.mdb", "12345")
I also attached a sample project on how you can use it, just check it out.
Please note that the database should be close before compacting it, else it will not work.