Problem running Access Compact & Repair on Vista with UAC enabled

I've got a button on a form that runs the Compact & Repair facility, using code from the EE site:

   Commandbars("menu bar"). _
   Controls("tools"). _
   .
   .
   accDoDefaultAction

and this works fine in Win98, XP etc.   However, in Vista, if the User Account Control is enabled (which it usually is) it throws up an error message saying that the database file can't be deleted because it is read-only (which it isn't), and then creates a db1.mdb file instead.

Any ideas?    I need to keep the action hidden behind a button, and the users do not have a full copy of Access, just the runtime version, so they can't use the normal toolbar way of doing it.    
pauldownhamAsked:
Who is Participating?
 
jderaConnect With a Mentor Commented:
Full permissions to that user in the folder where the database is located?
0
 
jderaCommented:
Is the user running the compact and repair an administrator?
0
 
pauldownhamAuthor Commented:
yes
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
"Any ideas?  "

Change the UAC settings.  Man, ya gotta love Vista and UAC.  Insane!

M$ motto:  If it works, break it!

mx
0
 
pauldownhamAuthor Commented:
I think some users would be uncomfortable with UAC off, because their system would keep recommending them to switch it back on.

Presumably there's no way in VBA to see if UAC is enabled, and if so disable it, do the compact and re-enable?

Paul
0
 
pauldownhamAuthor Commented:
jdera,

The user has administrator rights, and the folder says these have Full Control.

But out of interest I logged in as the actual administrator and the compact went OK!  So I gave all the Users Full Control, and its also OK.

So that's a bit odd, why it didn't work in the first place?  
0
 
jderaCommented:
Just the way the compact and repair has to write back to the same database.  Vista just works a bit different.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Vista has UAC ... and those are the issues.

C&R

1) Compacts into DB1.mdb
2) If successful, tries to delete the original mdb, then rename DB1.mdb to the original.

mx
0
All Courses

From novice to tech pro — start learning today.