1

I currently use the VB6 CompactDatabase method to compact a .mdb (Access DB) file and have searched high and low for a way to reapply the Share Permissions on Original DB using VB6.

The CompactDatabase code:

Set jro = CreateObject("jro.JetEngine")
If IsObject(jro) Then

    jro.CompactDatabase _
        "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sourcePath & _
            ";Jet OLEDB:Database Password=" & DBPassword, _
        "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & tmpPath & _
            ";Jet OLEDB:Database Password=" & DBPassword & _
            ";Jet OLEDB:Encrypt Database=True;Jet OLEDB:Engine Type=5;"
Else
    compactDB = "Compact Failed: MDAC not installed correctly - missing JRO.JETENGINE"
End If

This compacts to new DB and sequence is to Delete the original and rename new to old.

Problem with this is that new file does not have original Share Permissions, Currently set to 'Everyone' with 'Full Control'. I have found code on how to set permissions on folders but not directly to files.

Any help would be appreciated.

chue x
  • 18,573
  • 7
  • 56
  • 70
FLOG51
  • 43
  • 1
  • 6
  • You know that you must have permissions on the folder for MS Access to work? – Fionnuala Mar 27 '13 at 11:21
  • Yep, been running the system for many years now. This is not the issue, just the loss of original permissions after compacting and creating a new compacted .mdb. – FLOG51 Mar 28 '13 at 01:39

1 Answers1

0

For anyone who is interested I have found the resolution.

In original code; by using a temp path "C:\temp" to create the new '.mdb' and then copying it over to my Program Files directory; I actually inherited the Permissions of "temp" folder.

I changed the Temp file name to be in same directory as current DB and when process is complete new .mdb has full permissions as with Old.mdb. Cheers

FLOG51
  • 43
  • 1
  • 6