It all works well using the full version but the compact fails when
using the runtime giving an error that Access has stopped working. Is
it actually possible to compact with the runtime or is my only option
to install the full version?
... running a shortcut that compacts the backend. The target of the
shortcut would look like the following:
"C:\Program Files\Microsoft Office\Office12\msaccess.exe" /compact
"C:\Backend.accdb"
If your front-end is completely disconnected from the back-end, you can run
this from a module in the front-end. Otherwise add it to another MDB.
' Delete the copy of the backend made on a previous run of this function,
ignore error if file does not exist
Kill "BUBackend.mdb"
' Rename back-end file
Name "Backend.MDB As "BUBackend.mdb"
' Compact renamed back-end to original name
DBEngine.CompactDatabase "BUBackend.mdb", "Backend.MDB
' Verify the back-end exist, if not rename the backed-up copy to the
original back-end name
' Reopen the front-end
>I'm trying to compact a database backend using the A2007 runtime.
When the user exits the FE attempt to rename the backend MDB preferably with todays
date in the name in yyyy-mm-dd format. Ensure you close all bound forms, including
hidden forms, and reports before doing this. If you get an error message, oops, its
busy so don't bother. If it is successful then compact it back.
See my Backup, do you trust the users or sysadmins? tips page for more info.
http://www.granite.ab.ca/access/backup.htm
Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Granite Fleet Manager http://www.granitefleet.com/
The next thing I need to work out how to do is to limit the number of
zips stored in the backup folder. I've decided to do this every 3
days, so the number of zips will mount quickly.
The system I'm working on at the moment only has 2 users who sit next
to each other and prior to the compact a message is displayed asking
the user to ensure that no other users are connected. If an .ldb
exists the user is presented with another message telling them that
there is still a user connected.
What would be the best strategy to implement in a larger multiuser
environment to ensure that no users are connected to the backend prior
to compacting? Leaving a machine running all night and scheduling the
compact for the early hours of the morning is not always an option.
>The next thing I need to work out how to do is to limit the number of
>zips stored in the backup folder. I've decided to do this every 3
>days, so the number of zips will mount quickly.
I use the file API to couint the numer of files and kill the oldest.
>The system I'm working on at the moment only has 2 users who sit next
>to each other and prior to the compact a message is displayed asking
>the user to ensure that no other users are connected. If an .ldb
>exists the user is presented with another message telling them that
>there is still a user connected.
I just try to rename the BE. If it fails then someone is in it.
>What would be the best strategy to implement in a larger multiuser
>environment to ensure that no users are connected to the backend prior
>to compacting? Leaving a machine running all night and scheduling the
>compact for the early hours of the morning is not always an option.
HOW TO: Detect User Idle Time or Inactivity in Access 2000 (Q210297)
http://support.microsoft.com/?kbid=210297
ACC: How to Detect User Idle Time or Inactivity (Q128814)
http://support.microsoft.com/?kbid=128814
However we found that the code which runs on the timer event must be disabled for the
programmers. Otherwise weird things start happening when you're editing code.
Also print preview would sometimes not allow the users to run a menu item to export
the report to Excel or others. So you had to right click on the Previewed report to
get some type of internal focus back on the report so they could then export it.
This was also helped by extending the timer to five minutes.
The downside to extending the timer to five minutes was if a person stays in the same
form and at the same control for considerable parts of the day, ie someone doing the
same inquiries, the routine didn't realize that they had actually done something.
I'll be putting in some logic sometime to reset this timer whenever they do something
in the program.