Compacting Database

G

Guest

In a macro I am importing large tables, running some queries and then deleting the imported tables. The problem is that they are so large I need to compact the databse afterwards. Is there a way to do this in the macro?
 
G

Guest

Its ok, I found some posts on the topic. I tried searching before my post but misplelled 'Compacting' in my search critera. Appologies.
 
N

Nikos Yannacopoulos

Jamie,

I'm afraid this cannot be done, at least the way you
describe it. Compacting through a macro or VBA code is
only possible for other .mdb and .mde files that are not
used at the time, but not the one that actually runs the
macro or code. The only workaround I know of is to use the
SendKeys action to activate Compact and Repair from the
menu, but... SendKeys can be tricky at times, ending up
doing something else than what you intended it to, and
should generally be avoided.
A reliable alternative is to go to Tools > Options, tab
General, and tick the Compact on Close option. The
downside is it will only do the compaction on close,
rather than straight after the update operation. If that
works for you, it's a very good way to do it.

HTH,
Nikos
-----Original Message-----
In a macro I am importing large tables, running some
queries and then deleting the imported tables. The
problem is that they are so large I need to compact the
databse afterwards. Is there a way to do this in the
macro?
 
G

Guest

Another option is to check out the help file and look up COMPACT. There's a command line option (that you can put with a Shortcut, of course) that will allow you to compact a database by full pathname.

Unfortunately, whenever you run a macro and close a database window, you stop the macro. Of course, if you keep your data tables in a separate database (and just link and such to set up forms and queries), you may be able to compact the source database.

Just a thought
Dere

----- Nikos Yannacopoulos wrote: ----

Jamie

I'm afraid this cannot be done, at least the way you
describe it. Compacting through a macro or VBA code is
only possible for other .mdb and .mde files that are not
used at the time, but not the one that actually runs the
macro or code. The only workaround I know of is to use the
SendKeys action to activate Compact and Repair from the
menu, but... SendKeys can be tricky at times, ending up
doing something else than what you intended it to, and
should generally be avoided
A reliable alternative is to go to Tools > Options, tab
General, and tick the Compact on Close option. The
downside is it will only do the compaction on close,
rather than straight after the update operation. If that
works for you, it's a very good way to do it

HTH
Niko
-----Original Message----
In a macro I am importing large tables, running some
queries and then deleting the imported tables. The
problem is that they are so large I need to compact the
databse afterwards. Is there a way to do this in the
macro
 

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