PC Review


Reply
Thread Tools Rate Thread

Compact & Repair Code - File Permissions question

 
 
Marc T
Guest
Posts: n/a
 
      20th Apr 2010
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

 
Reply With Quote
 
 
 
 
Argyronet
Guest
Posts: n/a
 
      20th Apr 2010
Hi,

I do not understand your problem |
Do you speak about MDW file ?

--
Argy
Goto : http://argyronet.developpez.com/
Livres :
Créez des programmes avec Microsoft Access 2007 (ISBN 2742982442)
VBA pour Office 2007 (ISBN 2742983910)



"Marc T" wrote:

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

 
Reply With Quote
 
Marc T
Guest
Posts: n/a
 
      20th Apr 2010
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

"Argyronet" wrote:

> Hi,
>
> I do not understand your problem |
> Do you speak about MDW file ?
>
> --
> Argy
> Goto : http://argyronet.developpez.com/
> Livres :
> Créez des programmes avec Microsoft Access 2007 (ISBN 2742982442)
> VBA pour Office 2007 (ISBN 2742983910)
>
>
>
> "Marc T" wrote:
>
> > 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
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
compact and repair through a VB code Pietro Microsoft Access 2 14th Feb 2008 02:22 PM
Code to compact and repair =?Utf-8?B?dHJveQ==?= Microsoft Access Form Coding 1 10th May 2006 07:06 AM
Compact Repair code? =?Utf-8?B?TWFCZWxs?= Microsoft Access VBA Modules 4 2nd Aug 2005 10:14 PM
access 2002 vba compact-repair permissions =?Utf-8?B?bWFkaG91c2U=?= Microsoft Access Security 2 1st Mar 2005 07:45 PM
windows permissions change after compact repair Dan Microsoft Access Security 0 20th Feb 2004 06:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:02 AM.