Compact Database

G

Guest

Can the current database (the one that’s open) be compacted using a macro in
Access 97? When I try to use the RunCommand (Action) CompactDatabase
(Command) in a Macro it opens a dialogue box (explorer) looking for the
database.

I can compact the db manually from the Tools-Database Utilities menu, but I
would to do it programmatically through a macro or VB code on the current
database.

Thanks,

Nick
 
S

Steve Schapel

Nick,

Jim's idea would be good in a more recent version of Access, but this
option is unfortunately not available in Access 97. It is not possible
to directly compact the currently open database. The only way I know of
to achieve your purpose, is to make another mdb file, with a macro or
procedure to compact your main database file, and then open it. Then
put macro or code in your main database to open this compact-triggering
database, and close itself. Hope you understand the concept here. An
adaptation of the SOON (shut one open another) utility at
www.trigeminal.com may be of interest.
 
G

Guest

Understood & Thanks!

Steve Schapel said:
Nick,

Jim's idea would be good in a more recent version of Access, but this
option is unfortunately not available in Access 97. It is not possible
to directly compact the currently open database. The only way I know of
to achieve your purpose, is to make another mdb file, with a macro or
procedure to compact your main database file, and then open it. Then
put macro or code in your main database to open this compact-triggering
database, and close itself. Hope you understand the concept here. An
adaptation of the SOON (shut one open another) utility at
www.trigeminal.com may be of interest.
 
R

Russell Freshwater via AccessMonster.com

G

Guest

Russell,
I tried your suggestion with SendKeys. It appears to work but only after
(1) I run the macro for the first time, (2) I close (or cancel) the dialog
box "Database to Compact from" and (3) I run the macro a second time. When I
attach the macro to a form event, I do not get the dialog box but the
database does not compact. Am I missing a step? Thanks.
 

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