• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 471
  • Last Modified:

Access 2003 Compact cannot find database

I have a macro that does a RunCommand where Command is CompactDatabase.  I get the error message:

The Microsoft Jet database engine cannot open the file 'C:\Users\Judith\CARE2.8\db1.mdb'.  It is already opened exclusively by another user, or you need permission to view its data.

The file db1.mdb doesn't exist.  The file I'm trying to compact is CareProgram.mdb.  Where is the db1.mdb coming from?

  • 2
1 Solution
Kelvin SparksCommented:
The Compact and Repair creates a new db1.mdb with your data compacted, then deletes the original, and then renames db1.mdb as your database. You cannot compact your database while you are in it via a macro or code.

Jeffrey CoachmanMIS LiasonCommented:
You can however do this with an AutoKeys Macro, using Sendkeys
(do a web search of:  Sendkey issues
...to learn about the concerns when using SendKeys)

Something like: %TDC

Not near my Access 2003 box right now, but I am sure another expert can finish this off for you...
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Have the Permissions on the folder 'C:\Users\Judith\CARE2.8 changed at all recently ??

Are you SURE the db is not open in another instance ?

Do you see an LDB file in that folder ?
Jeffrey CoachmanMIS LiasonCommented:
I think like this:
Create  a macro named "AutoKeys"

Make the Name: ^+C
(This will be the key combination Ctrl+Shift+C)

Then set this as the  Action: SendKeys

Then set this as the argument:  %(TDC)
Or perhaps:  "%(TDC)"

Perhaps not 100% correct syntactically, but that is the general idea

You can see here for more info:

And also see AutoKeys and Sendkeys in the Access help files...

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now