Compacting error

B

Bill Brinkworth

I had this compacting routine working for days in my access 2003 program,
then i ran it this morning and got a "you attempted to open a database that
is already opened exclusively by user admin in machine.... (runtime error
3356). I rebooted machine. Nothing else is using it, and as i said it was
running fine in the past. How in the world can i get it to work, i even
added code to close it, buut still...

yes there is a .ldb open on the db..but it worked b4!

here's what i have:
'i just added this..but it doesn't help
Set dbWCData2003 = OpenDatabase("c:\bcs\worldchildren\wcdata2003.mdb")
With dbWCData2003
.Close
End With

'''
DBEngine.CompactDatabase "c:\bcs\worldchildren\wcdata2003.mdb",
"c:\bcs\worldchildren\wcdata2003Compact.mdb"

thank you for your time and help!!!!...in advance....
 
M

Michel

Ken,

Can you be more explicit when you suggest "see reply in m.p.a.modulesdaovba"

Where in this newsgroup can I find the answer you are pointing to ?
 
D

Douglas J. Steele

microsoft.public.access.modulesdaovba

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)
 
R

Richard

Hi,
I figured out what was the problem and here's the solution...
I had this line of code in Form_Load:
Set rs = Me.Recordset.Clone
I used rs throughout my coding diffent modules as needed.
I never thought of closing it. I didn't know it was necessary.
Then this evening it hit me....rs is still open and Access thinks it's still
in use...hence the error described below when exiting Access if the 'Compact
on Close option was checked in Tools...Options....General Tab....

"You attempted to open a database that is already opened exclusively by user
'Admin' on machine 'DELL'. Try again when the database is available."

So I put this code in my Form_Close event:
Set rs = Nothing
Then set the Compact on Close option on the general tab.
My database closed with no error!!

I hope this helps some folks,

Richard
 

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

Similar Threads


Top