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
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