Compact and Repair Database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Could someone please tell me the proper syntax in VBA to use the database
utilities / compact and repair database?

I thank you in advance for your reply
 
Erik T said:
Could someone please tell me the proper syntax in VBA to use the
database utilities / compact and repair database?

I thank you in advance for your reply

For the current database? It used to be impossible without an external
helper utility of some kind. But with Access 2000 and later versions,
it got much simpler. See this link:

http://www.mvps.org/access/general/gen0041.htm

For a more general discussion, look here:

http://www.mvps.org/access/general/gen0013.htm
 
Dirk,

The link worked great, however, once the sub is ran the program exits. I
attempted to add the following line to reopen the form upon which the
CompactDB() link was ran

DoCmd.OpenForm ("frmMainMenu")

I can only guess that the last line of the link

accDoDefaultAction

is what is causing the program to exit. Can you think of a way to have the
form to refresh? Thanks
 
Erik T said:
Dirk,

The link worked great, however, once the sub is ran the program
exits. I attempted to add the following line to reopen the form upon
which the CompactDB() link was ran

DoCmd.OpenForm ("frmMainMenu")

I can only guess that the last line of the link

accDoDefaultAction

is what is causing the program to exit. Can you think of a way to
have the form to refresh? Thanks

Yes, of course the program exits -- you can't compact an open database.
So the question is, how can you get the same form to open again
automatically? You'd need to record somewhere -- probably in a
configuration table dedicated to such things -- what form to open to,
and then have code run by your startup form or an Autoexec macro that
would extract the name from that table and reopen that form.
 
Back
Top