Use the CompactDatabase method of the DBEngine.
What I typically do is rename the existing backend, putting in today's date
and changing the extension to .bak. I then compact that to the "correct"
database. That way, I have a backup as well.
Dim strCurrentBacke nd As String
Dim strRenamedBacke nd As String
strCurrentBacke nd = .....
strRenamedBacke nd = Left$(strCurren tBackend, Len(strCurrentB ackend) - 4)
& _
Format$(Date(), "yyyymmdd") & ".bak"
Name strCurrentBacke nd As strRenamedBacke nd
DBEngine.Compac tDatabase strRenamedBacke nd, strCurrentBacke nd
I've left out how to determine where the current backend is, but it's pretty
straightforward . One way is to check the Connect roperty of a linked table,
and strip off the ";DATABASE= " from the front of it:
strCurrentBacke nd = Mid$(CurrentDb( ).TableDefs("My LinkedTable").C onnect,
11)
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"bobdydd" <re************ **@yahoo.co.uk> wrote in message
news:11******** *************@i 39g2000cwa.goog legroups.com...
Hi Everybody
For Microsoft Access 2000 and above
Windows XP
I am trying to mimic the action of this command that at the moment runs
from the start>>all programs at the bottom left of the screen.
"C:\Program Files\Microsoft Office\ART\Offi ce\MSACCESS.EXE " _
/excl /runtime /profile "MYDB" /wrkgrp _
"C:\Program Files\Stortvall ey\MYDB2\system .mdw" _
/repair "C:\Program Files\Stortvall ey\MYDB2\MYDB2_ Be.mdb" /compact
The idea is to be able to compact and repair the Backend database from
a command button on the Front End mde on a machine that has not got
full version Microsoft Access on it.....just the ART (Access Run Time)
Thanks for any help
Bob