Comact & Repair using DoCmd

  • Thread starter Thread starter Alan
  • Start date Start date
A

Alan

I would like to set somw databases to compact & repair when a form is opened
(using a macro that opens the form from the task scheduler). I tried the
following code on form load but it wants to create a new table. instead of
running compact & repair:
Private Sub Form_Load()

DoCmd.DoMenuItem acForm, acTools, acDatabaseUtilities,
acCompactAndRepairDatabase

End Sub

Any Ideas?
Thanks,

Alan
 
Alan said:
I would like to set somw databases to compact & repair when a form is
opened
(using a macro that opens the form from the task scheduler). I tried the
following code on form load but it wants to create a new table. instead of
running compact & repair:
Private Sub Form_Load()

DoCmd.DoMenuItem acForm, acTools, acDatabaseUtilities,
acCompactAndRepairDatabase

End Sub

Any Ideas?


What version of Access? And is there some special reason you want to open a
form to do this? If you're running it from the task scheduler, why bother
with a user-interface object like a form?
 
Dirk Goldgar said:
What version of Access? And is there some special reason you want to open a
form to do this? If you're running it from the task scheduler, why bother
with a user-interface object like a form?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

I didn't know you could run compact & repair from the task scheduler by
itself. I run macros from the task scheduler and the only way I could think
of to run the compact & repair using a macro would be using the DoCmd on form
load. I didn't think until I just typed the reply I could use the run command
in the macro. Thanks,
your reply sent me in the right direction!
 
Alan said:
I didn't know you could run compact & repair from the task scheduler by
itself. I run macros from the task scheduler and the only way I could think
of to run the compact & repair using a macro would be using the DoCmd on form
load. I didn't think until I just typed the reply I could use the run command
in the macro. Thanks,
your reply sent me in the right direction!

I tried running compact & repair from the run command in a macro but I get
an error message "You can't run Compact & Repair wheile a macro is open or
running"
 
Alan said:
I tried running compact & repair from the run command in a macro but I get
an error message "You can't run Compact & Repair wheile a macro is open or
running"


Did you try starting Access with the /compact command-line option? See this
help topic for a list of command-line options:

http://office.microsoft.com/assistance/hfws.aspx?AssetID=HP051883001033

For example, you might execute this command line from the task scheduler:

"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
"C:\SomeFolder\YourDB.mdb" /compact


Note that the above example will have been broken onto two lines by the
newsreader, but it's meant to be all on one line.
 
Thanks,

that is definetly the way to do it, it works fine. Funny the book I have
desn't even mention the command line startup options.

Alan
 

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

Back
Top