PC Review


Reply
Thread Tools Rate Thread

Automating CompactRepair--"db in use" error

 
 
Phil Freihofner
Guest
Posts: n/a
 
      22nd Mar 2010
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
 
Reply With Quote
 
 
 
 
Alex Dybenko
Guest
Posts: n/a
 
      23rd Mar 2010
Hi,
try to make a copy first, and then Compact a copy

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com


"Phil Freihofner" <(E-Mail Removed)> wrote in
message news:341A6A68-A359-49C2-9AAB-(E-Mail Removed)...
> 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


 
Reply With Quote
 
Alex Dybenko
Guest
Posts: n/a
 
      23rd Mar 2010
You can use this code to make a copy:
http://www.mvps.org/access/api/api0026.htm

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com


"Alex Dybenko" <(E-Mail Removed)> wrote in message
news:Oxuz#(E-Mail Removed)...
> Hi,
> try to make a copy first, and then Compact a copy
>
> --
> Best regards,
> ___________
> Alex Dybenko (MVP)
> http://accessblog.net
> http://www.PointLtd.com
>
>
> "Phil Freihofner" <(E-Mail Removed)> wrote in
> message news:341A6A68-A359-49C2-9AAB-(E-Mail Removed)...
>> 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

>

 
Reply With Quote
 
Phil Freihofner
Guest
Posts: n/a
 
      25th Mar 2010
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



"Phil Freihofner" wrote:

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error messages: "Winsck," "Status," and "Unable to open dialog" =?Utf-8?B?Sm9u?= Microsoft Windows 2000 0 17th Dec 2003 10:46 PM
Manual "Windows Update" produces "ActiveX/active scripting" error message even with "LOW" security level setting in "Trusted" Zone Ray2 Windows XP Help 1 14th Nov 2003 06:50 PM
Error messages: "Winsck," "Status," and "Unable to open dialog" =?Utf-8?B?Sm9u?= Microsoft Windows 2000 0 9th Nov 2003 06:16 AM
Error messages: "Winsck," "Status," and "Unable to open dialog" =?Utf-8?B?Sm9u?= Microsoft Windows 2000 0 28th Oct 2003 12:51 AM
Error messages: "Winsck," "Status," and "Unable to open dialog" =?Utf-8?B?Sm9u?= Microsoft Windows 2000 0 16th Oct 2003 03:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:35 PM.