Automating CompactRepair--"db in use" error


P

Phil Freihofner

I ran the following line of code from a db, called "writer.db".

Application.CompactRepair "projecttrack.mdb", "db1.mdb", True

It worked great, creating both the "db1.mdb" file and a log file.

I erased the db1.mdb & the log file, and tried to run it again, and it
failed, giving the following error:

"Runtime error 7866.
Microsoft cannot open the database because it is missing or opened
exclusively by another user."

I've closed all my copies of Access and reopened them, tried running again
and get the same error. The applications are on my desktop computer--no one
else could possibly be using them. Why did it work once then stop working?

Many thanks,

Phil Freihofner
 
Ad

Advertisements

Ad

Advertisements

P

Phil Freihofner

I switched from using the Application.CompactRepair to
dbEngine.CompactDatabase. The latter function seems to do the job.

I appreciate the code that was sent (as complex and unreadable as it was)
for copying a database. At some point I might try to figure it out. But
copying the database seemed like, at best, a clumsy workaround. There was no
reason that I can see that a direct statement should not work!!

I would be interested in knowing why the dbEngine.CompactDatabase works in
situations where the Application.CompactRepair does not. But since the latter
seems more current, perhaps the first has been deprecated or is buggy?

Thanks,

PF
 

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