Compact & Repair Code - File Permissions question

M

Marc T

hi all,

here's a poser that has got me stumped....

I use the following code to compact/repair a database backend:

Private Sub Form_Unload(Cancel As Integer)

Dim strBackupBackend As String
Dim strCurrBackend As String
Dim strCurrLockFile As String

strCurrBackend = CurrentProject.Path & "\Data\" &
Left(CurrentProject.Name, Len(CurrentProject.Name) - 4) & "_be.mdb"
strCurrLockFile = CurrentProject.Path & "\Data\" &
Left(CurrentProject.Name, Len(CurrentProject.Name) - 4) & "_be.ldb"
strBackupBackend = CurrentProject.Path & "\Data\" &
Left(CurrentProject.Name, Len(CurrentProject.Name) - 4) & "_be.bak"

If Len(Dir(strCurrLockFile)) > 0 Then
MsgBox strCurrBackend & " is still in use. " & _
"It cannot be compacted."
Else
If Len(Dir(strBackupBackend)) > 0 Then
Kill strBackupBackend
End If
Name strCurrBackend As strBackupBackend
DBEngine.CompactDatabase strBackupBackend, strCurrBackend
End If

End Sub



It works a treat, but now I'd like to set file permissions for the backend
database.... problem is, the code above creates a new version of the backend
prior to compacting which inherits permissions from the directory it is sat
in wiping out the permissions I've set. Does anyone have any ideas on how to
force the backend to keep the permissions I have set?

Cheers as ever!
Marc
 
M

Marc T

Hi,

no worries!

It's straightforward file permissions and not via an MDW file. The backend
database file itself is set as read only access for some users, and full
access for others (via properties>security menu in explorer). What I want to
do is keep these permissions, but the code to compact and repair always
creates a new version of the backend file which then inherits permissions
from the parent folder that the .mdb file is in.

Marc
 

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

Top