Compact and repair Back End From Front End at Runtime

B

bobdydd

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\Office\MSACCESS.EXE" _
/excl /runtime /profile "MYDB" /wrkgrp _
"C:\Program Files\Stortvalley\MYDB2\system.mdw" _
/repair "C:\Program Files\Stortvalley\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
 
D

Douglas J. Steele

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 strCurrentBackend As String
Dim strRenamedBackend As String

strCurrentBackend = .....
strRenamedBackend = Left$(strCurrentBackend, Len(strCurrentBackend) - 4)
& _
Format$(Date(), "yyyymmdd") & ".bak"

Name strCurrentBackend As strRenamedBackend

DBEngine.CompactDatabase strRenamedBackend, strCurrentBackend


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:

strCurrentBackend = Mid$(CurrentDb().TableDefs("MyLinkedTable").Connect,
11)
 
B

bobdydd

Hi Doug

As always you get me out of trouble ...................Thanks
I have not tried it on a machine without Full version Access installed
(just the ART) but I reckon it will work.
I altered it slightly to put the Backups it a different directory

Once again Thanks a lot

Bob
 

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