Dvorak Pietrek
New member
- Local time
- Today, 02:44
- Joined
- Sep 6, 2025
- Messages
- 18
hi
hoe to delete a non empty directory using Access VBA 2017?
THANKS
hoe to delete a non empty directory using Access VBA 2017?
THANKS
Sub DeleteFolderFSO(ByVal FolderPath$)
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(FolderPath) Then
fso.DeleteFolder FolderPath, True ' True = force delete non-empty folder
MsgBox "Folder deleted successfully.", vbInformation
Else
MsgBox "Folder not found.", vbExclamation
End If
Set fso = Nothing
End Sub
Are you saying the Access file is also in the directory you want to delete?I am using Access VBA 2007 and is the only app active. If I close it, then the directory releases and I can delete it manually. But I want to delete this directory just from my Access VBA code.
Ii hope it is not the same directory your ACCESS file is in.I am using Access VBA 2007 and is the only app active. If I close it, then the directory releases and I can delete it manually. But I want to delete this directory just from my Access VBA code.
Have you checked the permissions on the d:\pics\docs directory? Is d: a removable drive that has write-protect enabled? Have you tested creating and removing another folder on d: ?yes i deleted all the files in the directory but can't delete this empty direct
Is d: a disk partition, or a mounted volume, like a flash drive? Is the account you're logged into have admin privileges? Maybe there's a hidden file or subfolder in the folder you want to delete?i have tried all that
Well I can't think of anything else at the moment. I hope you find a solution. Cheersis a hard disk