By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 2,292 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 IT Pros & Developers. It's quick & easy.

Compact Repair Database

P: 46
HI All

Currently i have a access database and i am currently doing compact and repair using the tool in database.Can any one help me by giving me the code for doing the same thing so that i can call that method in a button click so that users can do it their own.Thanks in advance
Mar 7 '08 #1
Share this Question
Share on Google+
5 Replies


P: 59
depends on the version of access. see http://www.thescripts.com/forum/thread568193.html , looks a bit trickier with ms access 97

If you are using 2000+ maybe try

add a new module
add function (must be only code in module):

Function CompactRepair()
CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and repair database..."). _
accDoDefaultAction

End Function

call the function from your buttons Click event
I have tried on msaccess 2002/2003 and works OK.

good luck ramdil :)
Mar 7 '08 #2

missinglinq
Expert 2.5K+
P: 3,532
Important to remember is that compacting a database is a common cause of corruption! It should never, ever be done until the db has first been backed up!

Linq ;0)>
Mar 7 '08 #3

P: 59
excellent point missinglinq, and thank you for a great mousemove tutorial :)
Mar 7 '08 #4

missinglinq
Expert 2.5K+
P: 3,532
You're welcome, Blad3! The How To section is always a great place to browse thru when you have a few minutes! Lots of great stuff in their, all of it generated because it addresses things that have been asked beacoup times.

Linq ;0)>
Mar 7 '08 #5

P: 46
Thanks for the replies.I will try and get back to you .Any thanks for all responses.


depends on the version of access. see http://www.thescripts.com/forum/thread568193.html , looks a bit trickier with ms access 97

If you are using 2000+ maybe try

add a new module
add function (must be only code in module):

Function CompactRepair()
CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and repair database..."). _
accDoDefaultAction

End Function

call the function from your buttons Click event
I have tried on msaccess 2002/2003 and works OK.

good luck ramdil :)
Mar 10 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.