I'm having this problem regarding my Backup code.
I get an error saying "Permission Denied".
Here's my code:
Public Sub DBBackup()
Dim fsys As New FileSystemObject
Dim myfile As File
Dim isTrue As String
Dim isFalse As String
Set myfile = fsys.GetFile(App.Path & "\Database.mdb")
'Create Backup folder if not present
If fsys.FolderExists(App.Path & "\Backup") = False Then
fsys.CreateFolder App.Path & "\Backup"
End If
isTrue = App.Path & "/Backup/" & Format$(Date, "yyyy-mm-dd")
'Replace file if existing
If fsys.FileExists(isTrue) = True Then
fsys.DeleteFile isTrue
End If
'Start Backup Process
If myfile.Attributes = ReadOnly And myfile.ParentFolder.Attributes = ReadOnly Then
myfile.Attributes = Normal And myfile.ParentFolder.Attributes = Normal
fsys.CopyFile (App.Path & "\Database.mdb"), App.Path & "\Backup", False
End If
MsgBox "Database Backup Process Complete", vbInformation, "Information"
Set fsys = Nothing
Form2.Enabled = True
Unload Me
End Sub
I don't know if it is the code or it has something to do with file/folder attributes specifically Read Only attrib.
My Database file "Database.mdb" has no set attribute's, but the folder where i want to create a backup file of my Database is set to Read Only and also the folder that contains my whole project (Includes Both of Backup folder and program).
I tried removing the Read Only attrib but it returns as soon as i look at its attrib again.
Note: i am log on as Admin on my PC