Compact and Repair Database

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
 
D

Dirk Goldgar

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
 
G

Guest

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
 
D

Dirk Goldgar

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top