|
-
Oct 7th, 2006, 11:05 AM
#1
Thread Starter
Fanatic Member
Delete a file
Hello,
i want to delete my database using Kill App.Path & "\pcdb.mdb"
but the error message cmoes "ACCESS DENIED"
the full code is :
Private Sub CmdRestore_Click()
If Db.State = 1 Then
Db.Close
End If
SetAttr App.Path & "\Pcdb.mdb", vbNormal
Kill App.Path & "\pcdb.mdb"
If Db.State = 0 Then
On Error GoTo PerErr
FileCopy Direc & "\" & FileName, App.Path & "\pcdb.mdb" '& Format(Date, "dd/mm/yyyy") & ".mdb"
MsgBox "Restore completed ", vbInformation, "Restored"
SetAttr App.Path & "\Pcdb.mdb", vbHidden
PerErr: 'Access Permission (If Database is in use)
If Err.Number = 75 Then
MsgBox "Database is in use. Unable to create backup", vbCritical, "Database is in use"
Exit Sub
End If
End If
End Sub
please help me
-
Oct 7th, 2006, 11:07 AM
#2
Re: Delete a file
What other objects in your app is referencing/using the database?
There may be also other applications (external) using the file such as an open MSAccess.
-
Oct 7th, 2006, 11:10 AM
#3
Re: Delete a file
Try this
VB Code:
Private Sub CmdRestore_Click()
On Error GoTo PerErr
'If Db.State = 1 Then
'Db.Close
'set db=nothing ' ---> new additon
'End If
set db=nothing ' ---> new additon
SetAttr App.Path & "\Pcdb.mdb", vbNormal
Kill App.Path & "\pcdb.mdb"
'If Db.State = 0 Then
FileCopy Direc & "\" & FileName, App.Path & "\pcdb.mdb" '& Format(Date, "dd/mm/yyyy") & ".mdb"
MsgBox "Restore completed ", vbInformation, "Restored"
SetAttr App.Path & "\Pcdb.mdb", vbHidden
Exit sub '--> New
PerErr: 'Access Permission (If Database is in use)
If Err.Number = 75 Then
MsgBox "Database is in use. Unable to create backup", vbCritical, "Database
is in use"
Exit Sub
End If
'End If
End Sub
Last edited by danasegarane; Oct 7th, 2006 at 11:15 AM.
-
Oct 7th, 2006, 11:10 AM
#4
Re: Delete a file
Or you simpy don't have sufficient rights...
-
Oct 7th, 2006, 11:17 AM
#5
Thread Starter
Fanatic Member
Re: Delete a file
On Kill App.Path & "\pcdb.mdb", gives the error Permission Denied. Y ?
-
Oct 7th, 2006, 12:55 PM
#6
Re: Delete a file
The file itself may have its permissions set to prevent delete if your using an OS with a filesystem with built in security.
What's your operating system?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|