问题
We've had MS Access running for years as a scheduled task reading files from a mainframe and printing out a bunch of reports. Of course, it grows with each invocation, so it is set to compact and repair on exit.
Two weeks ago, something trashed Windows on that machine, and the people in charge of such things decided to put the newest "corporate standard image" on it. Now, on exit, the compact and repair successfuly creates the optimized db1.mdb (, db2.mdb, ... db99.mdb), but fails to overwrite the original. Nothing in the event log, but the task scheduler is told that something failed.
A web search initially confirmed my suspicion that the account running the job must not have permission to do this task. But when we went to fix that, we found that the account had full control. More experimentation revealed that two other accounts couldn't do it either, but all three accounts could do the same DB in the same directory on another host.
The directory is on a networked Windows fileserver, so I wonder whether something about that host is telling the fileserver "you can't trust me." But I don't know how to check that, and I'm open to any other suggestion.
回答1:
Two comments:
Automatic compact/repair on exit is something that SHOULD NEVER BE USED UNDER ANY CIRCUMSTANCES. It's dangerous and not cancellable. For properly architected applications, it's a waste of time in any case, since the user never opens the back end in the Access user interface, but only opens the front end, which never needs to be compacted.
it sounds like you are appending a bunch of temporary data. This is a design error if you are storing temp data in your front end. Move the temp data to a separate file and use linked tables. Then you don't have to compact -- you can just copy an template database over top of it before appending your new data.
回答2:
The only solution ever found was for the scheduled task that called the Access macro to delete the original and rename db1.mdb to replace it.
To avoid disaster, instead of deleting, it overwrites the previous day's version in an archive.
This is not the "right" solution, but when the problem cannot be found, .....
回答3:
I've got the same problem, inherited old Access DB's that aren't right, but we can't let go of.
I've run into the same permissions problem & have fixed it before by copying the system.mdw
file from one PC to another. I have an old XP PC that is able to compact & repair a couple of DBs that no other machine can run utils
on.
Can't recall what else I did, but I think it is an artifact from Access 97, so try searching on that version & the .mdw
file for a better answer.
来源:https://stackoverflow.com/questions/6740334/access-unable-to-complete-compact-and-repair-on-one-machine