Link to home
Start Free TrialLog in
Avatar of pauldownham
pauldownham

asked on

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.    
Avatar of jdera
jdera

Is the user running the compact and repair an administrator?
Avatar of pauldownham

ASKER

yes
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
"Any ideas?  "

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

M$ motto:  If it works, break it!

mx
ASKER CERTIFIED SOLUTION
Avatar of jdera
jdera

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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?  
Just the way the compact and repair has to write back to the same database.  Vista just works a bit different.
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